home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TCE Demo 2
/
TCE_DEMO_CD2.iso
/
demo_cd_.2
/
mags
/
stosser
/
stoser03.arj
/
stoser03.msa
/
A
/
A13.DOC
< prev
next >
Wrap
Text File
|
1987-04-22
|
5KB
|
195 lines
UNDERSTANDING STOS
Copied from the STOS Magazine
Thanks to Dion Guy who retains the
Copyright to this Article
Here is the final part of our A-Z
variable guide (see issues 1+2).We also
have a bit more on using variables in
your programs.
SGN(num var)
SGN is used to find the SIGN of a
number.The result will equal -1 if the
number is negative,0 if the number is
zero and 1 if the number is positive.Eg
{A=10:print SGN (A)} will display 1 as
a result.
SORTdimensioned var or num var(startpos)
SORT can sort through your array and
put the contents into ascending order
for you. It does this relatively
fast.For example if you have an array
of 10 numbers,say NUM,that you wanted
to sort into ascending order you would
just use-sort NUM(0). The number in the
brackets indicates the place in the
array to start sorting from(usually 0).
Type in this program to see sort in use.
10 dim NUM (10)
20 for A=1 to 10
30 B=rnd(100)
40 NUM(A)=B
50 next A
60 sort NUM(0)
70 for A=1 to 10
80 print NUM (A)
90 next A
100 end
This program will pick ten random
numbers from between 1 and 100 and
store them in the NUM array. We then use
the sort command to sort these random
numbers into ascending order. Lastly we
print the numbers so you can see sort
has done its job.SORT is mainly used in
conjunction with MATCH which allows you
to find the closest match to a
specified variable within an array.
See MATCH for further details.
SPACE$(number of spaces)
This is a reserved variable which
allows you to add spaces to a string
or display spaces on screen. Eg :
10 print "Hello";SPACE$(5);"there"
or
10 A$="Hello"
20 A$=A$+space$(5):A$=A$+"there"
30 print A$
STR$ (num var)
STR$ converts a number to a string.
This is useful for using the `centre`
command as centre does not allow you to
display number variables etc. Eg:
10 A=4
20 home:centre " STOS Magazine issue"
+str$(A)+" is here !"
or another use:
10 A=68000
20 print A
30 A$= str$(A):print A$
The opposite,VAL,allows you to convert
a string to a number. See VAL.
STRING$ (var,length)
STRING$ can be used to create a string,
length characters long,containing
nothing but the first character of the
specified string. Eg: print
STRING$("HAT",10) -will display 10 H's.
SWAP (var/num var,var/num var)
This simply SWAPs the information of
two variables(of the same type)around.
Eg :
10 A=10:B=20
20 swap A,B
30 print A,B
TIME$
TIME$ is a string that STOS updates
every 50th of a second,and contains how
long ,in hours,minutes and seconds that
STOS has been running. The format of
this variable is"hours:minutes:seconds"
and can be set with a command such as:
TIME$="01:20:30". This would set the
clock to 1 hour,20 minutes and 30
seconds.
TIMER
TIMER is another variable that STOS
updates every 50th of a second,and
represents how long STOS has been
running. The format is different from
TIME$ though as this contains the
actual 50th's of a second STOS has been
running. Eg - if STOS has been running
for 2 minutes, TIMER would contain the
number 6000. You can alter TIMER in the
same way as you can alter any other
number variable. Eg - TIMER=0. This
reserved variable can be used to time
program execution times,program loops
or can be used as an in game/program
timer.
TRUE
TRUE is basically a number variable
that always contains the number -1. The
TRUE command can be used to make
decisions as to whether things are true
or false. Eg :
10 A=10:if A>0=TRUE then print "{A} is
higher than zero"
See FALSE
UPPER$
UPPER$ is used to display a string in
upper case letters,even if the string
is in lower case letters. Eg - print
UPPER$("lower") -will display `LOWER `.
Another example:
10 A$="Hello"
20 A$=upper$(a$)
30 print A$
See LOWER$
VAL(var)
VAL is used to convert a string into a
number variable. Eg :
10 A$="10"
20 A=VAL(A$)
30 print A
See STR$
XGRAPHIC(num var)
This command is very useful as it
converts a X text coordinate into a X
graphic coordinate. Eg - print
XGRAPHIC(2) {from the standard STOS
editor window} - will return 16. This
command {and YGRAPHIC} takes into
account if you are in a window.
See YGRAPHIC
XMOUSE
XMOUSE is a reserved variable which
holds the X position of the mouse
cursor. Eg - {print XMOUSE}.See YMOUSE
XTEXT(num var)
XTEXT is the opposite of XGRAPHIC in
that it converts Xgraphic coordinations
into X text coordinates. Eg - print
XTEXT(16){from the standard STOS editor
window} - will return 2. This command
{and YTEXT} takes into account if you
are in a window. See YTEXT
YGRAPHIC(num var)
The Y coordinate equivalent of
XGRAPHIC. See XGRAPHIC.
YMOUSE
The Y coordinate equivalent of XMOUSE.
See XMOUSE
YTEXT(num var)
The Y coordinate equivalent of XTEXT.
See XTEXT.