Syntax

by • 03/07/2012 • New Pattern Computer NotesComments (0)1439

CLS
Purpose To clear the display screen.
Syntax CLS
Comments This command clears the entire screen and positions the cursor at Home with OK prompt.
Note Pressing the <Ctrl>/<Home> key sequence clears screen without Ok prompt.
DATA
Purpose To store numeric and string constants that will be accessed by READ statement.
Syntax DATA <Gonslnnt>[,<constant>]…Constant          It may be string or numeric.
Comments DATA statements are non-executable and may be placed anywhere in program.A DATA statement may contain as many constants as will fit on a line of 255 characters. While any number of DATA statements may be included in program.
DEF FN
Purpose To define a new function.
Syntax DEF FN<name> [(<variable>[,variable]…)]=<function>name               is a valid variable-name preceded by FN.

variable                       is a dummy variable used to define a function.

function           is an expression, returns a value of the type indicated by variable <name>.

Comments The  DEF  FN  statement  must  define the  function  in  a  program  before  the function is called. If a function is called before it is defined, an “undefined user function” error message is displayed.
DIM
Purpose To specify the  maximum  values  for array  variable  arid  to  allocate  enough memory for storage.
Syntax DIM <variable>(<subscript>) [.<variable>(<subscript>)]…variable           is a valid array variable name.

subscript         indicates size for each dimension.

Comments This statement is used to define a list of subscripted variables. A maximum of 255 dimension can be defined.
DRAW
Purpose To draw an object in the graphics mode.
Syntax DRAW <string>String  is a string expression using subcommands to draw the object.
Comments Subcommands describe motion (up, down, left, right, up-right, up-left, down-left.down-right), color, angle and scale factor. These subcommands are as under:

Mx, y    Move. The x and y are the coordinates

Un        Move Up. The distance moved is n units.

Dn       Move Down.

Rn        Move Right.

Ln        Move Left.

En        Move Up-Right (north-east).

Fn        Move Down-Right (south-east).

Gn        Move Down-Left (south-west).

Hn       Move UP-Left (north-west).

B          Blank (prolix). Don’t diaw any points for next command.

N         No move (prefix).Back to starting point after command.

An        Angle. To rotate figures.

Cn        Color. Select color 0. 1. 2, or 3 todraw with.

Sn        Scale. Select figure scaling size.

XnS      Execute sub-string.

END
Purpose To terminate the program execution.
Syntax END
Comments This statement may be placed anywhere in program to terminate the execution.An END statement at the end of program is optional.
ERASE
Purpose To eliminate arrays from memory.
Syntax ERASE <array name>[,<array name>]…array name        is name of an array you want to erase from memory.
Comments The ERASE statement may be  used to  free  memory  by erasing  the  space allocated to an array or arrays.
e.g. ERASE AS        Erases a string array AS.ERASE D.E       Erases two numeric arrays D and E.
FOR…NEXT
Purpose To create a loop for a given number of times.
Syntax FOR <variablc>=x TO y [STEP z]:

:

NEXT [<vanable>]

variable                       must be a valid integer or single precision variable.

X                     is a numeric expression representing the initial value of counter.

Y                      is a numeric expression representing the final value of counter.

Z                      is a numeric expression representing the increment.

Comments If STEP is not specified, the increment defaults to one. If STEP is negative the counter is decrement from initial value to final value and the loop is executed until the counter is less then the final value. FOR…NEXT loops may be nested, that is. a FOR…NEXT loop may be placed with in another FOR…NEXT loop
GOSUB…RETURN
Purpose To branch to and return from, a subroutine.
Syntax GOSUB <line number>RETURN [<line number>

line number in GOSUB, it is first line of subroutine. In RETURN, the optional <line number> indicates a specific line to return to from subroutine.

comments The GOSUB and RETURN statements allow to create subroutines that may be called any number of times from anywhere in program. A subroutine may also be called from within another subroutine.
GOTO
Purpose To branch unconditionally to a specified line number.
Syntax GOTO <line number>line number       is any valid line number in program.
comments When  the  GOTO  statement  is  executed,  program  control  is transferred- tospecified line number.
IF…THEN…ELSE
Purpose To make a decision regarding program flow based on the result returned by an expression
Syntax IF <expression> THEN <clause> [ELSE <clause>]expression        is an expression composed of relational or logical operators which

evaluates to a true (non-zero) or false (zero) value.

clause              is a statement, sequence of statements (separated by colon), or line

number.

Comments If the result of <expression> is true (non-zero), the THEN clause is executed. THEN may be followed by either a line number for branching or one-or more statements to be executed. If “the result of <expression> is false (zero), the THEN clause is ignored and the ELSE clause; if present, is executed. If ELSE clause’ is not present then execution continues with next executable statement. IF…THEN…ELSF statement may be nested. Nesting is limited only by length of line.
INPUT
Purpose To allow input from keyboard during program execution.
Syntax INPUT  [“<promp>” {;|,}] < variable[,<variable>]…Prompt                        is a string constant used as a message

variable                       can be numeric, string or array element

Comments At simple INPUT, statement the program execution pauses and a question mark is printed to indicate that computer is waiting  for data.   If <prompt>  and semicolon “;” are included, the prompt is displayed before question mark. If the comma “,” is used  instead of semicolon then  the question  mark will  net displayed. The <Enter> key continues the execution.
LET
Purpose To assign a value to a variable.
Syntax [LET] <variable> = <expression>Variable          is any valid variable name.

Expression       any valid expression, but type must be same as variable type.

Comments The LET is an optional statement.
LINE
Purpose To draw a line or box on screen in graphics mode.
Syntax LINE [(x1 ,y1)]-(x2,y2)[,[<color>][,[B[FJ][,<style>]]](x1,y1) is the coordinate to start.

(x2,y2) is the ending coordinate.

color    is the number of color.

B          to draw a rectangle box.

BF        to draw and fill box with color of line.

style     to change the line style.

Comments The LINE command is used in graphics mode to draw straight lines or rectangles on screen. These rectangles may be filled with “F” option.
LOCATE
Purpose To move the cursor at a specified position
Syntax LOCATE [<row>][,[<column>]]row                              is a numeric expression within 1 to 25, indicating row number on screen.

column                        is a numeric expression in the range 1 to 80 or 1 to 40, indicating a

column number on screen.

comments The LOCATE statement is used to move the cursor to a specified position on screen. This allows the program to print anywhere on screen.
LPRINT
Purpose To print data on printer.
Syntax LPRINT [<expression>][{;|,}][<expression>]…expression       is a numeric or-string expression. String constants must be enclosed in

quotation marks. The <expression>s may be separated by spaces,

commas, or semicolons. If no <expression> items are listed, a blank line is

printed.

comments LPRINT assumes the 80 column printer and functions like the PRINT statement.
PAINT
Purpose To fill a graphics object with a specified color.
Syntax PAINT (x.y)(,<color>[,<border>]](x,y)      are the starting coordinate to fill.

color     is color to use for painting-and must be in the range 0 to 3 in medium resolution &

0 or 1 in high resolution.

border is in the range 0 to 3 and identifies the border color.

Comments The PAINT statement is used to fill or paint around the point (x,y). It acts like a brush, which is always full of specified paint.
PRINT
Purpose To display the data on screen.
Syntax PRINT [<expression>][{;|,}][<expression>j…expression       is a numeric or string expression. String constants must be enclosed in

quotation marks. The <expression>s may be separated by spaces,

/commas, or semicolons. If no <expression> items. are listed, a blank line

is displayed.

Comments GWBASIC divides the screen line into print zones of 14 columns each. If the list’ of <expression>s are separated by commas, the next item is printed at the beginning of the next print zone. If the list of <expression>s are separated by semicolon or spaces, the next item is printed immediately after the last item.
PSET
Purpose To draw a point on screen at a specified position (for graphics mode only).
Syntax PSET (x,y)[.<color>](x,y)      is the coordinates of required point.

color     is to be-used to draw the point. In medium resolution, <color> is 0 to 3. In high

resolution, it is 0 or 1.

Comments This statement allows to draw a point anywhere on screen with specified color.
READ
Purpose To read values from DATA statement.
Syntax READ <variable>[,<variable>]…Variable          is a string, numeric or array element.
Comments A READ statement must always be used in conjunction with DATA statement.READ statement assign values from DATA statements to the variables in READ statement on a one-to-one basis. The variable type used in READ statement must agree with next value in the DATA table.
REM
Purpose To write comments in a program.
Syntax REM <remarks>remark             may consist of any sequence of characters.
Comments REM statement is non-executable statement, but it holds the space in memory.Remarks may be added to the end of a line by preceding the remark with a single quotation mark           During execution, the interpreter ignores everything on the line after a remark.
RESTORE
Purpose To allow DATA statement to read again.
Syntax RESTORE [<ti’ne number>]line number       is of a DATA statement in program.
Comments With no line number it resets the pointer to indicate back to the first element of DATA table. The next READ statement would then read first item in the first DATA statement available in program.. If a  <line number>  is specified, then DATA table pointer is reset to the beginning of that line.
SCREEN
Purpose To set the specifications for display screen.
Syntax SCREEN <mode>mode  is a numeric value in the range 0 to 2, indicating the current mode as follows.

0:         Text mode at current width 40 or SO columns per row

1:         medium resolution graphics mode. 320×200 pixels.

2:         high resolution graphics mode. 640×200 pixels.

Comments When the SCREEN statement is executed with a new screen mode, the new mode is stored, the screen is cleared, the foreground color is set to white and the background and border colors are set to black.
WHILE…WEND
Purpose To execute a series of statements in a loop as long as a given condition is true.
Syntax WHILE <expression> 

WEND

expression       is an expression returning a true (non-zero) or false (zero) value.

Comments If <expression> is true, the following loop statements are executed until the WEND statement is encountered. GWBASIC then returns to the WHILE statement and checks <expression>. If it is still true, the process is repeated. If it is not true, execution resumes with the statement following the WEND statement.

 

 

 

Pin It

Leave a Reply