INTOUCH® 4GL
A Guide to the INTOUCH Language


Previous Contents Index

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.

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 [, TRUE])

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.

The TRUE parameter is used if the match is to be case-exact. The default is case-insensitive.


        10  a$ = 'BLUE' 
            b$ = 'Blue' 
            c$ = a$ 
        20  DO 
              x = MATCH('Red,White,Blue', c$, TRUE) 
              PRINT c$; 
              IF  x > 0  THEN 
                PRINT ' is a match.' 
              ELSE 
                PRINT ' is not a match.' 
                c$ = b$ 
                REPEAT DO 
              END IF 
            END DO 
        30  END 
 
        RNH 
        BLUE is not a match. 
        Blue is a match. 

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. Names/words can start with digits. The maximum line length is 1024 characters.


        10  a$ = 'company$ = 123abc$ +"and sons" !rnn' 
        20  PRINT PARSE$(a$) 
        30  END 
 
        RNH 
        COMPANY$ = 123ABC$ + "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 one or more of a character that precedes the single asterisk (*).
Matches zero or more of a character that precedes the double 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 

{(word_text)}

Looks for a match on a word. The word text can contain an embedded "$".


        10  a$ = 'There are dogs and cats in the house.' 
            b$ = 'Everyone would like to make big$bucks!' 
        20  IF  PATTERN(a$, '{(cats)}') > 0  THEN 
              PRINT 'The word was found.' 
            END IF 
        30  IF  PATTERN(b$, '{(big$bucks)}') > 0  THEN 
              PRINT 'The $ word was found.' 
            END IF 
        40  END 
 
        RNH 
        The word was found. 
        The $ word was found. 

{|directive|}

Directives can be used with the PATTERN function. Multiple directives can be used. Directives are processed from left to right. The valid directives are:
nocase can be upper, lower or mixed case
case unless NOCASE specified, default is CASE (i.e. case-exact)
bol beginning of a line
eol end of a line


        10  a$ = 'ElEpHaNtS have trunks' 
            b$ = 'water goes splash' 
        20  IF  PATTERN(a$, '{|bol|}{|nocase|}elephants') > 0  THEN 
              PRINT 'elephants was found.' 
            END IF 
        30  IF  PATTERN(b$, 'splash{|eol|}') > 0  THEN 
              PRINT 'splash was found.' 
            END IF 
        40  END 
 
        RNH 
        elephants was found. 
        splash was found. 

PI

Returns the value 3.141592653589793.

PIECES(str_expr1 [,str_expr2])

and

PIECE$(str_expr1,num_expr[,str_expr2])

PIECE$ returns an element from str_expr1 specified by num_expr. str_expr1 contains a list of elements. The separator can be indicated by str_expr2. The default separator is a carriage-return line-feed pair.

These two functions are similar to the ELEMENTS() and ELEMENT$() functions except that:


        10 CLEAR 
            MESSAGE 'Press GOLD/F when done' 
            LINE INPUT AREA 5, 10, 8, 60: text$ 
            PRINT AT 10, 1: 'Rewrapped text' 
            wt$ = WRAP$(text$, 1, 30) 
            PRINT 'Number of lines: '; PIECES(wt$) 
            PRINT wt$ 
            PRINT 
            PRINT 'First line was: '; PIECE$(wt$, 1) 
        20  END 

POS(str_expr1, str_expr2[, int_expr])

POS searches for a substring within a string. It returns the substring's starting character position. str-exp1 is the string to be searched, str-exp2 is the substring to locate, and int-exp is the OPTIONAL character position at which to begin the search. (The default is the start of the string.) If the substring is not found, zero is returned.

PRETTY$(str_expr)

PRETTY$ converts text so that the text displays on any terminal. Named control characters show up with their names. Other control characters show up as {X} where "X" is the letter to press or as {XX} where "XX" is the hexadecimal value of the character.


        10  a$ = 'Hello' + CHR$(5) + CHR$(161) + CHR$(7) 
        20  PRINT PRETTY$(a$) 
        30  END 
 
        RNH 
        Hello{^E}{A1}{bel} 

QUOTE$(str_expr)

The QUOTE$ function encloses a string expression in double quotes. If the string expression is already enclosed in double quotes, QUOTE$ leaves it alone. If the string expression is already wrapped in single quotes, QUOTE$ replaces them with double quotes. Elements double quoted within the string expression are given another pair of double quotes (see following example). Elements single quoted within the string expression are ignored.


        10  DO 
              CLEAR 
              PRINT AT 1,1: 
              MESSAGE 'Enter a line of text to be quoted' 
              PRINT 'Text:' 
              INPUT '', LENGTH 30: line$ 
              IF  _BACK  OR  _EXIT  THEN  EXIT DO 
              IF  line$ = ''  THEN REPEAT DO 
        20    PRINT 
              PRINT 'Quoted text using the QUOTE$ function...' 
              PRINT quote$(line$) 
              DELAY 
            LOOP 
        30  END 
 
        RNH 
        Text: 
        ? The little boy cried "wolf!" 
        
        Quoted text using the QUOTE$ function... 
        "The little boy cried ""wolf!""" 

RAD(num_expr)

Given a measurement in degrees, returns the number of radians.

REAL(num_expr)

REAL changes any numeric expression into a real or floating-point value and assigns the real value to the variable specified.


        10  INPUT 'Your age': age% 
            LET decimal_age = REAL(age%) 
            PRINT 'Your number is'; decimal_age 
        20  END 

REMAINDER(num_expr1, num_expr2)

REMAINDER(x,y) returns the remainder when X is divided by Y. It differs subtly from MOD. MOD(-4,3) = 2 while REMAINDER(-4,3) = -1.

REPEAT$(str_expr, int_expr)

Creates a string composed of the specified string repeated the specified number of times.

REPLACE$(str_expr1, str_expr2 [,str_sep1][,str_sep2])

Searches for a list of patterns in the str_expr1 and replaces them with the output string from str_expr2. Returns the replaced string expression.

str_expr1 is a list of patterns to search for.

str_expr2 is the replacement list.

str_sep1 is the optional separator for replacement items. The default is a comma.

str_sep2 is the optional separator between the input and output text in items. Default is =.


        10  text$ = '01-Mar-1981' 
            PRINT REPLACE$(text$, 'r=y 8=9' , ' ') 
        20  END 
                       
        RNH 
        01-May-1991 

RIGHT[$](str_expr, int_expr)

RIGHT$ returns the rightmost characters from a string. int_exp is the character position of the last character to be included in the substring COUNTING FROM THE RIGHT.


        10  ans$ = RIGHT$('Daniel', 2) 
            PRINT 'rightmost char.= ', ans$ 
        20  END 
 
        RNH 
        rightmost char.= el 

RND

or

RND(num_expr)

RND returns a random number greater than or equal to zero and less than one. If a numeric expression (num_expr) is given, RND returns a whole number between one and the numeric expression.

ROUND(num_expr [, int_expr])

ROUND rounds a num_expr to the specified number of decimal places (int_expr). The default int_expr is 0.

RPAD$(text_str, size[,pad_str])

RPAD$ pads a string on the right with pad characters. The default pad character is a space.


        10  PRINT RPAD$('123', 6, '0') 
        20  END 
 
        RNH 
        123000 

RTRIM$(str_expr)

Returns a string without any trailing spaces (those on the right side).

SCAN(str_expr1, str_expr2 [, int_expr])

Scans str_expr1 for the characters in str_expr2 and returns the position at which str_expr2 begins. int_expr specifies a character position at which the search is to begin.

The characters in str_expr2 need not appear contiguously in str_expr1.


        10  LET a$ = 'Cameron Whitehorn' 
            LET b$ = 'amr Wtor' 
            LET position = SCAN(a$, b$) 
            PRINT position 
        20  END 
 
        RNH 
        2 

SEC(num_expr)

Returns a secant of a given angle (1/COS(num_expr)). num_expr is a passed angle.

SECONDS(str_expr)

Given a full-time string in CCYYMMDD HHMMSS, YYMMDD HHMMSS, HHMMSS or HHMM format, returns the number of seconds since the INTOUCH base date (January 1, 1600 00:00:00).

The number of seconds is returned as a floating point number.


        10  z  = SECONDS('19931201 103050') 
            z1 = SECONDS('931201 103050') 
            z2 = SECONDS('103050') 
            z3 = SECONDS('1030') 
        20  PRINT 'Seconds CYMDHMS ='; z 
            PRINT 'Seconds  YMDHMS ='; z1 
            PRINT 'Seconds     HMS ='; z2 
            PRINT 'Seconds     HM  ='; z3 
        30  END 
 
        RNH 
        Seconds CYMDHMS = 12430837850 
        Seconds  YMDHMS = 12430837850 
        Seconds     HMS = 37850 
        Seconds     HM  = 37800 

SEG$(str_expr, int_expr1, int_expr2)

Extracts the substring given a first and last character position.

SGN(num_expr)

Returns the sign of a number. It returns a +1 if the expression is positive, a -1 if the expression is negative, and 0 if the expression is zero.

SIN(num_expr)

SIN returns the sine of an angle specified in radians.

SINH(num_expr)

SINH(X) returns the hyperbolic sine X.

SIZE(array_name [,int_expr])

Returns the number of elements in one dimension of an array.
array-name Array to examine
int-expr Dimension to get the size of. The default dimension is 1.


Previous Next Contents Index