OK, here is the code for finding roots of polynomials using Bairstow’s method in both Liberty Basic 2 and in Smallbasic.
Liberty Basic 2 - bairstow.bas
Smallbasic - sb_bairstow.bas
There were really only three major changes and most of the work can be done using the find and replace tool in the Smallbasic editor.
1. Labels
Liberty basic uses brackets around lables, e.g. [jumptohere], while Smallbasic uses a two prong approach. You identify a label using “label jumptohere,” but you go to that label using just plain jumptohere. So you must search for all the brackets and replace them with spaces. Next find the actual label point and add label in front of it. A valid liberty basic lable is:
if x=1 goto [here]
x=100
[here]
While a similar Smallbasic program would be:
if x= 1 then
here
end if
x=100
label here
Also note that Smallbasic doesn’t like the label to be on a single line if statement. Use “then” and “end if.”
2. Functions
Functions are handled somwhat differently, but the important thing to note in this example is that a function was created to incorporate the SGN keyword into Liberty Basic. Smallbasic already had the SGN keyword because it is much more mathematically robust. So in this case you just delete the function.
There are other inconsistentcies, but labels will be the major problem in all of these programs.
|