M!INTOUCH® 4GL Y

INTOUCH® 4GL
A Guide to the INTOUCH Language

A
Previous page... 6Table of Contents


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

#

DIV0(num_expr1, num_expr2)



JThe 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)



DThe DTYPE function returns as an integer value, the data type of an Dexpression 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)



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

G  )        )    B    -    1    .    /    .    3  
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])



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





4

ELEMENT$(str_expr1, num_expr [, str_expr2])



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

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


BYou 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 


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

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

ENCODE$(num_expr, num_int)



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



EPS(num_expr)



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



EVAL(str_expr)



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

1        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$



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



EXLINE



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



EXP(num_expr)



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



EXTEXT$(int_expr)



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



EXTYPE



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



FALSE



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

9

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



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

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

IStr_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


JStr_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') 4            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])



FGiven a file name to find, returns the complete file specification of Hthe 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 Gonly one argument (i.e., the file specification, but no index number).    f     —     ?  
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)



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

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

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

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


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

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


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

#        PRINT USING str_expr: expr 


BThe FORMAT$ function supports the DATE format and date arguments. GGiven 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. 6If no date argument is provided, the default is MDCY. 

4        10  z1$ = FORMAT$('950401', '{DATE MDCY}?') =            z2$ = FORMAT$('950401', '{DATE MDCY}##/##/####') 6            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 


G  - , ! . !                                                                               
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


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

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


*The ? can be replaced with a mask. 

7        10  z1$ = FORMAT$('5552527800', '{ROTATE 3}?') D            z2$ = FORMAT$('5552527800', '{ROTATE 3}###~ ###~-####') 6            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. JGiven 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}?') 1            t2$ = FORMAT$('19:45:36', '{TIME}?')         20  PRINT t1$             PRINT t2$         30  END          RNH         10:22 AM         07:45:36 PM 


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

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


1        10  z1$ = FORMAT$('92126', '{ZIPCODE}?') 2            z2$ = FORMAT$('K8A3P9', '{ZIPCODE}?') 5            z3$ = FORMAT$('931327845', '{ZIPCODE}?') 0        20  PRINT '5 character zipcode : '; z1$ 0            PRINT '6 character zipcode : '; z2$ 0            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])]



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

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

I  * -                !    $  
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 
4

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



KThis function changes the plain text in str_expr1 into a hashed eight-byte Hstring value. It can be used to develop one-way hashed passwords. The Moptional 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 5              PRINT 'That was the correct password.'             ELSE        9              PRINT 'That was not the correct password.'             END IF         20  END               RNH         Password?  MONEY +        That was not the correct password. 


INT(num_expr)



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



INTEGER(num_expr)



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



IP(num_expr)



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

#

ITEM(str_expr1, str_expr2)



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

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

LBOUND(array_name [,int_expr])



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



LCASE$(str_expr)



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

$

LEFT[$](str_expr, int_expr)



@LEFT$ returns the leftmost nn characters from a string. PInt_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)



9LOG 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])



FLPAD$ 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)



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

$

MATCH(str_expr1, str_expr2)



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

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

9        10  INPUT 'Which procedure (ADD,DEL,QUIT)': pro$ 0        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)



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



MAXLEN(str_var)



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



MAXNUM



HReturns the largest number available in this implementation of INTOUCH. 



MAXSIZE(array_name)



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

1

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



JMID$ or MID returns a substring from the middle characters of a specified Lstring, 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)



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

"

MOD(num_expr1, num_expr2)



6Gives the remainder of one number divided by another. 



ORD(str_expr)



LGiven 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)



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



PARSE$(str_expr)



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

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

PATTERN(str_expr1, str_expr2)



IMatches any characters in text (str_expr1) with the pattern (str_expr2). CStr_expr1 is the text to search and str_expr2 is the pattern being Gsearched for. Returns the location of the first character in the text Mthat contains the pattern. If the characters cannot be found, returns zero. 

#PATTERN Options and Examples

DPattern options can be mixed and matched with unlimited complexity.

?





#Matches any character in the text. 

5        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. 

G        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 


{}





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

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


{^}





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

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


~





KThe '~' (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' H            IF  PATTERN(text$, 'is {<619|714|916>}') > 0  THEN 4              PRINT 'Your area code is on the list'             END IF         20  END                                RNH &        Your area code is on the list 



$

PI



4


Next page... | 6Table of Contents