Hi Walt,
NOTE: I have no idea why this went to my drafts, but I'm posting it anyway incase you find the information useful.
Anything else you need, let us know.
I wrote a partial conversion program to convert PowerBASIC to SmartBASIC code.
If your plan is to run SmartBASIC code on a PC, I can give you a few more specific pointers.
First, all languages, whether different dialects of the same language, or converting from, say COBOL to BASIC, all languages have core functions that should be easy to convert.
That's assigning variable values, moving values around, string functions, math, sequential files, and print/display* for starters. I'll explain the * by display in a bit.
But then there are other device or OS-specific features that there may not be anything to convert it to. For example, graphics. IOS and SmartBASIC has built into the interpreter access to use Retina, which does not exist outside iOS.
Then there are different ways languages identify functions. Modulo, for example, is different Among languages. Most use the convention of X=360 MOD 45, where SmartBASIC uses X=360%45. So knowing these differences when selecting a dialect on Windows is very important.
Also, there will be built in functions, some bearing the same name and others that are unique that there is no easy conversion.
One example is when converting PowerBASIC(PB) to SmartBASIC(SB) source. An easy example is PB's INCR and DECR statements. In the code, you can write DECR I. This is the same in SB as write I=I-1 or I-=1. These, you can write SB functions to do this.
File processing is one of those areas that can have great differences. In PB, I can create a record type variable that holds a mixture of string and numeric variables. I can do a WRITE #1 RECTYPE$, but this cannot be done in SmartBASIC.
I can write a book on this topic, but I just wanted to give you some of the problems you or I will run into when taking source code and trying to make it if somewhere else.
After Matt Dean gave me the source code for Deskware's COBOLScript program, while this isn't BASIC, I can tell you about the hurdles that I faced when getting the compiler (This is a real compiler and linker that creates an executable binary file) to work on Apple's OS. It works on Windows and 4 different brands of UNIX, and it does work on Macs, but there were major OS incompatibility.
COBOLScript is written and compiled in Visual Studio in C/C++. This means when I compiled the product, it took with it Visual Studio internals with it. Inbetween going from source to executable binary, you can create an object module. This module is supposed to give you the ability to do the final linkedit or make on the device you plan to run on.
Due to the VS functions and routines, I had to practically do a rewrite which reduced the functionality, as I needed to remove all the VS code. Most of this code dealt with OBDC, or the ability to use SQL products from different vendors. The VS code allowed me to not worry about the extra code needed to interface with and tell the difference between Sybase SQL vs. MySQL vs. MSSQL, or even MS-ACCESS.
So I had to select the most popular products and write my own routines. This is just one of the many headaches that developers like Mr K has to deal with in porting his product to work on another OS.
I tried to make is sound simple (much more than it actually is) so you could understand what has to be done, even if the developer gave you the source and said "Good Luck" as Matt Dean said to me back in 2006.
Since I was a systems programmer, designed new 4GL's and even added new functions to existing languages, without having to get really technical, I hope the over simplication painted a broad enough picture of the issues involved in making a language (or even a application for that matter) work in different operating systems.
The best way to make an application or a programming language work in many operating systems is to put that in your design from the beginning, where all these issues can be addressed in advanced.
SmartBASIC is very versatile when I performed the exercise of converting PB to SB. It's Functions and Subroutines practically allows you to create new programming statements. So if you like a statement from another language, chances are you can write a Function that allows you use them in your main code.
Ricardo and I (and someothers) explored this and put this in a post thread. Besides that, another showed how you can include Javacript code within your SmartBASIC source. Links to the posts are below.
Whatever language you choose to convert SB to a Windows language, you will, more than likely, be able to use the same principles of writing your own functions to serve as executing new source code statements.
The program attached here is a library of functions, where some are new statements, and some are conversions of existing PB statements that preserve not only the source statement itself (you may need to use brackets), but some new statements, such as printline, which I use so that I just pass it a parameter and it prints the number of lines I need instead of having a program where I may need to use many PRINT statements throughout. It makes the code look cleaner as well.
Example #1:
Logic Functions:
viewtopic.php?f=24&t=1772&p=11040&hilit=PRINT#p11040
User Davey110 noticed and posted:
"x=5
PRINT 3+(x=5)
Other versions of BASIC will evaluate (x=5) as True, then return a 1. Then 3+(1) will print as 4."
I wrote a sample function that allowed a programmer to use this type of logic in their SB program.
Example #2
waltax wrote: ↑Fri Jun 02, 2017 8:20 pm
Thanks for the information. This is very useful.