• Keine Ergebnisse gefunden

(~ INDEX Function

Im Dokument BASIC Language Reference Guide (Seite 195-200)

(~ INDEX Function

Syntax

Description

6929-3

The INDEX function searches a string for the occurrence of a substring and returns the starting column position of that substring.

INDEX(string,substring,occurrence) string string to be examined substring substring to search for

occurrence occurrence of substring within string

The function returns a numeric value which is the starting column position of the substring within the string. If the substring is not found, a value of 0 is returned.

The INDEX function parameters may be any valid expressions.

A INDEX ("ABCAB", "A", 2) Second occurrence of "A" is at column position 4 of "ABCAB", so value of 4 is assigned to variable A.

x = "1234ABC"

Y = "ABC"

IF INDEX(X,Y,1)=5 THEN GOTO 3

END

"ABC" starts at column position 5 of

"1234ABC", so the IF statement transfers control to statement 3.

Q INDEX ("PROGRAM", "S",5)

Ultimate BASIC

"s" does not occur in the string

"PROGRAM", so value of 0 is assigned to variable Q.

3-117

Confidential and Proprietary to The Ultimate Corp.

Statements and Functions

INMATO Function

Syntax

Description

3~118

The INMATO function is used to return infonnation about elements in dimensioned arrays and modulos of files that were opened.

INMATO

INMATO can be used to return values generated by the following statements:

DIM

MATPARSE MATREAD{U}

OPEN

INMATO returns the actual number of elements in a dimensioned array after a MATREAD{U} or MATPARSE in the following cases:

• when the array is initially dimensioned as zero

• when the array is dimensioned with a variable

• when the array is dimensioned with a literal that is greater than the actual number of attributes read or parsed into it

INMATO returns zero as the number of elements in a dimensioned array after a MATREAD{U} or MATPARSE statement in the following case:

• when the array is dimensioned with a non-zero literal and the number of elements being read or parsed is greater than the dimensioned size of the array

INMATO also returns zero after a DIM statement is executed.

INMATO returns the modulo of the file after an OPEN statement.

Caution! The value of INMAT() is volatile;

if

the value is needed, it should be retrieved immediately after the statement that generates it has completed.

Ultimate BASIC 6929-3

Confidential and Proprietary to The Ultimate Corp.

c('. '"

\~

- - - -

---C-'

- / -\

6929-3

-INMA

TO

Function

DIM A(O)

MATREAD A FROM TESTFILE, 'ITEM.I' ELSE STOP

SZ = INMAT () The number of elements in the array A is returned in SZ.

Ultimate BASIC 3-119

Confidential and Proprietary to The Ultimate Corp.

Statements and Functions

INPUT Statement

Syntax

3-120

The INPUT statement is used to request data. The cursor position and data format can also be specified.

INPUT {@(x,y){:}} var {,len}{:}{format}L}{THEN/ELSE stmts}

INPUT var,O

@(x,y) specified cursor position; column x, row y

used immediately after@(x,y), displays existing value as the default before updating; if no existing value, null is assigned var variable to which the response is assigned

len maximum length of input; default length is 140 characters used after var or len, does not execute carriage return and line feed at end of input

format format string for input validation and output formatting; may contain any Ultimate format string Gharacters; alternatively, it may contain any valid Recall date conversion code. (Input verification is described in this topic. For details on using format strings for output formatting, refer to the chapter

"Working with Data" in this manual; for information on Recall date conversion codes, refer to the Ultimate Recall and Update User Guide.)

if user attempts to enter more than the maximum number of characters, bell is sounded each time a character is entered until RETURN or LINEFEED is pressed

THEN statements to execute after RETURN or LINEFEED is pressed when at least one character has been input by the user ELSE statements to execute when only RETURN or LINEFEED is

pressed by the user

o o

(zero) accepts single character and no editing is performed;

this allows non-printable characters such as <ESC> to be input;

Ultimate BASIC 6929-3

Confidential and Proprietary to The Ultimate Corp.

' ..

~.""·

('

Description

(

6929-3

INPUT Statement

the character is not echoed. This form must be specified with no other parameters. If other parameters are used, 0 is assumed to specify length and not single character input. A variable with value zero is also assumed to specify length and not single character input. (A length of zero does not provide meaningful input and is not recommended.)

N ole: The unprintable characters represented by <CIRL-Q>

and <CTRL-S> cannot be accepted ijx-ONIX-OFF protocol is enabled. These characters are used to set X-ON and X-OFF for the terminal.

All options must be in the order shown above.

An INPUT statement causes a prompt character to be printed at the user's terminal. The prompt character can be changed by the PROMPT

statement. (For more information about prompt characters, please refer to the PROMPT statement listed alphabetically in this chapter.)

The @(x,y) option allows the input to be placed at a specified cursor position; x and y may be any BASIC expressions. The prompt character is displayed one character prior to the x coordinate. It is recommended that x not be zero.

If@(x,y) is followed by a colon (:), the existing value of var, if any, is displayed, formatted according to format, if present. If there is no existing value, null is assumed. If @(x,y) is followed by a colon (:), and if format is specified as numerics (%), the field is zero-filled before displaying the value of var; if format is specified as blanks (#), the field is dot-filled before displaying the value of var.

If @(x,y) is omitted, the prompt character is displayed at the current cursor position, which may vary, depending on the results of any previous INPUT statement. For accurate cursor positioning, it is recommended that the @(x,y) function be used.

Maximum input is 140 characters unless len specifies a different value.

If the user enters the specified number of characters, an automatic RETURN is executed unless the underscore ( _ ) option is present. If the optional _ is used, the operator must physically press RETURN or LINEFEED to indicate end of input. If the optional _ is used and the

Ultimate BASIC 3-121

Confidential and Proprietary to The Ultimate Corp.

Statements and Functions

3-122

operator attempts to enter more than the specified number of characters before pressing RETURN, the bell is sounded and the extra characters are not accepted.

If len is an expression, the expression can use operators with

precedence levels 1-4 only, that is, dynamic array extraction, substring, exponentiation, multiplication, division, addition, and subtraction.

If the colon (:) is used after the var or len, the RETURN is inhibited on the screen; the cursor remains positioned after the input data. However, if an error message is printed, either because of PRINTERR or because of input verification, the cursor is moved to the line following the line on which the error message is displayed.

When using a format mask, data is converted on output and input.

Thus, if a date is to be input, the default, if any, should be stored in internal format; it is displayed in external format. Input values are converted from external format and stored in var in internal format; they are redisplayed in the external form specified by format.

The THEN and ELSE clauses are both optional; one, both, or none may be used. These clauses may be on a single line or multiple lines. If multiple lines are used, the clause must be terminated by an END

statement as in the multi-line IF statement.

If either THEN or ELSE is used, a null input (only RETURN) causes var to retain its old value. If no THEN or ELSE is present, null input stores a null string ("") in var.

The following statements and functions may have an effect on INPUT, or may be affected by INPUT:

INPUTCLEAR INPUTCONTROL PRINTERR PROMPT SYSTEM(11) SYSTEM(12)

For more information on these features, refer to the description of each listed alphabetically in this chapter.

Ultimate BASIC 6929-3

Confidential and Proprietary to The Ultimate Corp.

Im Dokument BASIC Language Reference Guide (Seite 195-200)