BASIC-SO

Functions

MID$

The MID$(X$,1. [,J]) function examines string X$ and returns the rightmost characters starting at pointer 1. I and J are integers in the range 1-255. If argument J is specified, J characters are returned, starting at position 1. If I is greater than LEN(X$), the MID$ function returns the null string. If argument J is greater than the number of characters in X$ to the right of I or is not specified, MID$ returns the rest of the string.

MID$(string expression, expression [,expression])

10X$ = "JOHN J. JONES"

20PRINT MID$(X$,10,3)

30PRINT MID$(X$,9)

40END

RUN ONE JONES

Ok

The MID$ (X$, 1. [,J]) function may also appear on the left side of an assignment statement. Employed in this context, it will replace the characters of string X$ begin- ning at position I with the string given on the right. If J is specified, J characters of X$ are replaced. If I is greater then LEN(X$) , an illegal function call error is displayed. The length of X$ is never changed.

10A$ = "ABCDEF"

20B$ = "XXYYZZ"

30MID$(A$,2,4) = B$

40PRINT A$

50END

RUN AXXYYF

Ok

MKI$

MKS$

MKD$

The three functions MKI$, MKS$, and MKD$ convert data represented as numerical values into two-, four-, or eight-byte strings, respectively. MKI$ is used to convert an integer value; MKS$ is used to convert a single-precision floating-poinf value; and MKD$ is used to convert a double-precision floating-point value.

MKI$ (integer)

MKS$ (single-precision value)

MKD$ (double-precision value)

These functions are used to place numeric values into fields of random file buffers. See Chapter 5 for discussion of MKI$, MKD$, and MKS$

OCT$

The aCTS function returns a string of octal digits which represent the value of the integer argument. The expression is rounded to an integer before conversion.

OCT$ (expression)

10PRINT "TYPE DECIMAL INTEGER TO BE CONVERTED."

20INPUT A

30A$ = OCT$(A)

40PRINT A,"EQUALS,"A$," IN OCTAL."

7-9

Page 73
Image 73
Intel 9800758-02 manual Mid$, Mki$ Mks$ Mkd$, Oct$