View Full Screen
Line Labels:
For line labels you simply write the name of the label and
put a colon after it. If a return is added then you can go
back to where you called the gosub.
EXAMPLE
top:
msg 'Beginning of subroutine.'
ask 'Do you wish to go back to the beginning? Y' dflt .t.
if ask()
goto top
else
gosub nextsub
goto top
endif
{
nextsub:
ask 'do you wish to go to first subroutine? N' dflt .f.
if ask()
ret
else
pops
goto exit
endif
}
exit:
quit
Commands:
Commands are basic subroutines that perform a set of
instructions. i.e. assigning variables values, etc.
in TAS you must have a #udc or #udx for ability to use
and define these in your program.
EXAMPLE
#udc
top:
msg 'This is the beginning of the program.' windows 'info'
subr
exit:
quit
cmd subr
msg 'Inside the subroutine ' windows 'info'
ret
note: in pascal and c++ you have the ability to only
reference the variables passed, and not change
them from within the function.
The values can be accessed and changed WITHIN the
command, but after you leave they hold the old values.
Functions:
Functions are defined much like the cmds are. There must
be a #udf, or #udx in order to define and use them within
your program. Advantages over pascal is that you do not
have to define the return type. You may return any type
field type.
EXAPMLE
define today type i
define alpha type a
define int type i
define today type d size 8
define choose type a size 1
top:
enter choose at 1,1 mask 'IAD'
if choose = 'I'
int = test_function(choose)
else_if choose 'A'
alpha = test_function(choose)
else
today = test_function(choose)
endif
exit:
quit
func test_function choose
if choose = 'I'
ret 213
else_if choose = 'A'
ret 'Alpha was chosen'
else
ret date()
endif
ret
Control Structures:
Control structures in TAS, Pascal, and C++ are essentially
the same. TAS control structures are blocked off by the
loop command and a type of end (endw) (ends) (next) etc..
TAS also has a control structure that is specialized for
searching through files. Pascal and C++ don't really have
that.
EXAMPLES
while a < b
pmsg a at 12,12
a = a + 1
endw
scan @file_hndl KEY key_name START start_value \ &&next line
WHILE conditional FOR conditional
sexit_if condition_1
sloop_if condition_2
pfmt 7
ends
for (cntr;1;15;1)
pmsg cntr at 1,cntr
next
a = 3
b = 5
if a > b
msg 'a is greater than b' windows 'info'
else_if b > a
msg 'b is greater than a' windows 'info'
else &&a and b are equal
msg 'they are equal!' windows 'info'
endif
define what type i size 1
enter what at 1,1
select what
case 1
msg 'What was one.' windows 'info'
case 2
msg 'What was two.' windows 'info'
case 3
msg 'What was three.' windows 'info'
otherwise
msg 'What was not one, two or three' windows 'info'
endc
INPUTTING VALUES:
In TAS there is a lot more power to inputting compared to
Pascal and C++ In Tas there is the ability to mask, execute
functions prior and post of input, optional helpkeys, and do
validity checks all values entered, combined into one
command, which allows the programmer to control input
better, easier, faster, and without nearly as much code.
EXAMPLE
define TEST type a size 1
enter TEST up mask 'YN' pre setup_test() post clr_test() \
vld TEST <> '' vldm 'You must enter something'
{
;inside these {} braces we can write functions that
; the compiler will never hit, unless it is called
; from elsewhere.
; when returning false from a pre-function it simply
; skips the input of that variable. and moves on to
; the next. If returning true, then you can now
; input the value as you normally would.
func setup_test
ask 'Would you like to enter this? (Y/N) N' dflt .f.
if .n. ask()
ret .f. && the input command will now be skipped.
endif
ret .t.
func clr_test
msg 'In post function, you may trap different keys'
msg 'You may also do math or whatever you want '
ret .t.
}
;This will force test into uppercase mask it to only
;Y and N, execute setup_test before allowed to enter,
;execute clr_Test after entered, and won't let you
;by if TEST is blank
Outputs:
TAS has a various ways of doing an output. There's a
pmsg, a msg, and an ask (ask is actually a function) Each
of these have ways of controlling the output, unlike Pascal.
EXAMPLE
top:
pmsg at 20,1 'This is a test' color 14
msg 'This is only a test'
ask 'Is this a test' dflt .t.
if ask() goto top