Omikron BASIC for Apple Power Mac

5-6. INPUT$- LPRINT Contents | 5-8. NOISE - POKE


Chapter 5-7

The Command Set



Type: Command
Syntax: LSET <string variable>=<string expression>
Explanation: The string expression is inserted into the string variable left justified without changing its length. If the string expression needs to be truncated, this will occur at the end. This command is used especially during allocations to buffer variables (see FIELD).
Example: A$= SPACE$(20)
LSET A$="Omikron"
PRINT "*";A$;"*"
Result: *Omikron *
See also: RSET    FIELD     LEFT$ 

Type: Command
Syntax:  MAC_OS [<num.variable>][[,<num.variable>]] [;num.constant]; {<string constant>|<num.constant>}, <string constant> [[,<num.expression>]] 
MAC_OS [<return variable>][[,<return variable>]] [;flags]; {<import library name>|<import library number>}, <function name> [[,<parameter>]] 
Explanation:  This is a universal command to be used to import functions. Its main purpose is to call the MacOS, but it may also be used to import functions from shared libraries. A value may be returned to the <return variable>. How many and what type has to be indicated here depends on the function to be imported. If the function returns nothing the variables may also be omitted completely. However, a semicolon has to remain.

Some optional flags may be passed in <flags>, which will modify the command. The following bits are currently used:

Bit 0: The import is marked as "weak." This means that your program will be started even if the Code Fragment Manager cannot even find the desired function (unresolved import). You have to make sure yourself that in such cases your program does not call nonexistent functions under any circumstance. This can be achieved by querying the Gestalt Manager for the existing operating system components (Inside Macintosh, Operating Systems Utilities) or by first examining the transition vector of the function by calling the function using flag=3. A long integer variable has to be indicated here as the return parameter. Parameters do not have to be passed for this test. If the returned value equals zero, then the function does not exist and may not be called on any account.
Bit 1: No functions are called but data imported instead.
You will receive a value such as the address operator "&" would return as well. If the imported data are exported from a Library written in Omikron Basic, you may access this data using the dereference operator "*", otherwise, you have to ascertain from the documentation for the Library in question whether the received value is a date, a pointer, a handle, or something different.

The <import library name> indicates from which shared library the desired functions are to be imported. Here a numerical constant from 1 to 8 may be employed instead of the string constant. Then the following predefined strings are used: 

1: "InterfaceLib" 
2: "MathLib" 
3: "QuickTimeLib" 
4: "SpeechLib" 
5: "QuickDrawGXLib" 
6: "AppleScriptLib" 
7: "ObjectSupportLib" 
8: "StdCLib"

<Function name> is the name of the function, which is to be called. Please pay attention to capitalization.

Important: <Flags>, <import library name> or <import library number> and <function name> have to be constants already known at the time of compilation.This means you cannot indicate any variables, but rather plain text just as in the case of the predefined entries.

<Parameter1>,<Parameter2>, ... are numerical parameters to be passed to the function. Strings cannot be passed directly. Instead, a pointer to the string is passed. Attention has to be paid whether the function expects a Pascal string or a C string. If needed, the string has to be furnished with a length byte or null terminated, respectively.  
Example: See the programs Import.BAS and SpeekText.BAS in the folder DEMO.
See also:  DEF FNEX

Type: Command
Syntax: MAT <field variable>{+|-|*|/}< field variable>
MAT < field variable>=< field variable>[ {+|-|*|/}< field variable>]
1: MAT < field variable>=1
2: MAT < field variable>=< field variable>
3: MAT < field variable>{+|-|*|/}< num.expression>
4: MAT < field variable>=< field variable>{+|-|*|/}< field variable>
Explanation: First some basic information:
Matrix commands only function with two-dimensional floating point fields. It is unimportant whether single or double precision is used here. The size of the matrices is determined by the specified indices. Counting of the elements begins as always with zero. Thus, Matrix!(2,2) indicates a three-row quadratic matrix. Correspondingly, Matrix!(N,M) is a (N+1,M+1) matrix. The index can be omitted, as always when using fields. This will be treated the same way as if the highest index was indicated. If the field Matrix! was consequently dimensioned to (3,3), then Matrix!(,) is a four-row quadratic matrix.
Four different structures are to be distinguished when using the command MAT:

1. Creating a unit matrix. The unit matrix is allocated to the quadratic matrix.

2. Matrix allocation: All elements to the right of the equal sign are assigned to the left.
Note: This command functions with any fields, which do not meet the special requirements of matrices in the sense of Omikron Basic. Everything up to the specified element is simply copied from the right to the left. Of course, converting types is impossible during this process.

3. Scalar matrix operations: Depending on the operator
- a value is added to every element
- a value is subtracted from every element
- every element is multiplied with a value
- every element is divided by a value.

4. Vectored matrix operations: Depending on the operator
- two matrices are added (one element at a time)
- two matrices are subtracted (one element at a time)
- two matrices are multiplied
- two matrices are divided (multiplied with the inverse).

When multiplying and/or dividing matrices, care has to be taken to pay attention to a suitable selection of matrix dimensions. The following applies: A(P,Q)=B(P,N)*C(N,Q).
In addition, matrix C must be quadratic when performing divisions.
Example: N=3
DIM Matrix!(N,N),Mat_A!(N,N),Mat_B!(N,N),Mat_C!(N,N)
DIM Array1(10),Array2(10)
MAT Matrix!(,)=1
MAT Mat_A!(1,1)+2
MAT Mat_C!(,)=Mat_B!(,)+Mat_A!(,)
MAT Matrix!(1,2)=Mat_A!(1,2)
MAT Array2(5)=Array1(6):'The lesser index is valid
See also: MAT  CLEAR     MAT INV


Type: Command
Syntax: MAT CLEAR <field variable>
Explanation: MAT CLEAR deletes any field up to the specified maximum index. If no index is specified, the entire field is deleted. This command is not limited to floating point fields but can be used for any data types and any dimensions.
Example: N=3
DIM Matrix!(N,N)
DIM Array(10)
MAT CLEAR Matrix!(,)
MAT CLEAR Array(5)
Result: The field Matrix!(,) will be completely deleted, the field Array() only up to element 5.
See also: MAT


Type: Command
Syntax: MAT <field variable>= INV <field variable>
Explanation: Calculates the inverse matrix. Both matrices must be quadratic. If the inverse matrix does not exist (determinant = 0), an error message is issued.
Example: N=3
DIM Mat_A!(N,N),Mat_B!(N,N)
MAT Mat_A!(,)=1
MAT Mat_B!(,)= INV Mat_A!(,)
Result: The inverse of the unit matrix is calculated. Of course, this once again returns the unit matrix.
See also: MAT

Type: Function
Syntax: MAX (<expression>,<expression>)
Explanation: Outputs the greater of the two expressions as a functional value. Comparisons between numerical and string expressions are not permitted.
Example: PRINT MAX(1,4), MAX(-6, PI)
Result: 4 3.14159265358979
See also: MIN

Type: Function
Syntax: MEMORY(<num.expression>)
MEMORY(<block length|-1>)
Explanation: The MEMORY function allocates a non-relocatable memory block in the application heap of its program. The call with "-1" as a parameter returns the length of the largest available block. Otherwise, the memory address from which the required memory block is available is returned. The selected application heap has to be of such a size as to allow for the reservation of a sufficiently large amount of memory using the function MEMORY (see COMPILER "PRE_SIZE ..."). If the available memory is not sufficient, an error message of the memory manager appears. Memory blocks created with MEMORY can be released again with FRE().

Note: Some memory should be always kept unallocated and available (at least 64K), since various Omikron Basic commands and/or MacOS functions require some application heap memory.

X Note: When used with Mac OS X, MEMORY(-1) always returns very high values since each program has 4 GB of virtual memory. This is also the reason why a memory block requested with MEMORY can have a negative address.
Example: Free_Mem=MEMORY(-1)
IF Free_Mem>40000
 THEN Image_Buffer=MEMORY(32000)
 ELSE PRINT "Not Enough Memory!"
Result: The first query concerns the size of the largest contiguous and unallocated memory block. This query is followed by reserving an Image_Buffer of 32000 bytes if more than 40000 bytes are still available. Otherwise, an error is reported.
See also: FRE

Type: Command
Syntax: MEMORY_BLOCK <two digits>, <num.expression>, <num.variable>
MEMORY_BLOCK <name>, <size>, <address return variable>
Explanation: The MEMORY_BLOCK command creates a memory block of the specified size already during program input. The memory block will remain in the program from hereon, becoming part of the program and is accordingly saved and loaded by the editor. This memory block is identified by the two digits directly behind the MEMORY_BLOCK command. If an additional memory block with the same two digits is created, which has a lesser size than the first, the first one will be destroyed. Since the memory block is identified with two digits, max. 100 memory blocks (00-99) are possible within any given program.

Caution: It always has to be EXACTLY two digits (e.g., 03, 00, or 23). The size of the block must be an even number and its length may not exceed 32 MB.

Note: For the creation of larger memory blocks, enough memory has to be reserved in the editor for the program text. Use the dialog Mode/Preferences ... for this purpose.

The MEMORY_BLOCK can be filled with data using the editor menu option 'Load MEMORY_BLOCK' in the edit menu. Thus, data can consist e.g., of an image, which the user wants to incorporate into the program or a short machine language program, which serves to execute a specific task especially fast.
The address of the memory block is written into the return variable only after the program executes the MEMORY_BLOCK command after its successful compilation. Since the absolute address of the MEMORY_BLOCK is not known prior to the actual start of the program, machine language programs should not employ absolute addresses in memory areas set up by MEMORY_BLOCK!

Caution: It is impossible to write to a MEMORY_BLOCK while the program is running because it is located in the code fragment and with that is write-protected. A MEMORY_BLOCK can only be filled with data from the editor.
Example: 'A suitable cover must be loaded from the editor to the MEMORY_BLOCK before the program is started.'
MEMORY_BLOCK 00,32000,Cover
Result: As soon as the program executes the MEMORY_BLOCK command, the physical address of the image 'cover' is placed in the variable. If the image has a suitable format (6 byte headers as described for BITBLT), it can be displayed on the screen afterward (e.g., as background for a game).


Type: Command
Syntax: MEMORY_MOVE[B] <source address>, <length>TO <target address>
Explanation: Copying a memory area is best accomplished using the MEMORY_MOVE command. The memory part that begins with <source address> and is <length> long is copied to the <target address>. MEMORY_MOVEB has the same function as MEMORY_MOVE and is only supplied for reasons of compatibility.

Note: Copying speed is at its highest if source and target addresses are on an 8-byte limit.
Example: Buffer=MEMORY(20000)
MEMORY_MOVE Buffer+15000,5000 TO Buffer
Result: Starting at the end of the buffer, 5000 bytes are copied to the beginning.


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

Type: Command
Syntax: MID$(<string variable>,<num.expression>,<num.expression>)= <string expression>
MID$(<string variable>,<location>,<amount>)=<string expression>
Explanation: Allocates the string expression to the string variable starting from the specified location, namely the max. indicated number of characters. The length of the string variable is not changed.
Example: Program$="Omikron Basic"
PRINT Program$
Result: Omikron-Basic
See also: MID$ as function   RIGHT$   LEFT$ 


Type: Function
Syntax: MID$(<string expression,<num.expression>[,<num.expression>])
MID$(<string expression>,<location>[,<length>])
Explanation: Returns a partial string of the string expression starting at the indicated location with the indicated length. If <length> is omitted or greater than the remaining part of the string expression, the partial string ends at the end of the string expression.
Example: A$="Omikron Basic"
PRINT MID$(A$,6,7)
PRINT MID$("abcdefg",4)
Result: on Basi
See also: MID$ as command   LEFT$   RIGHT$ 

Type: Function
Syntax: MIN (<expression>,<expression>)
Explanation: Returns the lesser of the two expressions as a functional value. Comparisons between numerical and string expressions are not permitted.
Example: PRINT MIN(-6,0), MIN(7,7.1)
Result: -6 7
See also: MAX

Type: Function
Syntax: MIRROR$(<string expression>)
Explanation: Reflects the given string expression. The first character is exchanged with the last, the second with the next to the last one, etc.
Example: PRINT MIRROR$("12340")
Result: 04321


Type: Function
Syntax: MKD$(<num.expression>)
Explanation: Converts the numerical expression into a double floating number, followed by its conversion into a string 8 characters long.
MKD$ is the reverse function of CVD.
Example: Number$=MKD$(PI)
FOR I=1 TO 8
PRINT HEX$(ASC(MID$(Number$,I,1)));
Result: $40 $9 $21 $FB $54 $4 $2D $18
See also: CVD   MKI$   MKIL$   MKS$ 

Type: Command
Syntax: MKDIR <string expression>
Explanation: Creates a new folder. A FileSpecificationRecord must be passed in the <string expression>.
Example: MKDIR FN Get_Fsspec$(0,0,"Macintosh HD:OmikronBasic:Program:")
Result: Creates a new folder with the name 'Program' in the folder 'OmikronBasic'.
See also: RMDIR   CHDIR 

Type: Function
Syntax: MKI$(<num.expression>)
Explanation: Converts the numerical expression into a short integer number, followed by its conversion into a string 2 characters long.
MKI$ is the reverse function of CVI.
Example: PRINT MKI$($5445)+MKI$($5354)
Result: TEST
See also: CVI    MKIL$    MKS$    MKD$


Type: Function
Syntax: MKIL$(<num.expression>)
Explanation: Converts the numerical expression into a long integer number, followed by its conversion into a string 4 characters long.
MKIL$ is the reverse function of CVIL.
Example: PRINT MKIL$($57656C74)
Result: World
See also: CVIL     MKI$     MKS$     MKD$

Type: Function
Syntax: MKS$(<num.expression>)
Explanation: Converts the numerical expression into a single floating number, followed by its conversion into a string 4 characters long.
MKS$ is the reverse function of CVS.
Example: Number$=MKS$(PI)
FOR I=1 TO 4
 PRINT HEX$(ASC(MID$(Number$,I,1)));
Result: $40 $49 $F $DA
See also: CVS   MKD$   MKI$   MKIL$ 


Type: Operator
Syntax: <num.expression>MOD<num.expression>
Explanation: Determines the remainder of a division resulting from the first numerical expression being divided by the second numerical expression. Of course, the factor must not be equal to 0. The operational sign corresponds to that of the first expression.
Example: PRINT 10 MOD 3,-20 MOD 7,15 MOD -6
Result: 1 -6 3
See also: Mathematical Operators

Type: Command
Syntax: MODE <string expression>
MODE <country identification>

Controls the country-specific mode.
Possible preference settings are as follows:

"D" for Germany,
"GB" for Great Britain,
"I" for "Italy",
"F" for France, and
"USA" for United States of America.

The country settings affect the conversion of lowercase to uppercase letters and vice versa when using LOWER$ and UPPER$.

Example: MODE "D"
Result: ÄÖÜ


Type: Command
Syntax: MODE= <num.expression>
MODE= <draw mode>
Explanation: Controls the draw mode for all graphics commands.
Possible settings are as follows:

1: opaque
2: transparent
3: XOR
4: reverse transparent

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

Type: Function
Explanation: Specifies the status of the mouse button while also considering the status of the modifier keys. Accordingly, the function returns values between 0 and 32 such as the following examples:

MOUSEBUT = 1 if only mouse button is pressed
MOUSEBUT = 2 if mouse button and Command key is pressed
MOUSEBUT = 3 if mouse button and Shift key is pressed
and so forth.

Therefore, the functional value of MOUSEBUT results from the value of the modifier keys (see description of INKEY$) + 1 for the pressed mouse button.

Note when using a mouse with two or three buttons:
Program your multiple button mouse in such a way that the second mouse button works like [Cmd]+[Return] and the third like [Alt]+[Return]. Then you will receive values between 0 (no button pressed) and 7 (all three buttons pressed) when using MOUSEBUT. Of course, you can also assign a double-click to the middle button and use the right mouse button as the second button or assign any other desired combination.
Example: PRINT "End with any key"
Result: In the third line, the program displays the respective status of the mouse button and modifier keys.
See also: MOUSEX   MOUSEY 

Type: Command
Explanation: Deactivates the mouse (the mouse cursor is no longer visible).
See also: MOUSEON

Type: Command
Explanation: Activates the mouse (the mouse cursor is visible again).
See also: MOUSEOFF


Type: Function
Syntax: MOUSEX
Explanation: Returns the X-coordinate of the mouse position. In this case, it is unimportant whether the mouse is currently displayed or not.
Example: PRINT "End with any key"
Result: In the third line, the program displays the current X-position and the current Y-position of the mouse cursor is being displayed in the fourth line.

Type: Function
Syntax: MOUSEY
Explanation: Returns the Y-coordinate of the mouse position. In this case, it is unimportant whether the mouse is currently displayed or not.
Example: PRINT "End with any"
Result: In the third line, the program displays the current X-position and the current Y-position of the mouse cursor is being displayed in the fourth line.


Type: Command
Syntax: NAME <string expression>AS <string expression>
NAME <file name/old>AS <file name/new>
Explanation: The <file name/old> must contain a FileSpecificationRecord. <File name/new> may only contain the new name. If a directory is supposed to be renamed, the names must be concluded with a colon.
Example: NAME FN Get_Fsspec$(0,0,"Old_Name") AS "New_Name"
NAME FN Get_Fsspec$(0,0,"Old_Folder:") AS "New_Folder:"
Result: The file 'Old_Name' is renamed to 'New_Name'. The folder 'Old_Folder' is renamed to 'New_Folder'.
See also: COPY   BACKUP 


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


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


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

Type: Command
Syntax: NEXT [<num.variable>]
NEXT [<loop variable>]
Explanation: Terminates a FOR ... NEXT loop. If no loop variable is specified, NEXT always refers to the last FOR.
See also: FOR    UNTIL    WEND 

5-6. INPUT$- LPRINT Contents | 5-8. NOISE - POKE

Tech-Support | Order | Start | Home:

© 1997-2001 Berkhan-Software