EasyManua.ls Logo

HP TACL - Page 62

HP TACL
235 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Processing Arguments
Developing TACL Routines
3–6 107365 Tandem Computers Incorporated
The following examples illustrate two ways to retrieve a number from a position
within a line of text (as returned by FUP or other processes). First, you can use the
#CHARGET function:
#PUSH pfree line
#SET line This is a test number: 53
#SET pfree [#CHARGET line 24 FOR 2]
#OUTPUT [pfree]
The preceding code retrieves two characters from line, but does not check that the
two characters are numbers. The number at position 24 must be two characters long;
the code returns two digits even if the number has a single digit or three digits.
As an alternative, you can define a routine that uses #ARGUMENT.
?SECTION getnumber ROUTINE
#FRAME
#PUSH rslt arg position
== First, get the requested character position
#SET rslt [#ARGUMENT /TEXT position/ NUMBER OTHERWISE]
[#CASE [rslt]
|1|
== position is OK
|2|
== Caller did not supply a number for position arg.
#RESULT -1
#RETURN
]
== Skip [position] characters
SINK [#ARGUMENT CHARACTERS /WIDTH [position]/ ]
#SET rslt [#ARGUMENT /TEXT arg/ NUMBER OTHERWISE]
[#CASE [rslt]
|1|
#RESULT 0 [arg]
|2|
== Invalid argument; text at specified position is
== not a number
#RESULT -2
]
#UNFRAME
If getnumber finds a number, it returns a zero followed by the requested number. If
position is invalid, it returns -1; otherwise, it returns -2.

Table of Contents

Related product manuals