This is a child page. You can use Parent in the quick nav bar at the top or the bottom of the page to navigate directly back to the parent of this page. Some child pages are more than one level deep, and in that case will require more than one Parent click to reach the outermost document level.

16.96.17 - BASIC-like Script Commands

ABS(n)

Returns the absolute value of the parameter (a positive number.)

ASC("string")

Returns the ASCII code for the character in the string.

ATN(n)

Returns the arc-tangent of the parameter in radians.

CEIL(a)

Returns the nearest integer less than a.

CHAINP filename

Brings in new program lines. The old program data is discarded. Variables that have been marked by the use of the COMMON statement are retained, other variables are discarded.

CHR$(n)

Returns the ASCII character represented by the numeric parameter.

CLAMP(x,a,b)

If x < a, returns a. If x > b, returns b. Otherwise returns x.

CLEAR

Resets all numeric variables to zero and text variables to empty.

CLOSE #n

Closes the open file by its channel number.

COMMON variable[,variable...]

This identifies a variable as one that gets passed along to a program that you bring in using the CHAINP command.

COS(n)

Returns the cosine of the parameter in radians.

DATE$

Returns the current date as a string.

DAY$

Returns the day (1-31) as a string.

DEF UFfunction-name([arg[,arg...]])

Defines a function that you construct. The function name must begin with the capital letters UF (for User Function). The variables named in the left side of the statement control what is passed to the function.

The following simple example implements a negative function using inverse luma:

10 REM shows how to use DEF 20 DEF UFNUG(uuu,vvv) = 255-GETLUMA(uuu,vvv) 40 X1=GETX1(0): Y1=GETY1(0): X2=GETX2(0): Y2=GETY2(0) 50 FOR Y=Y1 TO Y2 60 A=PROGRESS(Y-Y1): IF A=1 THEN END 70 FOR X=X1 TO X2 80 a = PUTLUMA(X,Y,UFNUG(X,Y)) 90 NEXT X 100 NEXT Y

DEG(n)

Returns the degree value equivalent to the specified number in radians.

DIM variable(n[,n...])

Examples:

10 DIM a(10,20) 20 DIM B$(100,3)

END

This command terminates the script immediately.

EOF(#n)

Returns -1 if the device referenced is at the end-of-file, otherwise returns zero.

ERASE variable (Unknown Built-in or Squiggly: tag=",variable..." data="row

EOF(#n)

Returns -1 if the device referenced is at the end-of-file, otherwise returns zero.

")

Erases variables.

EXP(n)

Returns exponential of parameter.

FIELD #n, o AS s$ [, p AS t$...]

This allocates space in a random file buffer for device indicated by #n, allocating o bytes and assigning the bytes at this position to the variable s$, etc.

FOR n=x TO y [STEP z]

Example:

10 FOR I=0 to 10 STEP 2 20 print "The number is ";I 30 NEXT I

FLOOR(a)

Returns the nearest integer greater than a.

GET #n [,record number]

GET reads the next record from a random-access file or device into the buffer associated with that file. If record number is specified, GET reads the specified record.

GOSUB line

This jumps to the specified line and begins execution. However, when it jumps, it remembers where it was when it jumped; when, at the new location, it encounters a RETURN statement, the script will resume execution at the statement or line immediately following the GOSUB statement.

GOTO line

This jumps to the specified line and begins execution there.

HEX$(n)

Returns a string which is the base-16 equivalent of the parameter n.

HILIM(a,b)

Returns 'a', or 'b' if a > b.

HOUR$

Returns the current hour as a string 0-23.

IF expression THEN statement [ELSE statement]

Example:

10 A=5 20 IF A=5 THEN PRINT "it was 5" ELSE PRINT "it was something else"

INSTR([start,] string, pattern)

Used to search for the pattern in the string. If found, will return the character position in the string where it exists; otherwise, it will return 0.

INT(n)

Discards the fractional part of the number, if any, and returns the integer part.

KILL "filename"

Deletes the specified file.

LEFT$("string",n)

Returns the leftmost n characters of the string.

LEN("string")

Returns the length of the string.

LET variable=expression (OPTIONAL)

Optional assignment statement. These do the same thing:

10 LET A=5 20 A=5

LOC(#n)

LOC returns the next record that GET or PUT statements will use.

LOF(#n)

Returns the length of the file specified by #n (see OPEN)

LOG(n)

Returns natural log of parameter.

LOWLIM(a,b)

Returns 'a', or 'b' if a < b.

LSET x$ = expression

Transfers data from expression to the left hand side of a string variable or random access buffer field.

MAX(a,b)

Returns the larger of 'a' or 'b'.

MERGEP filename

Brings in new program lines from a file. The current program is retained, and varables are not reset. To reset variables and discard the current program, use CHAIN instead.

MID$("string",start[,len])

Returns a substring of len length (if provided) starting at start.

MIN(a,b)

Returns the lesser of 'a' or 'b'.

MINUTE$

Returns a string of minutes 0-59.

MONTH$

Returns a string for month, 1-12

NAME oldfile AS newfile

Renames the specified file.

NEXT

Used with FOR

ON variable GOSUB

Allows you to associate a series of subroutines with different values of a variable. Example:

10 A=2 20 ON A GOSUB 100,200,300 30 PRINT "We're back..." 40 END 100 PRINT "sub 1":RETURN 200 PRINT "sub 2":RETURN 300 PRINT "sub 3":RETURN

ON variable GOTO

Allows you to associate a series of jump-out targets with different values of a variable.

Example:

10 A=2 20 ON A GOTO 100,200,300 30 PRINT "Whoops - A was not matched!" 40 END 100 PRINT "target 1":END 200 PRINT "target 2":END 300 PRINT "target 3":END

OPEN "O"|"I"|"R", #n, filename, [,recordlength] filename FOR INPUT|OUTPUT|APPEND AS #n [,LEN=recordlength]

You can actually use OPEN two ways:

OPEN "O"|"I"|"R", #n, filename [,recordlength] OPEN filename FOR INPUT|OUTPUT|APPEND AS #n [,LEN=recordlength]

The first form, with the O|I|R options, allows you to select sequential or random file access. The R option is the random access option, while I and O are sequential.

The second form allows only sequential file access.

See the PRINT statement for an example of the use of the second form.

OPTION BASE n

Controls the referencing of arrays. With OPTION BASE 1 in effect (the default), this statement:

10 DIM A(10)

...will result in array elements from A(1) through A(10).

With OPTION BASE 0 in effect, this statement:

10 DIM A(10)

...will result in array elements from A(0) through A(9).

POS

Returns a number represeting the character position on the output (PRINT) line.

PRINT [#n]|[USING format] expressions

PRINT is the means to write information to dialogs in F/x, and also to files. Used by itself as PRINT expression, output is sent to F/x. Used with a device number and an open file, you can write almost anything to the file.

PRINT expressions are text strings or variables separated either by commas, which act as TABs, or by semicolons, which act to juxtapose one portion of an expression next to the next portion. Examples:

10 PRINT "This is a test." 20 A=5 30 PRINT "The value of A is ";A 40 B=7 50 PRINT A,B 60 OPEN "c:\scripttest.txt" FOR OUTPUT AS #1 70 PRINT #1,"Data for the file" 80 PRINT #1,"A+B=";A+B 90 CLOSE #1

PUT #n[,recordnumber]

PUT outputs the next available record or the record specified by recordnumber to the specified channel.

RAD(n)

Returns the radian value equivalent to the specified number in degrees.

RANDOMIZE n

Seeds the script language random number generator.

READ variable[,variable]

Reads information contained in DATA statements.

REM ignored content

RESTORE

Resets the READ statement so that it points back to the beginning of the information contained in the DATA statements.

RETURN

This statement is only used in subroutines. When you call a subroutine with GOSUB, this statement causes execution to result at the line or statement following the GOSUB call.

RIGHT$("string",n)

Returns the rightmost n characters of string.

RND(0)

Returns a random number ranging from zero to 1.

RSET x$ = expression

Places the data specified by expression into the right side of a string variable or random access buffer field.

SECOND$

Returns a string representing seconds in the range 0-59.

SGN(n)

Returns either -1, 0 or 1, depending on the sign of the argument.

SIN(n)

Argument n is in radians.

SMOOTHSTEP(x,a,b)

If x < a, returns 0. If x > b, returns 1. Otherwise, returns a smoothed value to make the step between 0 and 1 smooth.

SPACE$(n)

Returns a string with n spaces in it.

SQR(n)

Square root function.

STEP(x,a)

If x < a, returns 0. Otherwise returns 1.

STR$(n)

Returns a string of the number.

STRIP("string")

Removes all leading and trailing spaces and tabs from a string, but does not remove any that are "interior" elements, that is, that might be separating words or numbers interior to the string.

SWAP variable,variable

Swaps two variables of identical types.

TAB(n)

Sends spaces until the column indicated by n is reached. Intended to be used with PRINT.

TAN(n)

Argument is in radians.

TIME$

Returns the current time as a text string.

VAL("string")

Returns the value (a number) of a string that contains a text representation of a number.

WEND

Ends a WHILE loop, see WHILE.

WHILE expression

Will loop as long as the expression evaluates as true (-1).

WIDTH #n,n

Sets the number of columns assumed to the be the full width of the specified output channel.

WRITE #n,expression[,expression]

Somewhat like print; outputs variables in a formatted manner.

YEAR$

Returns a string containing the year.

Keyboard Navigation
, Previous Page . Next Page t TOC i Index o Operators g Glossary
WinImages F/x, Morph and all associated documentation
Copyright © 1992-2007 Black Belt Systems ALL RIGHTS RESERVED Under the Pan-American Conventions
WinImages F/x Manual Version 7, Revision 6, Level A

Valid HTML 4.01 Loose
 

This manual was generated with wtfm
wtfm uses aa_macro and SqLite
aa_macro uses python 2.7
Page 275