home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMOS PD CD
/
amospdcd.iso
/
551-575
/
apd558
/
amoner2
/
doc
/
loancalc.doc
< prev
next >
Wrap
Text File
|
1993-11-29
|
4KB
|
120 lines
Things to look for when porting to AMOS
by
Michael Cox
Welcome, gentlemen and ladies, to another edition of the Amoner Project. I
hope you have enjoyed the show so far!
It has come to my attention that many people buy newer BASIC flavors so
that their old BASIC programs will run faster, better, and, hopefully, more
efficiently. Unfortunately, not all BASICs are the same. I hope this
short little article will help you with translating your old programs to
AMOS.
The first difference that I noted was the LOCATE command. In Amiga and
HiSoft BASIC, the command is in the format:
LOCATE Y,X
In AMOS, it is in the format:
LOCATE X,Y [that makes more sense as a graph coordinate is represented by
(x,y)]
So, the simple and obvious fix is to reverse the X,Y position.
The second difference is the way the colour of printed text is changed.
In Amiga and HiSoft BASIC, they use the COLOR command, with the following
syntax:
COLOR [foreground][,background]
foreground is the text and graphics colour, represented by a number
background is the screen background colour, represented by a number
In AMOS, the COLOUR command is used to change an individual colour in the
current palette. The format for this command:
COLOUR n,$RGB
n is the index for the colour and $RGB is the hex value for the new colour.
For instance, to change colour index 0 from its original colour to yellow,
one would do:
COLOUR 0,$FF0
To change the colour of printed text in AMOS, you use the PEN command.
PEN is used in the following way:
PEN n
Where n is the colour's index number. So, from our preceding example, if we
wished to print the word 'BEAN' in yellow, we would do as follows:
COLOUR 0,$FF0
PEN 0
PRINT "BEAN"
To change COLOR to PEN, you need to search and replace the word 'Col or' in
the AMOS Editor. Why? Well, since COLOR is not a command, the AMOS Editor
thinks you mean 'Col' (collision) and 'or' (logical OR) and automagically
separates the word.
The simplest difference is the CLS command. AMOS also has a CLS
command, but it acts differently from the CLS command in HiSoft BASIC. If
you look at the program LoanCalc, you will see that it opens a window to
perform all its operations. In AMOS, if you do a CLS after you open the
window, it will erase the window's border, including both the top and bottom
titles. So, instead, one should use the CLW command if you want to clear
the screen inside the window. If you wish to wipe out everything, CLS is
the way to go. Believe it or not, this was tricky for me to catch as I
did not think CLS would do such a thing.
Another difference, and it is a large one, is that AMOS considers all numbers
to be integers (which makes AMOS faster) unless told otherwise. HiSoft and
Amiga BASIC consider all numbers to be floating point unless told otherwise.
So, if you have a program that uses floating point numbers, make sure you
specify which variables are floats in AMOS. To do so, you append the '#'
(pound/hash mark) to the variable:
A#, A#()
One thing to remember is that the variable
A
is different from the variable
A#
So, if you change a variable from an integer to a float in one area of your
program, make sure you do a global change. Also, when using numbers that
represent dollars and cents, it is always best to add the command:
FIX 2
at the beginning of the program. This sets the floating point numbers to two
(2) digits to the right of the decimal point. As always, due to the nature
of floating points, you will not get 100% accuracy. Even if you compare the
output from AMOS to the output from Amiga or HiSoft BASIC, you will not
always get the same numbers. This is due to the way that the individual
BASIC rounds floating points.
Well, that is all for this "How to" article. In following articles, I will
stick to the differences that I have had to make to get a program
to run. For this article, I ported a program called 'The Loan Calculator'
from HiSoft BASIC to AMOS. LoanCalc was originally written by Ira S. Davis
of the USA.
If you have any questions about porting programs or anything else, you can
mail them to me via Internet or Snail (Postal) mail.
Internet: aj639@Cleveland.Freenet.EDU
Snail: 6970 Vaughn Pointe Drive, Suite H, Montgomery, AL 36116-1395 USA