INTOUCH® 4GL
A Guide to the INTOUCH Language
SKIP(str_expr1 [, str_expr2] [, int_expr])
SKIP returns the position of the character following the last skipped
character.
str_expr1 is the text string to be searched.
str_expr2 contains the list of characters which are to be
skipped. If only one argument is given, SKIP will skip over spaces,
tabs and nulls.
int_expr contains the search start position. This parameter is
optional.
10 a$ = '31415 hello'
z = SKIP(a$, '1234567890 ')
20 PRINT mid(a$, z)
30 END
RNH
Hello
|
SORT$(str_expr1 [,str_expr2])
Sorts the elements from a str_expr1 in ASCII value order.
Returns a list of the sorted elements.
str_expr1 contains the list of elements to be sorted.
str_expr2 is an optional separator. Default is a comma.
10 a$ = 'code area is'
a_sort$ = SORT$(a$, ' ')
PRINT a_sort$
20 END
RNH
area code is
|
SPACE$(num_expr)
Returns the number of spaces indicated by num_expr.
SQR(num_expr)
SQR returns the square root of a number.
STR$(num_expr)
STR$ changes a number to a numeric string. The string that is created
does not have any extra leading or trailing spaces.
?8pc
SYSTEXT$
-
or
SYSTEXT$(int_expr)
SYSTEXT$ returns the text associated with the operating system status
specified. If no int_expr is supplied, INTOUCH returns the
text for the last system status.
TAB(int_expr)
When used with the PRINT statement, the TAB function moves the cursor
or print mechanism to the right to a specified column.
TAN(num_expr)
TAN returns the tangent of an angle that is specified in radians.
TANH(num_expr)
Returns the hyperbolic tangent of the numeric expression given.
TIME(int_expr)
The value returned by the TIME function depends on the value of
int_expr.
If int_expr = 0, TIME returns the number of seconds since
midnight.
If int_expr = 1, TIME returns the CPU time of the process in
tenths of a second.
If int_expr = 2, TIME returns connect time of the current
process in minutes.
?8pc
TIME$
-
or
TIME$(num_expr)
If num_expr is NOT specified, TIME$ returns the current time
of day in HH:MM:SS format.
num_expr is the number of seconds since midnight. The result
is returned in HH:MM format.
10 PRINT TIME$(1800)
PRINT TIME$(54178)
20 END
RNH
00:30
15:02
|
TIME(5)
Returns the number of seconds since INTOUCH was invoked. This function
can be used to time events to the nearest 100th/sec.
TRIM$(str_expr)
Returns the string specified stripped of any leading or trailing spaces
and tabs.
10 LET a$ = ' HELLO '
20 PRINT '*'; a$; '*'
30 LET stripped$ = TRIM$(a$)
40 PRINT '*'; stripped$; '*'
RNH
* HELLO *
*HELLO*
|
TRUE
Returns the constant 1. It is returned as an integer.
TRUNCATE(num_expr, int_expr)
Truncates a real number to a given number of decimal places.
UBOUND(array_name [, int_expr])
Given an array and a dimension number, returns the upper bound for that
dimension. It returns an integer value. The default dimension is 1.
UCASE$(str_expr)
UCASE returns a string expression with all letters in upper case.
UNQUOTE$(str_expr)
The UNQUOTE$ function removes one set of quotes from a quoted string
expression. If the string expression is not quoted, UNQUOTE$ leaves the
string alone. UNQUOTE$ does not affect internally quoted elements.
10 DO
CLEAR
PRINT AT 1,1:
MESSAGE 'Enter a line of text to be unquoted'
PRINT 'Text:'
INPUT '', LENGTH 50: line$
IF _BACK OR _EXIT THEN EXIT DO
IF line$ = '' THEN REPEAT DO
20 PRINT
PRINT 'Quotes removed using the UNQUOTE$ function...'
PRINT UNQUOTE$(line$)
DELAY
LOOP
100 END
RNH
Text:
? "I will not take these 'things' for granted"
Quotes removed using the UNQUOTE$ function...
I will not take these 'things' for granted
|
VAL(num_str)
VAL returns the floating-point value of a numeric string.
VALID(text_str, rule_str)
VALID is used to validate user responses.
text_str is the text to be validated.
rule_str is the list of validation rules.
Multiple validation rules are separated by a semi-colon. If given
characters are NOT between quotes, they are upper-cased.
VALID returns an error if there is an invalid validation rule.
'Illegal validation rule' (-4021)
|
VALID returns TRUE or FALSE according to the following validation rules:
-
- ALLOW text1, text2, text3 [to text4]
ALLOW
compares the text_str with each element on the
rule_str list (defaults to CHARACTER) and returns TRUE if
found.
For numeric comparison, "NUMBER" or "INTEGER" must
be used, otherwise, VALID() will do a string-compare validation...left
justified.
10 IF VALID('ann', 'ALLOW ann, dan, tom') THEN PRINT 'true'
20 IF NOT VALID('10', 'NUMBER; ALLOW 1 to 6; MAXLENGTH 2') &
THEN PRINT 'false'
30 IF VALID('12', 'NUMBER; ALLOW 1 TO 24,99') THEN PRINT 'true'
40 END
RNH
true
false
true
|
- DISALLOW text1, text2, text3 [to text4]
Returns TRUE if text_str cannot be found on the
rule_str list.
10 IF VALID('10', 'DISALLOW 01,03,05; MINLENGTH 2') &
THEN PRINT 'true'
20 END
RNH
true
|
- MINLENGTH nn
Minimum of nn characters long.
- MAXLENGTH nn
Maximum of nn characters long.
- LENGTH nn
Exactly nn characters long.
- CHARACTERS ccc
Returns TRUE if the given
characters (letters or numbers) are on the rule_str list.
- NOCHARACTERS ccc
Returns TRUE if the given
characters are not on the rule_str list.
- LETTERS
Returns TRUE if given
text_str consists only of A - Z, a - z or space.
- LCASE
Returns TRUE if given text_str
consists of lower-case letters.
- UCASE
Returns TRUE if given text_str
consists of upper-case characters.
- DIGITS
Returns TRUE if text_str
consists of the numbers 0 - 9.
- DECIMALS nn
Specifies the maximum number of
decimal places.
- NUMBER
Indicates that text_str is
numeric (validates that number).
- INTEGER
Returns TRUE if given integer number
is up to 32 bits long (i.e. 2147483647).
- INTEGER WORD
Returns TRUE if given integer
number is up to 16 bits long (i.e. 32767).
- DATE
Validates a given date in: YYMMDD or
CCYYMMDD format.
|
DATE
|
YMD
|
YYMMDD format
|
|
DATE
|
DMY
|
DDMMYY format
|
|
DATE
|
MDY
|
MMDDYY format
|
|
DATE
|
MDCY
|
MMDDCCYY format
|
Note
For all dates, use 'LENGTH nn' to control whether a 6- or 8-character
date is required.
|
- DATE DMONY
Checks if text_str is a
legal date in DD-Mon-YY format and returns TRUE or FALSE.
10 PRINT VALID('01-May-93', 'DATE DMONY')
20 END
RNH
1
|
- DATE DMONCY
Checks if text_str is a
legal date in DD-Mon-CCYY format and returns TRUE or FALSE.
10 PRINT VALID('01-May-1993', 'DATE DMONCY')
20 END
RNH
1
|
- FULLTIME
Checks if text_str is a
legal date and time in CCYYMMDD HHMMSS or YYMMDD HHMMSS format and
returns TRUE or FALSE.
10 PRINT VALID('19931231 010101', 'FULLTIME')
PRINT VALID('931231 010101', 'FULLTIME')
20 END
RNH
1
1
|
- PATTERN
Matches text_str with
PATTERN's rule_str. For details see the PATTERN$ function.
- REQUIRED
Returns TRUE if text_str is
not null or space(s).
- YES/NO
Returns TRUE if text_str
consists only of the following: YES, NO, Y or N.
- VRULES
Checks if a text_str is a
legal set of validation rules, and returns TRUE or FALSE.
10 PRINT VALID('integer', 'vrules')
20 END
RNH
1
|
- PRINTMASK
Checks the format of
text_str and returns TRUE if it is legal or FALSE otherwise.
10 text_str$ = '##.##'
PRINT VALID(text_str$, 'PRINTMASK')
20 END
RNH
1
|
- EXPRESSION
Validates a text_str and
returns TRUE if it is a legal INTOUCH expression or FALSE otherwise.
10 text_str$ = 'total = a% + 30'
PRINT VALID(text_str$, 'EXPRESSION')
PRINT VALID('##~-###', 'EXPRESSION')
20 END
RNH
1
0
|
- CODE
Checks for VALID INTOUCH code syntax.
10 a$ = 'PRINT 'Hello, ' name$'
IF NOT VALID(a$, 'CODE') THEN PRINT 'false'
30 END
|
- MENU
Validates a text_str and returns
TRUE if it is a legal menu description for an INPUT MENU statement, or
FALSE otherwise.
10 text_str$ = '%multi,a,b,c'
PRINT VALID(text_str$, 'MENU')
20 END
RNH
1
|
- ROUTINE
Checks to see if the given routine
name exists or not. TRUE (1) is returned if the routine name exists and
FALSE (0) is returned if it does not exist.
10 PRINT VALID('do_totals', 'ROUTINE')
PRINT VALID('test_nos', 'ROUTINE')
20 END
100 ROUTINE do_totals: PRIVATE mytotal, desc$
mytotal = 15
desc$ = 'Test Totals'
PRINT desc$; mytotal
END ROUTINE
RNH
1
0
|
- FILTER
Filters the text_str before
the validation. The following filters are allowed:
- LTRIM$ - Remove leading spaces.
- RTRIM$ - Remove trailing spaces.
- TRIM$ - Remove both leading and trailing spaces.
- UCASE$ - Convert to upper-case characters.
- LCASE$ - Convert to lower-case characters.
- REPLACE - If text_str contains a few
'old_t1' characters, all of them will be replaced by 'new_t1'.
old_t1=new_t1, old_t2=new_t2, ....
|
- REMOVE - Removes any characters from the
text_str.
- CHANGE - Changes specified characters. For
details see the CHANGE$ function.
10 IF VALID('abcd10', &
'FILTER REMOVE "10"; LETTERS' THEN PRINT 'true'
IF VALID("ab1cd1", "FILTER REPLACE '1'='e';LETTERS") &
THEN PRINT 'true'
IF VALID(" 1234 ","FILTER TRIM; NUMBER") &
THEN PRINT 'true'
30 END
RNH
true
true
true
|
- RESTORE - Restores data to pre-filtered state for
further validations. Can be used for multiple validation rules.
10 IF VALID("123", &
"FILTER REPLACE '1'='a';RESTORE;NUMBER") &
THEN PRINT "true"
20 END
RNH
true
|
WRAP$(str_expr, int_expr1, int_expr2)
Returns a word-wrapped text string, given left and right margins. Each
line of the string is separated with a CR/LF.
Where string_expr = text string to wrap, int_expr1 =
left margin, int_expr2 = right margin.
XLATE$(str_expr1, str_expr2)
The XLATE$ function translates one string to another by referencing a
table you supply. For example, the XLATE$ function can translate from
EBCDIC to ASCII. The first str_expr is the string to be
translated. The second str_expr is the translation table.
Appendix B
Reserved Words
Reserved words are words that cannot be used as identifiers. INTOUCH's
reserved words are:
-
- DATE
- DATE$
- ELSE
- EXLINE
- EXTYPE
- MAXNUM
- NOT
- PI
- PRINT
- REM
- RND
- TIME
- TIME$
The following words will be reserved in future versions:
-
- CON
- IDN
- NUL$
- TRANSFORM
- ZER
Appendix C
INTOUCH's Error and Exception Messages
Errors are returned either immediately after typing a syntactically
incorrect line, or when the RUN command is given and your program is
syntactically incorrect.
C.1 Compile Errors
-
- ACCESS mode not INPUT, OUTPUT, or OUTIN
- ADD without matching END ADD
- Already declared as other than array
- Array name expected
- Array not yet dimensioned
- Array or structure reference is missing "()"
- Bad line number
- CANCEL ADD without matching ADD
- CANCEL EXTRACT without matching EXTRACT
- Can't find relation in database
- Can't GO
- Can't store into an internal field
- Can't use this option with FIELD clause
- CASE expression is of different type than SELECT CASE
- CASE statement missing 'TO'
- CASE without matching SELECT CASE
- CASE OF not within SELECT block
- Compilation errors
- Compiler doesn't handle this yet
- Database engine discovered bad binary information buffer
- Datatype mismatch
- DO without matching LOOP
- Dots not allowed in variable names
- Dynamic variables may not be used as arrays
- ELSE without matching IF
- END ADD without matching ADD
- END EXTRACT without matching EXTRACT or REEXTRACT
- END IF without matching IF
- END HANDLER without matching HANDLER
- END SELECT not within SELECT block
- END WHEN without a previous USE
- EXIT ADD without matching ADD
- EXIT EXTRACT without matching EXTRACT
- EXPECTED KEY keyword
- EXTRACT without matching END EXTRACT
- Expected a line number or label
- Expected a relational operator
- Expected an expression
- Expected ELSE clause
- Expected end-of-line
- Expected EXCEPTION keyword
- Expected FIELD keyword
- Expected file name expression
- Expected IN or USE keywords
- Expected INPUT keyword
- Expected 'ON' or 'OFF'
- Expected quoted string
- Expected RECORD keyword
- Expected STEP keyword
- Expected STRUCTURE keyword
- Expected THEN clause
- Expected ','
- Expected ':' in substring expression
- Expected ',' or ':'
- Expected ',' or ';'
- Expected ',' or ')'
- Expected '('
- Expected ')'
- Expected '='
- Expression poorly formed
- Expression too complex
- EXTRACT without matching END EXTRACT
- INPUT missing variable list
- Invalid file name
- Invalid relation name
- Invalid routine name
- Invalid workspace name
- FOR EACH may not appear within and EXTRACT
- FOR index must be real or integer simple variable
- FOR without matching NEXT
- Function or array not declared
- GOTO or GOSUB expected
- HANDLER name not found
- HANDLER or FUNCTION name cannot be used as a label
- HANDLER without matching END HANDLER
- IF without matching END IF
- Illegal ADD STRUCTURE nesting
- Illegal character in source code
- Illegal delimiter
- Illegal EXTRACT nesting
- Illegal integer
- Illegal structure field name
- Illegal use of dynamic variable/structure in CASE
- Illegally nested error handlers
- Illegally nested PROGRAM statement
- INCLUDE, EXCLUDE, or SORT outside EXTRACT block
- Internal END-ON without preceding ON
- Invalid NEXT variable
- Leading white space not within a multiple statement line
- Line number or label not found
- LOOP without matching DO
- LSET, CSET, and RSET require string assignments
- Missing operand
- Missing '=' in FOR statement
- Missing ':' in substring expression
- Missing '('
- Missing ')'
- More than 32 dimensions not allowed
- Multiply defined HANDLER
- Multiply defined label
- Nested FOR loops with same index variable
- NEXT without matching FOR
- No END statement terminating PROGRAM block
- Not existing HANDLER name
- Only one OPTION BASE allowed per program
- Only one OPTION integer/real allowed per program
- OPEN statement missing NAME keyword
- PARTIAL only allowed for character fields
- PROGRAM statement not first in program
- Relation name expected
- REPEAT DO or ITERATE DO not inside DO loop
- REPEAT FOR, ITERATE FOR, or EXIT FOR not in FOR loop
- Reserved word
- RESUME, RETRY, CONTINUE, or EXIT HANDLER not within handler
- SELECT CASE without matching END SELECT
- SELECT has no matching END SELECT
- Statement following LOOP is not WHILE or UNTIL
- Statement is only legal in immediate mode
- Statement must be inside a program
- Structure name expected
- Syntax error
- Syntax error in specified expression
- This option needs a FIELD clause
- Too many relations declared
- Too many structures in the relation
- Tried to DECLARE an illegal or typed variable
- Unexpected number of dimensions
- Unknown special variable
- Unrecognized COMPILE option
- Unrecognized keyword
- Unrecognized OPEN keyword
- Unrecognized relational operator
- Unrecognized SET/ASK keyword
- Unrecognized statement
- Unterminated ELSEIF statement
- USE block has no END WHEN
- Use of '()' not valid in this context
- USE without preceding WHEN EXCEPTION IN...
- Using '()' with array name not valid in this context
- Variable already declared
- Variable currently exists with a different data type
- Variable names may not contain embedded dots
- Valid OPTION BASE parameters are 0 and 1
- Warning: Missing quote assumed
- WHEN EXCEPTION IN has no USE block
- WHEN EXCEPTION USE has no END WHEN
- WHEN may not be inside of a HANDLER or USE block
- WHILE/UNTIL or EXIT DO not inside DO loop
- Wrong number of arguments
- Wrong number of subscripts in array reference