INTOUCH® 4GL
A Guide to the INTOUCH Language


Previous page... Table of Contents

Given an angle in radians, returns the number of degrees.

DIV0(num_expr1, num_expr2)

The DIV0 function divides num_expr1 by num_expr2. If num_expr2 (divisor) is 0, 0 is returned.

        10  PRINT DIV0(0.8, 0.000004) 
            PRINT DIV0(0.8, 0.0) 
            PRINT DIV0(6, 3) 
            PRINT DIV0(6, 0) 
        20  END 
 
        RNH 
         200000 
         0 
         2 
         0 

DTYPE(expr)

The DTYPE function returns as an integer value, the data type of an expression or dynamic variable: 1 = string, 2 = integer, 3 = real.

        10  DECLARE DYNAMIC x 
        20  x = 45.6 
        30  PRINT DTYPE(x) 
        40  END 
 
        RNH 
        3 

EDIT$(str_expr,int_expr)

EDIT$ performs one or more editing operations, depending on the value of the integer expression, on the supplied string argument. The integer expression is one of the integers below, or a sum of integers below for the desired edit functions:

Table A-4 EDIT$ Function - Operation Values
Value Edit Operation
1 Trim parity bits.
2 Discard all spaces and tabs.
4 Discard characters: CR, LF, FF, ESC, RUBOUT and NULL.
8 Discard leading spaces and tabs.
16 Reduce spaces and tabs to One space.
32 Convert lower case to upper case.
64 Convert "[" to "(" and "]" to ")".
128 Discard trailing spaces and tabs.
256 Do not alter characters inside quotes.

ELEMENTS(str_expr1 [, str_expr2])

Returns the number of elements in a string expression which contains a list of elements. Str_expr1 is the string containing the list of elements. Str_expr2 is the separator. A comma is the default separator.

ELEMENT$(str_expr1, num_expr [, str_expr2])

ELEMENT$ returns the element from str_expr1 which is specified by the num_expr. Str_expr1 contains a set of elements with separators between them. The default separator is a comma:

        10  LET a$ = ELEMENT$('ADD,DEL,EXIT',2) 
        20  PRINT a$ 
        30  END 
 
        RNH 
        DEL 

You can specify a separator other than the comma with str_expr2.

        10  LET sentence$ = 'This is a test.' 
        20  LET a$ = ELEMENT$(sentence$,2,' ') 
        30  PRINT a$ 
 
        RNH 
        is 

More than one separator in a row returns a null for the corresponding element.

        10  LET sentence$ = 'This,, is, a, test'  
            PRINT ELEMENT$(sentence$, 2) 
        20  END 
 
        RNH 
 

ENCODE$(num_expr, num_int)

Returns a string containing a number converted to the base specified. Num_expr is the value to convert. Num_int is the base to convert. For instance, '2' indicates binary, etc.

EPS(num_expr)

INTOUCH carries 15 digits of precision. The EPS(number) returns the smallest value, which when added to "number" yields the next number.

EVAL(str_expr)

This function evaluates the expression described in str_expr, and returns the result. If the variable being assigned the result is dynamic, the function puts the result in whatever data type the expression result was in. If the variable is NOT dynamic, and the result is the wrong data type, a "Data type mismatch" error is returned.

        10  LINE INPUT 'Enter an expression': a$ 
            PRINT 'The result is '; EVAL(a$) 
        20  END 
 
        RNH 
        Enter an expression?  5 + 4 
        The result is  9 

EXLABEL$

EXLABEL$ returns the label and line number executing when the last exception occurred, e.g., DO_INPUT.4

EXLINE

EXLINE returns the line number executing when the last exception occurred.

EXP(num_expr)

EXP function returns the value of the mathematical constant, "e", raised to a specified power.

EXTEXT$(int_expr)

EXTEXT$ returns explanatory text associated with a specified exception number.

EXTYPE

EXTYPE returns the number of the last exception that occurred. It is returned as an integer.

FALSE

Returns the constant 0. It is returned as an integer.

FILESPEC$(str_expr1 [, str_expr2 [, str_expr3]])

FILESPEC$ parses a file specification and returns either a full file specification or specific file specification fields.

Str_expr1 is the file specification to be parsed. If no file specification is given, the device and directory you are currently running from are returned.

Str_expr2 is a list of field names, separated by commas, which are to be returned. The field names are:
DEVICE device name
DIRECTORY directory name
NAME file name
TYPE type or extension name
VERSION file version number
LOCATION device and directory names
ALL or "" full file specification

Str_expr3 is the default file specification. This parameter is optional.

FILESPEC$ can be used in various formats.

        10  PRINT FILESPEC$('x.y', 'ALL') 
            PRINT FILESPEC$('', 'ALL') 
        20  END 
 
        RNH 
        USER:[FRED]X.Y; 
        USER:[FRED].; 

        10  x$ = 'TTI_RUN:CLIENT' 
            PRINT FILESPEC$(x$, 'ALL', '.dat') 
        20  END 
 
        RNH 
        STORAGE:[INTOUCH]CLIENT.DAT; 

        10  PRINT FILESPEC$('tti_run:client', 'ALL', '.dat') 
            PRINT FILESPEC$('tti_run:client', 'LOCATION') 
            PRINT FILESPEC$('tti_run:client', 'LOCATION, NAME') 
            PRINT FILESPEC$('tti_run:client.dat;1') 
        20  END 
 
        RNH 
        STORAGE:[INTOUCH]CLIENT.DAT;  
        STORAGE:[INTOUCH] 
        STORAGE:[INTOUCH]CLIENT 
        STORAGE:[INTOUCH]CLIENT.DAT;1 

FINDFILE$(str_expr [, int_expr])

Given a file name to find, returns the complete file specification of the first file found that matches the name given. If no file is found, the function returns a null string.

FINDFILE$ calls can be nested if the inner call has only one argument (i.e., the file specification, but no index number).
str_expr The name of the file to search for. This can be just part of the full file specification.
int_expr Which file specification to return if multiple files are found. This parameter is optional. The default is to return the first file found.
Result The complete file specification of the file found.

        10  PRINT FINDFILE$('tti_run:*.int') 
 
        RNH 
        DUA0:[INTOUCH]ALIENS.INT;5 

        10  DO 
              LINE INPUT 'File.Spec': spec$ 
              IF  _EXIT  THEN  EXIT DO         
              FOR i = 1 TO 9999 
                file$ = FINDFILE$(spec$, i) 
                IF  file$ = ''  THEN  EXIT FOR 
                PRINT file$ 
              NEXT i 
            LOOP 
        20  END 
 
        RNH 
        File specification? TTI_RUN:CLIENT.* 
        DUA0:[INTOUCH]CLIENT.DAT;7 
        DUA0:[INTOUCH]CLIENT.DEF;3 
        DUA0:[INTOUCH]CLIENT.INT;1 
        DUA0:[INTOUCH]CLIENT.SAV;1 
        DUA0:[INTOUCH]CLIENT.STR;16 

FORMAT$(expr, str_expr)

Given an expression and a format, returns the result of the expression in the format indicated.

The '@' format character causes the character not to be translated by the formatter. The '<' and '>'are treated like an '@' character. You can justify a character string, but avoid zero suppression and zero insertion.

The FORMAT$ function takes an expression of any data type for the data to format (the first argument), including string expressions.

        10  z$ = FORMAT$('1234567', '###~-####') 
            PRINT 'Phone number: '; z$ 
        20  END 
 
        RNH 
        Phone number: 123-4567 

The FORMAT$ function returns all asterisks "*" in the case of overflow.

        10  z$ = FORMAT$(12.23,'#.##') 
            PRINT z$ 
        20  END 
 
        RNH 
        **** 

FORMAT$() returns the same string data as given by the following:

        PRINT USING str_expr: expr 

The FORMAT$ function supports the DATE format and date arguments. Given a date in YYMMDD or CCYYMMDD format, FORMAT$ returns the date in the date format requested.

        FORMAT$(z$, '{DATE [argument]}?') 

The ? can be replaced with a mask. If no date argument is provided, the default is MDCY.

        10  z1$ = FORMAT$('950401', '{DATE MDCY}?') 
            z2$ = FORMAT$('950401', '{DATE MDCY}##/##/####') 
            z3$ = FORMAT$('19950401', '{DATE MDCY}?') 
            z4$ = FORMAT$('19950401', '{DATE MDCY}##/##/####') 
        20  PRINT z1$, z2$ 
            PRINT z3$, z4$ 
        30  END 
 
        RNH 
        04011995            04/01/1995 
        04011995            04/01/1995 

Table A-5 FORMAT$ Function - Date Arguments
DATE
Argument
YYMMDD
Input
Result CCYYMMDD
Input
Result
none 950207 02071995 19950207 02071995
YMD 950207 950207 19950207 950207
CYMD 950207 19950207 19950207 19950207
MDY 950207 022195 19950207 022195
MDCY 950207 02071995 19950207 02071995
DMY 950207 070295 19950207 070295
DMCY 950207 07021995 19950207 07021995
DMONY 950207 07-Feb-95 19950207 07-Feb-95
DMONCY 950207 07-Feb-1995 19950207 07-Feb-1995
MONTHDY 950207 February 7, 95 19950207 February 7, 95
MONTHDCY 950207 February 7, 1995 19950207 February 7, 1995

The FORMAT$ function supports character rotation. The ROTATE option rotates the last nn characters of a string to the first position in the string.

        FORMAT$(z$, '{ROTATE n}?') 

The ? can be replaced with a mask.

        10  z1$ = FORMAT$('5552527800', '{ROTATE 3}?') 
            z2$ = FORMAT$('5552527800', '{ROTATE 3}###~ ###~-####') 
            z3$ = FORMAT$('TuneTommy', '{ROTATE 5}?') 
            z4$ = FORMAT$('TuneTommy', '{ROTATE 5}#####~ ####') 
        20  PRINT z1$, z2$ 
            PRINT z3$, z4$ 
        30  END 
 
        RNH 
        8005552527            800 555-2527 
        TommyTune             Tommy Tune 

The FORMAT$ function supports the TIME format. Given a military standard time in HHMM, HH:MM, HHMMSS or HH:MM:SS format, FORMAT$ returns the time as HH:MM AM/PM or HH:MM:SS AM/PM.

        FORMAT$(z$, '{TIME}?') 

        10  t1$ = FORMAT$('1022', '{TIME}?') 
            t2$ = FORMAT$('19:45:36', '{TIME}?') 
        20  PRINT t1$ 
            PRINT t2$ 
        30  END 
 
        RNH 
        10:22 AM 
        07:45:36 PM 

The FORMAT$ function supports the ZIPCODE format. Given a 5, 6 or 9 digit zipcode, FORMAT$ returns a formatted zipcode.

        FORMAT$(z$, '{ZIPCODE}?') 

        10  z1$ = FORMAT$('92126', '{ZIPCODE}?') 
            z2$ = FORMAT$('K8A3P9', '{ZIPCODE}?') 
            z3$ = FORMAT$('931327845', '{ZIPCODE}?') 
        20  PRINT '5 character zipcode : '; z1$ 
            PRINT '6 character zipcode : '; z2$ 
            PRINT '9 character zipcode : '; z3$ 
        30  END 
 
        RNH 
        5 character zipcode : 92126 
        6 character zipcode : K8A 3P9 
        9 character zipcode : 93132-7845 

FP(num_expr)

Given a number, returns the fractional part of the number.

FULLTIME$[(float_expr, [int_var])]

Given the number of seconds since the INTOUCH base date, this function returns the date and time in one of the formats given below.

Where float_expr is the number of seconds since the INTOUCH base date. The default is the current date and time. January 1, 1600 00:00:00 is considered the second 0.

Table A-6 FULLTIME$ Function - Integer Values
Value (int_var) Output Data Format
0 CCYYMDD HHMMSS
1 MMDDCCYY HHMMSS
2 DDMMCCYY HHMMSS
3 DD-Mon-CCYY HH:MM:SS
4 Month DD, CCYY HH:MM:SS

        10  PRINT FULLTIME$ 
        20  sec = SECONDS('19910621 115042') 
        30  PRINT FULLTIME$(sec, 0) 
        40  PRINT FULLTIME$(sec, 1) 
        50  PRINT FULLTIME$(sec, 2) 
        60  PRINT FULLTIME$(sec, 3) 
        70  PRINT FULLTIME$(sec, 4) 
        80  END 
 
        RNH 
        19910621 123756 
        19910621 115042 
        06211991 115042 
        21061991 115042 
        21-Jun-1991 11:50:42 
        June 21, 1991 11:50:42 

HASH$(str_expr1 [, str_expr2 [, int_expr]])

This function changes the plain text in str_expr1 into a hashed eight-byte string value. It can be used to develop one-way hashed passwords. The optional text in str_expr2 and optional int_expr can be used to further make the hashed value unique.

        10  password$ = HASH$('TRUTH') 
            INPUT 'Password': pwd$ 
            IF  HASH$(pwd$) = password$  THEN 
              PRINT 'That was the correct password.' 
            ELSE        
              PRINT 'That was not the correct password.' 
            END IF 
        20  END      
 
        RNH 
        Password?  MONEY 
        That was not the correct password. 

INT(num_expr)

INT returns the whole portion of a real number as a real number.

INTEGER(num_expr)

INTEGER changes any numeric expression into an integer value and assigns the integer value to the variable specified.

IP(num_expr)

IP truncates the value of a real number at the decimal point and returns the integer portion.

ITEM(str_expr1, str_expr2)

The ITEM function returns the number of the first item that matches the whole or partial item name given. A negative number is returned if more than one item matches.

        10  z = ITEM('ADD,EXIT,EXTRACT,MODIFY', 'MOD')   
            PRINT z 
        20  END 
 
        RNH 
        4 
 
 
 
        10  z = ITEM('ADD,EXIT,EXTRACT,MODIFY', 'EX') 
            PRINT z 
        20  END 
 
        RNH 
        -2 

LBOUND(array_name [,int_expr])

Given an array and a dimension number, returns the low bound for that dimension. The default dimension is 1.

LCASE$(str_expr)

LCASE returns a string expression with all letters in lower case.

LEFT[$](str_expr, int_expr)

LEFT$ returns the leftmost nn characters from a string. Int_expr is the last character position to be included in the resulting string.

LEN(str_expr)

LEN returns the length of a string. It returns an integer.

LOG(num_expr)

LOG returns the natural logarithm of a specified number.

LOG2(num_expr)

LOG2 returns a number's base 2 logarithm.

LOG10(num_expr)

LOG10 returns a number's common logarithm.

LPAD$(text_str, size [, pad_str])

LPAD$ pads a string on the left with pad characters. The default pad character is a space.

        10  PRINT LPAD$('123', 6, '0') 
        20  END 
        RNH 
 
        000123 

LTRIM$(str_expr)

Removes all leading spaces (those on the left side of the string).

MATCH(str_expr1, str_expr2)

Str_expr1 contains a list of elements separated by commas. Str_expr2 contains a string. MATCH compares str_expr2 with each of the elements in str_expr1 and gives the number of the element that matches.

Quoted data is treated as one element; the quotes are not removed.

        10  INPUT 'Which procedure (ADD,DEL,QUIT)': pro$ 
        20  LET x = MATCH('ADD,DEL,QUIT', pro$) 
        30  ON x GOSUB 50, 70, 90 
        40  GOTO 10 
        50  PRINT 'Adding...' 
        60  RETURN 
        70  PRINT 'Deleting...' 
        80  RETURN 
        90  END 

MAX(num_expr, num_expr)

MAX(x,y) returns the larger of the two values x and y.

MAXLEN(str_var)

Returns the maximum number of characters that a string variable can contain. Since all string variables are variable length, with a maximum of 65535, this function always returns 65535.

MAXNUM

Returns the largest number available in this implementation of INTOUCH.

MAXSIZE(array_name)

Returns the total number of elements that can be contained in an array.

MID[$](str_expr, int_expr1 [,int_expr2])

MID$ or MID returns a substring from the middle characters of a specified string, leaving the string unchanged. Int_expr1 is the starting position of the substring, and int_expr2 is the length of the substring. MID$(str_expr,int_expr1) will return the rest of the string.

        10  a$ = 'beginmiddleend' 
            middle$ = MID$(a$, 6, 6) 
            end$ = MID$(a$, 6) 
            PRINT middle$, end$ 
        20  END 
 
        RNH 
        middle     middleend 

MIN(num_expr1, num_expr2)

MIN(x,y) returns the lesser of the values x and y.

MOD(num_expr1, num_expr2)

Gives the remainder of one number divided by another.

ORD(str_expr)

Given the ASCII name of a character, returns the location of that character in the ASCII character table. It returns an integer number.

ORDNAME$(int_expr)

Given the location of a character in the ASCII character table, returns the name of that character.

PARSE$(str_expr)

PARSE$ splits a string into tokens and returns each token separated by a space. Letters are upper-cased, except within quotes. Tail comments are ignored. Embedded "$" characters are allowed. The maximum line length is 1024 characters.

        a$ = 'company$ = abc$ +"and sons" !rnn' 
        PRINT PARSE$(a$) 
 
        RNH 
        COMPANY$ = ABC$ + "and sons" 

PATTERN(str_expr1, str_expr2)

Matches any characters in text (str_expr1) with the pattern (str_expr2). Str_expr1 is the text to search and str_expr2 is the pattern being searched for. Returns the location of the first character in the text that contains the pattern. If the characters cannot be found, returns zero.

PATTERN Options and Examples

Pattern options can be mixed and matched with unlimited complexity.

?

Matches any character in the text.

        10  IF  PATTERN('The quick brown fox', & 
               'f?x') > 0  THEN 
               PRINT 'Found' 
            END IF 
        20  END 
                                 
        RNH 
        Found 

*

Matches zero or more of a character that precedes the asterisk.

        10  IF  PATTERN('aaa   03/26/92', 'a* *03/26/92') > 0  THEN 
              PRINT 'The date is found' 
            END IF 
        20  END 
                
        RNH 
        The date is found 

{}

Used to define a group of characters. The characters in the enclosed group can be ranges such as {a-z} or individual characters such as {AQX}.

        10  text$ = 'A1N5V7N0' 
            rule_str$ = '{A-Z}{0-9}{A-Z}{0-9}{A-Z}{0-9}{A-Z}{0-9}' 
            IF  PATTERN(text$, rule_str$) > 0  THEN  
              PRINT 'Driver's licence is correct' 
            END IF 
        20  END  
 
        RNH 
        Driver's licence is correct 

{^}

Looks for characters that are NOT {^A-Z}. The result of line 30 below shows the difference between using '?' and {^}.

        10  PRINT PATTERN('Mary J. Smith','{^Mar}') 
        20  PRINT PATTERN('Mary J. Smith','J. {^S}') 
        30  PRINT PATTERN('Mary J. Smith','J. S?') 
        40  END 
 
        RNH 
        4 
        0  
        6 

~

The '~' (quote) character looks for a pattern of text that IS an * (stands for itself).

        10  text$ = '$4,670.00' 
            IF  PATTERN(text$, '$~4, 670.00') > 0  THEN 
              PRINT 'Your text is correct' 
            END IF 
        20  END 
                     
        RNH 
        Your text is correct 

{<cc|ccc|c>}

Looks for text in str_expr1 that matches the enclosed groups.

        10  text$ = 'The area code is 619' 
            IF  PATTERN(text$, 'is {<619|714|916>}') > 0  THEN 
              PRINT 'Your area code is on the list' 
            END IF 
        20  END 
                       
        RNH 
        Your area code is on the list 

PI


Next page... | Table of Contents