Omikron BASIC for Apple Power Mac

5-7. LSET - NEXT Contents | 5-9. POS - SAVE

 

Chapter 5-8

The Command Set

NOISE - POKE

NOISE
Type: Command
Syntax: NOISE <num.expression>,<num.expression>[[,<num.expression>,<num.expression>]]
NOISE <sound channel>,<sound>[[,<sound channel>,<sound>]]
Explanation: Adjusts the purity of sound. A value between 0 and 15 must be passed in <sound channel>. <Sound> can have values of 0 to 254. Value 0 indicates that the sound is clear and pure, 254 results in a sound with more of a low humming quality. One command can change up to 16 different sound channels.

Note: In order to hear the sound, TUNE must be used to allocate a frequency to the corresponding channels and VOLUME to determine a sound volume.
Example: TUNE 0,40
VOLUME 0,255
T=0:Dt=1
REPEAT
NOISE 0,T:WAIT 0.01
T+=Dt
IF T<=0 or T>=254 then Dt*=-1
UNTIL LEN(INKEY$)
Result: First, a sound is created and the sound volume set to maximum, followed by alternately increasing and decreasing the purity in the loop.
See also: TUNE   VOLUME    Table of MIDI Notes
   
 


NOR
Type: Operator
Syntax: <num.expression>NOR <num.expression>
Explanation: Links the two numerical expressions with the logical operator "not-or (NOT OR)".
Example: PRINT BIN$((%1010 NOR %1100)+%10000)
Result: %1
See also: OR     XOR     AND    NAND     IMP     EQV     NOT
   
 


NOT
Type: Function
Syntax: NOT <num.expression>
Explanation: Negates the numerical expression bit-wise. Since all expressions not equal to 0 are considered true, NOT does not necessarily turn a true expression into a false one.
Example: OK=1
PRINT NOT(2>1), NOT OK
Result: 0    -2
See also: OR    NOR    XOR    AND   NAND     IMP     EQV 
   

 

OCT$
Type: Function
Syntax: OCT$(<num.expression>)
Explanation: Converts the numerical expression into a character string, which represents the rounded value of the expression as an octal number.
Example: PRINT OCT$($12345678)
Result: &2215053170
See also: HEX$   BIN$   STR$   VAL 
   

 

OFF, ON
Explanation: See OUTLINE   COMPILER
   
 


ON ERROR GOTO
Type: Command
Syntax: ON ERROR GOTO {<label>|0}
Explanation: If an error occurs during the execution of the program that would result in an error message, this error can be intercepted with ON ERROR GOTO. When the error appears, a jump leading to the indicated label is initiated. If a zero is specified instead of a label, the error control monitoring is deactivated again. It is of absolute necessity to conclude the error handling routine with RESUME, RESUME <label>, or RESUME NEXT. This enables the recognition of those issues pertaining to the error handling and those pertaining to the program. Therefore, the error handling routine should not be exited using GOTO. If an error occurs again during the error handling routine, the new error is always handled by Omikron Basic, since otherwise the program would slip into an endless loop.
The system variables ERR, ERR$, and ERL contain the error number, error text, and error line. (See 'Error Messages of Omikron Basic'). For an example see also RESUME.
Example: ON ERROR GOTO Error
A#=0
PRINT 1/A#
PRINT A#
END

-Error
IF ERR=83
THEN FORMALERT (2,"[2][Division by 0|Continue Program?] [Yes |No]",R)
IF R=1 then RESUME NEXT ELSE END
ELSE ERROR ERR: END
ENDIF
Result: First, an error is triggered by dividing through zero. That returns error 83, which is processed in the error handling routine. The routine does not manage other errors but instead returns them to Omikron Basic with ERROR ERR.

Note: The error will be noticed only if the FPU exceptions are activated (see
Compiler Control Words).
See also: RESUME   Error Messages of Omikron Basic
   
 


ON ... GOSUB
Type: Command
Syntax: ON <num.expression>GOSUB <label>[[,<label>]]
Explanation: Depending on the numerical expression, a branch to one of the subprograms defined by the labels is created. If the numerical expression equals one (1), the branch leads to the first label, if it is two (2), the branch leads to the second, etc. If the numerical expression equals 0 or is greater than the number of indicated labels, a branch is not established at all, and the command will be ignored. The subroutine must be concluded with RETURN.
Example: INPUT "Value (1-3): ";Value
ON Value GOSUB Animal,Vegetable,Tree
END

-Animal: PRINT "Dog": RETURN
-Vegetable: PRINT "Cabbage": RETURN
-Tree: PRINT "Oak": RETURN
Result: Depending on input, the word dog, cabbage, and oak appears on the screen.
See also: ON GOTO     GOSUB 
   

 

ON ... GOTO
Type: Command
Syntax: ON <num.expression>GOTO <label>[[,<label>]]
Explanation: Depending on the numerical expression, a branch to one of the subprograms defined by the labels is created. If the numerical expression equals one (1), the branch leads to the first label, if it is two (2), the branch leads to the second, etc. If the numerical expression equals 0 or is greater than the number of indicated labels, a branch is not established at all, and the command will be ignored.
Example: INPUT "Value (1-3): ";Value
ON Value GOTO Animal,Vegetable,Tree
END

-Animal: PRINT "Dog": END
-Vegetable: PRINT "Cabbage": END
-Tree: PRINT "Oak": END
Result: Depending on input, the word dog, cabbage, or oak appears on the screen, followed by the immediate termination of the program.
See also: ON GOSUB    GOTO 
   
 


ON HELP GOSUB
Type: Command
Syntax: ON HELP GOSUB <label|0>
Explanation: If the [Help] key is pressed, a branch to the subprogram defined by <label> is initiated.
Which key is supposed to function as the [Help] key can be established with the procedure Set_Help from the Extension Library.
The subprogram must be concluded with RETURN.
[Help] key monitoring is deactivated by placing a 0 behind the command.
Example: ON HELP GOSUB Help
PRINT "Please, press [Help] key."
REPEAT
'The main program is displayed here'
UNTIL End
END

-Help
PRINT "The HELP key was pressed."
End=-1
RETURN
Result: Please, press [Help] key.
The HELP key was pressed.
See also: ON KEY GOSUB   Set_Help 
   

 

ON KEY GOSUB
Type: Command
Syntax: ON KEY GOSUB <label|0>
Explanation: Triggers a branch to the subprogram defined by <label> as soon as the user presses a key.
Keyboard monitoring is deactivated by placing a 0 behind the command.
Example: ON KEY GOSUB Key
PRINT "Please press some keys. [Esc]->End"
REPEAT
'The main program is displayed here'
UNTIL End
END

-Key
Key= CVIL( INKEY$)
Shiftbits=Key SHR 24
Scancode= HIGH(Key) AND $FF
Ascii=Key AND $FF
PRINT "Shiftbits:";Shiftbits;" "," Scancode:";Scancode;" "
PRINT "ASCII:";Ascii;" "
IF Scancode=35 THEN End=-1
RETURN
Result: A branch to the subroutine is created by each keystroke and the result displayed on the screen.
See also: ON HELP GOSUB
   
 


ON MOUSEBUT GOSUB
Type: Command
Syntax: ON MOUSEBUT GOSUB {<label>|0}
Explanation: Triggers a subroutine to the subprogram defined by <label> as soon as the user presses a mouse button.

Important: A jump to the subprogram is triggered only if the status of the mouse buttons is changed. Thus, if a mouse button is pressed and then remains depressed, the subprogram will be executed only once. Mouse button monitoring is deactivated again by placing a zero behind GOSUB.
Example: ON MOUSEBUT GOSUB Mouse_Button
PRINT "Please, press mouse button"
REPEAT
'The main program is displayed here
UNTIL LEN( INKEY$ )
END

-Mouse_Button
PRINT "Mouse button status: "; MOUSEBUT
RETURN
Result: As soon as the mouse button is pressed, the subroutine returns the status of the mouse button in connection with the modifier keys.
See also: ON KEY GOSUB    MOUSEBUT
   
 


ON ... RESTORE
Type: Command
Syntax: ON <num.expression>RESTORE <label>[[,<label>]]
Explanation: The pointer indicating the next available allocation to be read by READ is reallocated dependent on the numerical expression. If the value of the numerical expression amounts to one (1), the first label is valid, if it amounts to two (2), the second label is valid, etc. The DATA pointer indicates the first available allocation defined by DATA, which appears behind the appropriate label. If the numerical expression equals 0 or is greater than the number of the specified labels, the DATA pointer is not reallocated and the command will be ignored.
Example: DATA "First text"
-Animal: DATA "Dog"
-Vegetable: DATA "Cabbage"
-Tree: DATA "Oak"
INPUT "VALUE (1-3): ";Value
ON Value RESTORE Animal,Vegetable,Tree
READ Text$
PRINT Text$
Result: Depending on input, the word dog, cabbage, or oak is displayed on the screen.
See also: RESTORE   DATA   ON ... GOTO   ON ... GOSUB 
   

 



ON TIMER ... GOSUB 
Type: Command 
Syntax:  ON TIMER <num.expression>GOSUB {<label>|0}
ON TIMER <time in seconds>GOSUB {<label>|0}
Explanation: Every <time in seconds>, a jump is triggered to the subprogram defined by <label>. If the jump target is specified as 0, timer monitoring is deactivated again. Care should be taken to ensure that the subprogram does not claim too much time. If the subprogram should require more time than the initially adjusted time interval allows, it will be called again as soon as it has finished with no time remaining to execute the main program.
Example: ON TIMER 1 GOSUB Clock
REPEAT
'The main program could be displayed here'
UNTIL LEN(INKEY$)
END

-Clock
PRINT CHR$(27)+"j"+@(0,0)+TIME$+" "+DATE$+CHR$(27)+"k"; 
RETURN 
Result: The time is displayed once per second in the left upper corner.
See also: TIMER    ON HELP GOSUB     ON KEY GOSUB     ON MOUSEBUT GOSUB 
   
 


ON TRON GOSUB
Explanation: Has no application purpose in Omikron Basic 6 and is ignored by the compiler. Please, do not use.
   

 

OPEN
Type: Command
Syntax: OPEN <string expression>,<num.expression>, <string expression>[,<num.expression>]
OPEN <mode identification>,<file number>,<file name>[,<record length>]
Explanation: OPEN opens a file. The mode identification is one character long and characterizes the type of the file to be opened. Omikron Basic manages up to 16 open files simultaneously. Therefore, the file number must be between 1 and 16 and serves as the distinguishing feature (handle) of this file for all further file operations.
A FileSpecificationRecord such as is returned by e.g., FILESELECT or the function 'Get_Fsspec$' of the Extension Library must be passed in the file name.
The different modes have the following meanings:

"I" "Input" sequential file; only for reading
"O" "Output" sequential file; only for writing; deletes an already existing file
"A" "Append" sequential file; only for reading; is appended to existing file
"R" "Random" random access file; read and write, fixed record length; use of FIELD/PUT/GET
"U" "User", random access file; read and write, no fixed record length; use of PUT/GET/SEEK
"P" "Printer " opens a channel to the serial printer interface
"V" "V24" opens a channel to the serial modem interface
"F" "Files" opens a channel that may be used to query the properties (size, date of creation...) of a file or folder and modify them in part as well.


Possible read-write functions of the three sequential file modes "Input", "Output," and "Append": PRINT #, WRITE #, INPUT #, INPUT$(,), or LINE INPUT #. Furthermore, EOF and LOF can be determined.

Important: In order to open a file with "Append," this file must already exist; otherwise, an error is triggered.

The random access file of the type "R" requires the record length as a supplementary parameter. If no record length is specified, the preset record length of 128 is valid. Before every write or read operation, one or several buffer variables must be defined by means of FIELD. Then GET and PUT read or write any data record. The first data record has the number 1. The file is extended automatically if a record is being written that does not yet exist within the file.

The "User" file does not require a specification of the record length. Any desired amount of data may be read or written. A buffer variable agreement is omitted; PUT/GET is used to directly read/write a memory block or string. In addition, the read/write pointer can be repositioned with SEEK.

The file modes accessing the interfaces of the computer function analogously to the sequential files. The appropriate interfaces are simply read from or written to and/or output effected through them. This is especially useful in connection with the CMD command. Functions such as LOF, LOC, or EOF are not allowed with channels, which were opened for interfaces.

'OPEN "F",Channel,Fsspec$' may be used to determine and in part also modify the properties of a file or folder. A structure has to be defined for the selected file number using the FIELD instruction, into which Omikron Basic then enters the desired properties. The FIELD instruction has to be structured as follows:

FIELD Channel,93,1 AS Attributes$,4 AS Time_Modification$,4 AS Time_Creation$,4 AS Size$,16 AS Finder_Information_Record$,64 AS File_Name$

Important: The strings have to be global variables and their size has to remain unchanged. Partial assignments should be effected using LSET and/or RSET.

The individual variables have the following significance:
<Attributes$> : These are file attributes. If bit 0 has been set, the folder is write-protected, bit 4 indicates whether the object is a folder. All other bits have little significance for practical applications. The inquisitive ones among the users may read about their significance in "Inside Macintosh, Files."
<Time_Modification$> : Time and date of last modification.
<Time_Creation$> : Time and date of file creation.
<Size$> : Size of file in bytes.
<Finder_Information_Record$> : The so-called FinderInformationRecord. It consists of a 4 byte FileType, 4 byteFile Creator, 2 byte
FinderFlags and other, less important information. A detailed description can be found in "Inside Macintosh, Macintosh Toolbox Essentials."
<File_Name$> The name of the file or folder. This information holds special interest if <Index> is used to search for a folder.

The individual entries are read with 'GET Channel,Index'. The following values are possible for <Index>:

Index=-1 : The properties of the folder are read, which contains the file determined by <Fsspec$>.
Index=0 : The properties of the file are read, which is determined by <Fsspec$>.
Index>0 : The properties of the file are read, which is located at the location determined by <Index> in the folder defiend by <Fsspec$>. This syntax makes it possible to extract all files of a folder and to examine the folders within the folder as well by using recursive programming.

The time indications and entries in <Finder_Information_Record$> may also be modified and then assigned to the file or folder using 'PUT Channel,0'. For practical purposes it is best first to use GET to read the existing information into the FIELD structure, then to modify the respective strings, and then to write them back to the files with PUT.

Please, also consider the sample programs OPEN "F" GET.BAS and OPEN "F" PUT.BAS in the DEMO folder.  
Example: 'First, the ExtensionLibrary must be loaded from the editor.
Extension_Init
P$="File name":R=1:FILESELECT(P$,F$,R):' Select target file
IF R THEN
OPEN "O",1,F$:' F$ contains the FileSpecificationRecord
WRITE #1,"Caspar","Melchior","Balthazar"
CLOSE 1
OPEN "I",1,F$
WHILE NOT EOF(1):' Reading until EOF
INPUT #1,N$
PRINT N$,
WEND
CLOSE 1
ENDIF
INPUT "Program concluded with 'RETURN' ";E
Extension_Exit
END
Result: Caspar Melchior Balthazar
See also: CLOSE   PRINT #    WRITE #    INPUT #    INPUT$    LINE INPUT    EOF   LOF 
FN Ser_Get_Buf Ser_Reset
   

 

OR
Type: Operator
Syntax: <num.expression>OR <num.expression>
Explanation: Links the two numerical expressions with the logical operator "OR".
Example: PRINT BIN$(%1010 OR %1100)
Result: %1110
See also: AND    NAND    XOR    NOR    IMP    EQV    NOT
   
 

OTHERWISE
Type: Command
Syntax: OTHERWISE
Explanation: If no other alternative was applicable, OTHERWISE or DEFAULT is used within a SELECT ... CASE statement to initiate the program branch to be executed. The OTHERWISE branch must always be the last possibility within the SELECT...CASE statement. An additional CASE statement may not follow.
See also: DEFAULT
   
 


OUTLINE
Type: Command
Syntax: OUTLINE {ON|OFF}
Explanation: The outline of all filled rectangulars, circles, etc. may be activated or deactivated with this command.
The color for the frame being drawn is chosen with LINE COLOR, the width chosen with LINE WIDTH, and the mode selected with MODE. The drawn line will always be a continuous line, with the value set with LINE STYLE having no effect.
An example illustrates this probably best:
Example: CLS: FILL COLOR=0
FILL STYLE=2,4
OUTLINE OFF: PCIRCLE 100,100,80
OUTLINE ON: PCIRCLE 200,100,80
Result: One circle is drawn with and one without a border or outline.
   
 


PALETTE
Type: Command
Syntax: PALETTE [<num.expression>],[[,<num.expression>]]
PALETTE [<start register>],[[,<color register>]]
Explanation: Writes the specified values into the internal color map of Omikron Basic. The first parameter specifies which index should be the starting point of the read operation. Additional parameters may follow, which are entered into the subsequent color registers. The color parameters must be specified as a long-integer number, whereby 1 byte (value 0-255) is to be selected for each one of the colors red, green, and blue ($00RRGGBB).
See also: Get_Indexed_Color     Set_Indexed_Color
   

 

PBOX
Type: Command
Syntax: PBOX <num.expression>,<num.expression> {TO <num.expression>,<num.expression>|,<num.expression>,<num.expression>}
PBOX <X>,<Y>{TO <X2>,<Y2>|,<width>,<higth>}
Explanation: Draws a filled rectangle onto the screen. Either two opposite corners are to be specified or one corner, width, and height of the rectangle. The fill color defined in FILL COLOR and the fill style as defined in FILL STYLE are applied.
The outline frame is always a continuous line one pixel wide regardless of the settings effected in LINE STYLE and LINE WIDTH. The color corresponds to the fill color. The outline can be activated or deactivated using OUTLINE ON|OFF. If a window is defined by means of CLIP, nothing will be drawn outside of this area.
See also: BOX   PRBOX   RBOX 
   

 

PCIRCLE
Type: Command
Syntax: PCIRCLE <num.expression>,<num.expression>,<num.expression>[,<num.expression>,<num.expression>]
PCIRCLE <X>,<Y>,<radius>[,<start angle>,<end angle>]
Explanation: Draws a filled circle with the specified radius around the center <X>,<Y>. Start and end angle be optionally specified in one tenth of a degree. Angle=0 is located to the right of the center, angle=900 is located above the center, etc.
The fill color defined in FILL COLOR and the fill style as defined in FILL STYLE are applied.
The outline frame is always a continuous line one pixel wide regardless of the settings effected in LINE STYLE and LINE WIDTH. The color corresponds to the fill color. The outline can be activated or deactivated using OUTLINE ON|OFF. If a window is defined by means of CLIP, nothing will be drawn outside of this area.
See also: PELLIPSE   CIRCLE   ELLIPSE 
   
 


PEEK
Type: Function
Syntax: PEEK(<num.expression>)
PEEK(<address>)
Explanation: Reads a byte at the address returned by the numerical expression.
See also: WPEEK   LPEEK   POKE     WPOKE     LPOKE 
   
 


PELLIPSE
Type: Command
Syntax: PELLIPSE <num.expression>,<num.expression>,<num.expression>, <num.expression>[,<num.expression>,<num.expression>]
PELLIPSE <X>,<Y>,<X radius>,<Y radius>, [,<start angle>,<end angle>]
Explanation: Draws an ellipse with the specified radii around the center <X>,<Y>. Start and end angle be optionally specified in one tenth of a degree. Angle=0 is located to the right of the center, angle=900 is located above the center, etc.
The fill color defined in FILL COLOR and the fill style as defined in FILL STYLE are applied.
The outline frame is always a continuous line one pixel wide regardless of the settings effected in LINE STYLE and LINE WIDTH. The color corresponds to the fill color. The outline can be activated or deactivated using OUTLINE ON|OFF. If a window is defined by means of CLIP, nothing will be drawn outside of this area.
See also: PCIRCLE   CIRCLE   ELLIPSE 
   
 


PI
Type: Function
Syntax: PI
Explanation: Returns the number of the ratio of the circumference to the diameter of the circle- "pi" - as a double float number.
Example: PRINT PI
Result: 3.14159265358979
   
 


POINT
Type: Function
Syntax: POINT(<num.expression>,<num.expression>)
POINT(<X>,<Y>)
Explanation: POINT returns a pointer to the RGB Color Record of the pixel at (<X>,<Y>).
Example: PRINT "Quit whith any key."
REPEAT
C=POINT(MOUSEX,MOUSEY)
PRINT @(3,0);"Red =";HEX$(PEEK(C) SHL 8 + PEEK(C+1))+SPACE$(5)
PRINT @(4,0);"Green=";HEX$(PEEK(C+2) SHL 8 + PEEK(C+3))+SPACE$(5)
PRINT @(5,0);"Blue =";HEX$(PEEK(C+4) SHL 8 + PEEK(C+5))+SPACE$(5)
UNTIL LEN(INKEY$)
END
Result: The red, greeen, and blue components of the pixel at the mouse cursor position are continously displayed on the screen.
   

 

POKE
Type: Command
Syntax: POKE <num.expression>,<num.expression>
POKE <address>,<value>
Explanation: Posts the value as a byte at the indicated address. The value must be between 0 and 255.
See also: PEEK   WPEEK   LPEEK   WPOKE    LPOKE 
   
 

5-7. LSET - NEXT Contents | 5-9. POS - SAVE

Tech-Support | Order | Start | Home: http://www.berkhan.com


© 1997-2001 Berkhan-Software