|
Chapter 5-2 |
ABS | |
Type: | Function |
Syntax: | ABS(<num.expression>) |
Explanation: | ABS computes the absolute value of the numerical expression. Negative values thus receive a positive sign while positive values remain unchanged. |
Example: | A=-5.2 PRINT A PRINT ABS(A) PRINT ABS(A+3.2)+3.2 |
Result: | -5.2 5.2 5.2 |
AES | |
Explanation: | Has no application purpose in Omikron Basic Mac and is ignored by the compiler. Please, do not use. |
AND | |
Type: | Operator |
Syntax: | <num.expression>AND<num.expression> |
Explanation: | The expressions are linked with the logical Boolean operator AND, which takes two values, resolving to a single value. |
Example: | PRINT BIN$(%1010 AND %1100) IF 1<2 AND 2<3 THEN PRINT "I knew it!" IF 1<4 AND 2=4 THEN PRINT "That's wrong!!!" |
Result: | 1000 I knew it! |
See also: | OR NOR NAND XOR IMP EQV |
ARCCOS | |
Type: | Function |
Syntax: | ARCCOS(<num.expression>) |
Explanation: | Calculates the arcus cosine of the numerical expression. The numerical expression must have a value between -1 and 1. The result is dependent on the adjusted angle mode. |
Example: | PRINT ARCCOS(-0.5) DEG PRINT ARCCOS(1) |
Result: | 2.0943951023932 0 |
See also: | DEG RAD |
ARCCOT | |
Type: | Function |
Syntax: | ARCCOT(<num.expression>) |
Explanation: | Calculates the arcus cotangent of the numerical expression. The result is dependent on the adjusted angle mode (see DEG, RAD). |
Example: | PRINT ARCCOT(5) DEG PRINT ARCCOT(1) |
Result: | 0.197395559849881 45 |
See also: | DEG RAD |
ARCOTH | |
Type: | Function |
Syntax: | ARCOTH(<num.expression>) |
Explanation: | Calculates the area (inverse) hyperbolic cotangent of the numerical expression. The numerical value must be outside of the number interval -1 to 1. |
Example: | PRINT ARCOTH(5) |
Result: | 0.202732554054082 |
ARCSIN | |
Type: | Function |
Syntax: | ARCSIN(<num.expression>) |
Explanation: | Calculates the arcus sine of the numerical expression. The numerical expression must have a value between -1 and 1. The result is dependent on the adjusted angle mode. (See also, DEG, RAD) |
Example: | PRINT ARCSIN(1) DEG PRINT ARCSIN(0.5) |
Result: | 1.5707963267949 30 |
ARCTAN | |
Type: | Function |
Syntax: | ARCTAN(<num.expression>) |
Explanation: | Calculates the arcus tangent of the numerical expression. ARCTAN is identical to ATN. The result is dependent on the adjusted angle mode. |
Example: | PRINT ARCTAN(-1) DEG PRINT ARCTAN(1) |
Result: | -0.785398163397448 45 |
ARSINH | |
Type: | Function |
Syntax: | ARSINH(<num.expression>) |
Explanation: | Calculates the area (inverse) hyperbolic sine of the numerical expression. |
Example: | PRINT ARSINH(-1) |
Result: | -0.881373587019543 |
ARTANH | |
Type: | Function |
Syntax: | ARTANH(<num.expression>) |
Explanation: | Calculates the area (inverse) hyperbolic tangents of the numerical expression. The numerical expression must have a value between -1 and 1. |
Example: | PRINT ARTANH(0.5) |
Result: | 0.549306144334055 |
AS | |
Explanation: | see NAME...AS |
ASC | |
Type: | Function |
Syntax: | ASC(<string expression>) |
Explanation: | Determines the ASCII value of the first character of the string expression. ASC is
the reverse function of CHR$. For more information, turn to the
ASCII table in the appendix. Caution: If A$ is an empty string, the call ASC(A$) returns zero if the nonfatal error messages have been turned off (Error_messages 0) and leads to the message "Illegal function call" if not. |
Example: | PRINT ASC("abc") PRINT ASC( CHR$(24)) |
Result: | 97 24 |
See also: | CHR$ |
ATN | |
Type: | Function |
Syntax: | ATN(<num.expression>) |
Explanation: | Calculates the arcus tangent of the numerical expression. ATN is identical to ARCTAN. The result is dependent on the adjusted angle mode (see DEG, RAD). |
Example: | PRINT ATN(-1) DEG PRINT ATN(1) |
Result: | -0.785398163397448 45 |
BACKUP | |
Type: | Command |
Syntax: | BACKUP(<string expression>) BACKUP(<file name>) |
Explanation: | Creates a backup copy from a file. The backup copy receives the extension "BAK"
and is posted in the same folder. The FileSpecificationRecord
must contain such a <file name> as it is returned e.g., from FILESELECT
or FN Get_Fsspec$ from
the Extension Library. Wildcard characters are not permitted in the file. If the file cannot be found, the command is cancelled. An error message is issued if Error_Messages is activated. |
Example: | BACKUP Fn GetFsspec$(0,0,"OmikronBasic") |
Result: | A file copy with the name OmikronBasic.BAK is generated from the file OmikronBasic. |
See also: | COPY |
BIN$ | |
Type: | Function |
Syntax: | BIN$(<num.expression>) |
Explanation: | The numerical expression is converted into a character string, which represents the rounded value of the expression as a binary number. First, the numerical expression is always converted to the long integer format. A value with a too large amount generates an "Integer overflow" error message, if the FPU Exceptions were previously activated with the compiler control word "FPUEXON." |
Example: | PRINT BIN$(4) PRINT BIN$(24) PRINT BIN$(1E+10) |
Result: | %100 %11000 Integer overflow in line no. 2 |
See also: | OCT$ HEX$ STR$ VAL |
BIOS | |
Explanation: | Has no application purpose in Omikron Basic Mac and is ignored by the compiler. Please, do not use. |
BIT | |
Type: | Function |
Syntax: | BIT(<num.expression>,<num.expression>) BIT(<bit number>,<value>) |
Explanation: | The rounded value is converted to a 32-digit binary number. If the amount of a value
is too large, it will generate the error message "Integer overflow" if
the FPU exceptions were turned on with the compiler control word "FPUEXON."
The function returns -1, if the bit on the right of the binary number is set, otherwise,
0. The bit with the lowest value has the number 0. The bit with the highest value
has the number 31 and represents the sign in case of signed numbers. An erroneous bit number generates the error message "Illegal vunction call" if monitoring of the range control was previously activated using COMPILER "RCON." |
Example: | PRINT BIT(0,1) PRINT BIT(2,1) PRINT BIT(31,-1) PRINT BIT(12,-1) |
Result: | -1 0 -1 -1 |
See also: | BIT as a command |
BIT | |
Type: | Command |
Syntax: | BIT(<num.expression>,{<integer variable>|(<num.expression>)})
=<num.expression> BIT(<bit number>,{<integer variable>|(<memory address>)})=<bit value> |
Explanation: | Assigns the value zero (0) to an individual bit, if the <bit value> equals
zero, otherwise the value one (1). The bit is indicated by the <bit number>.
The bit with the lowest value has the bit number zero. Bits can be changed either
by integer variables or by the memory. Important: If the memory has undergone any changes, any access will occur byte-wise, i.e., the highest bit number is 7. However, when modifying integer variables, bit numbers up to 31 are permitted. An erroneous bit number generates the error message "Illegal function call" if range control monitoring was previously activated using COMPILER "RCON." |
Example: | Address=MEMORY(1) PRINT PEEK(Address) BIT (2,(Address ))= 1 PRINT PEEK(Address) A=19 BIT (2,A)=0 PRINT A |
Result: | 0 4 17 |
BITBLT | |
Type: | Command |
Syntax: | BITBLT<num.expression>[,<num.expression>,<num.expression>,<num.expression>]
TO <num.expression>[,<num.expression>,<num.expression>,<num.expression>]
[;<num.expression>] BITBLT <num.expression>TO <num.expression>,COLOR <num.expression> 1: BITBLT <X1>,<Y1>,<width>,<height> TO <X2>,<Y2>,<width2>, <height2>[;<mode>] 2: BITBLT <X>,<Y>,<width>,<height>TO <memory address>[;<mode>] 3: BITBLT <memory address>TO <X>,<Y>,<width>,<height>[;<mode>] 4: BITBLT <memory address1>TO <memory address2>,COLOR <color> |
Explanation: | Copies a rectangular screen section depending on syntax: 1: from screen to screen 2: from screen to memory 3: from memory to screen 4: from memory to memory Source and target oblongs can differ in size. The source image is modified by the command in such a way as to fit it exactly into the target oblong. Therefore, the BITBLT command can also be used for the purpose of enlarging, reducing, or distorting images. In the case of syntax 1 to 3, the specification of a mode is possible as well, which allows for a point by point linking of the image information between source and target: MODE 0: Target = Source MODE 1: Target = Source AND Target MODE 2: Target = NOT (Source XOR Target) MODE 3: Target = NOT Target OR Source MODE 4: Target = NOT Source MODE 5: Target = NOT Target AND Source MODE 6: Target = Source XOR Target MODE 7: Target = Source OR Target MODE 32: Target = (Source + Target)\2 MODE 33: Target = MIN($FFFF, Source + Target) MODE 34: Target = (Source + Target) MOD $FFFF MODE 35: Target = MAX(0, Source - Target) MODE 36: Target = Source, if source is not white (transparent mode) MODE 37: Target = MAX(Source, Target) MODE 38: Target = (Source - Target + $FFFF) MOD $FFFF MODE 39: Target = MIN (Source, Target) Each Source and Target represent a 6-byte RGB Record whereby R=Red, G=Green, and B=Blue can consist of values between 0 and $FFFF. If the specification <mode> is omitted, the process is performed according to 'MODE 0'. Any bit block transfer send to the screen takes a defined graphics window into consideration (see CLIP). In the syntax BITBLT Adr1 TO Adr2, COLOR P indicates P, how many color planes the target image should have. Therefore, this command can be used in order to modify the pixel depth of an image. The memory requirements for a BITBLT to memory can be calculated as follows: Memory requirement = 6+((width+15) * height * color planes) SHR 3 The leading three words consist of the following: 1. Number of color planes 2. Width in pixels 3. Height in pixels |
Example: | Screen_Buffer= MEMORY(6+((60+15)*40*8) SHR 3):'with
256 colors PELLIPSE 50,50,30,20 BITBLT 25,20,50,50 TO Screen_Buffer WAIT .5 CLS BITBLT Screen_Buffer TO 20,20,50,50 WAIT .5 BITBLT 20,20,50,50 TO 20,30,50,50,6 WAIT .5 PCIRCLE 45,55,8 |
Result: | First, a screen buffer is created using MEMORY. After this, an ellipse is drawn and transferred to the buffer using BITBLT. After the screen was cleared, the ellipse is now again loaded from the buffer and then once again copied to the screen. Finally, a circle is drawn. |
See also: | BLOAD BSAVE |
BLOAD | |
Type: | Command |
Syntax: | BLOAD <string expression>[,<num.expression>] BLOAD <file name>[,<start address>] |
Explanation: | The indicated file is loaded into memory commencing at the start address. If this
expression is missing, the output is directed to the screen (logical screen address)
and to the uppermost Omikron Basic output window (if one is open), respectively.
In this case, width, height, and pixel depth are adapted automatically. For this
purpose, the file must be available in the PICT format such as it is e.g., automatically
created by BSAVE. PICT files created with other programs can
be loaded with BLOAD as well. Caution: You have to take care, that enough memory is reserved at <start address> for receiving the whole file. Otherwise a crash would be propably the result. |
Example: | Mem= MEMORY(100) BLOAD FN Get_Fsspec$(0,0,"EXAMPLE.DAT"),Mem |
Result: | Memory is first reserved. The file EXAMPLE.DAT is then loaded into memory. |
See also: | BSAVE BITBLT |
BOX | |
Type: | Command |
Syntax: | BOX <num.expression>,<num.expression>{TO <num.expression>,<num.expression>|,<num.expression>,<num.expression>}
BOX <X>,<Y>{TO <X2>,<Y2>|<width>,<height>} |
Explanation: | Draws an unfilled oblong on the screen. Hereby, either two opposite corners are to be indicated or a corner, width, and height of the oblong. Color, line style, and width can be determined using LINE COLOR, LINE STYLE, and LINE WIDTH respectively. A window defined by CLIP, is not drawn outside of this area. |
Example: | BOX 20,30,70,40 |
Result: | Draws an oblong |
See also: | PBOX PRBOX RBOX |
BRK | |
Type: | Command |
Syntax: | BRK |
Explanation: | This command is used exclusively for the error location in compiled programs. It triggers a jump in the compiled product to the debugger. Of course, that is only possible if a debugger was started before, otherwise, the Mac crashes with the message "Unimplemented Trap." This command offers the opportunity to interrupt a program at a specific location so as to initiate the search for errors with a debugger on an object code level. |
BSAVE | |
Type: | Command |
Syntax: | BSAVE <string expression>[,<num.expression>,<num.expression>]
BSAVE <file name>[,<start address>,<length>] |
Explanation: | Saves the memory area starting at <start address> under the <file name>. If <start address> and <length> are missing, the screen and the uppermost Omikron Basic output window, respectively, are stored instead. In this case, the save procedure occurs in the PICT format, whereby it is possible to load the image to any graphics port with BLOAD or to process it further with another program. |
Example: | BSAVE FN Get_Fsspec$(0,0,"Screen.PICT") |
Result: | The contents of the screen buffer are transferred to the file Screen.PICT. |
See also: | BITBLT BLOAD |
CALL | |
Type: | Command |
Syntax: | CALL <num.variable>[(][L ]<num.expression>][[, [L ]<num.expression>]])] |
Explanation: | A machine language subroutine is called. The start address is supplied by the numerical
variable. The following expressions are passed to the stack in reverse order, i.e.,
the first parameter is at the bottom of the stack, that is, at "0,R31".
The expressions may be preceded by an "L" in order to pass the appropriate
parameter as long integers. Otherwise, a short integer is always passed. Only those registers declared by Apple as 'volatile' may be modified. They are as follows: R0,R3-R12 FPR0-FPR13 CR0,CR1,CR5-CR7 R31 points to the dynamic stack on which the passed parameters are located. The program must end with 'Blr'. If the link register is modified, it is to be ensured that it is restored again before the return. At the completion of the machine program, the contents of R3 can be loaded with RESERVED(0). Errors caused by the machine program cannot be intercepted by Omikron Basic. Therefore, starting a suitable debugger in the test phase first is recommended. |
Example: | Test$ = "CFSLIBO.TPGUXBSF" CALL Decode (L &Test$, 1) 'Pass pointer to Test$ and "1" PRINT Test$ 'The machine program was created with the Assembler Library. Lwz R6,0,R31:'Load pointer to string Lhz R4,4,R31:'Load parameter (the "1") Lwz R7,0,R6:'Generate pointer to string segment Lwz R3,4,R6:'Length of string Subi R7,R7,1 Mtctr R3 Label "loop":Lbz R5,1,R7:'Load a character of the string Sub R5,R5,R4:' Modify character Stbu R5,1,R7:'And return character Bdnz_L "loop":'For all characters of the string Blr |
Result: | BERKHAN-SOFTWARE |
See also: | CALLR USR INLINE |
CALLR | |
Type: | Command |
Syntax: | CALLR <num.variable>[(]<num.expression>][[, <num.expression>]])] |
Explanation: | A machine language subroutine is called. The start address is defined by the numerical
variable. Contrary to CALL, parameters used with CALLR are not passed on the stack
but in the registers. Numerical expressions with an integer type result are then
consecutively written to the registers R3 to R12, while registers FPR1 to FPR13 are
used for floating point values. If more parameters than available registers are passed,
the compiler issues a warning. The excess parameters are ignored. Only registers declared 'volatile' by Apple may be changed. They are as follows: R0,R3-R12 FPR0-FPR13 CR0,CR1,CR5-CR7 R31 points to the dynamic stack. The program must be concluded with 'Blr'. If the link register is modified, it has to be restored again before the return. After the machine program has finished, the contents of R3 can be loaded with RESERVED(0) . Omikron Basic cannot intercept errors caused by your machine program. It is therefore recommended to start a suitable debugger in the test phase first. CALLR is quicker than CALL and thus should be used preferably. |
Example: | X#=1.2:Y#=5.5:M=3:N=5 CALLR Power(X#,M,Y#,N,&R#) PRINT "X#^M + Y#^N =";R# 'The machine program was generated with Assembler Library. Subi R3,R3,1:Mtctr R3 Fmr Fp3,Fp1 Fmul Fp3,Fp3,Fp1:'calculate X#^M. Bdnz -4 Subi R4,R4,1:Mtctr R4 Fmr Fp4,Fp2 Fmul Fp4,Fp4,Fp2:'calculate Y#^N. Bdnz -4 Fadd Fp0,Fp3,Fp4 Stfd Fp0,0,R5:'Post result in R# (R5 contains pointers to R#). Blr :'Jump back |
Result: | 5034.57175 |
See also: | CALL USR INLINE |
CASE | |
Type: | Command |
Syntax: | CASE <expression>[TO <expression>][[,<expression> [TO <expression>]]] |
Explanation: | Within a SELECT ... CASE statement, CASE introduces a partial branch. This program branch is then carried out if one of the indicated possibilities applies to the variable mentioned in the case of SELECT. Several possibilities are simply listed separated by commas. Intervals are also possible using TO. In the case of strings, only the first 4 bytes are parsed. |
See also: | SELECT DEFAULT OTHERWISE |
CDBL | |
Type: | Function |
Syntax: | CDBL(<num.expression>) |
Explanation: | Converts any numerical expression to a double precision floating point format. |
Example: | A!=1 B!=3 PRINT CDBL(A!/B!) PRINT CDBL(A!)/CDBL(B!) |
Result: | 0.333333333333333 0.333333333333333 |
See also: | CINT CINTL CSNG |
CHAIN | |
Explanation: | Has no application purpose in Omikron Basic Mac and is ignored by the compiler. Please, do not use. |
CHDIR | |
Type: | Command |
Syntax: | CHDIR <string expression> |
Explanation: | Changes the default path to the path indicated in <string expression>. Such a FileSpecificationRecord must be passed to the command as is returned e.g., by FILESELECT or FN Get_Fsspec$ from the Extension Library. |
Example: | CHDIR FN Get_Fsspec(0,0,"MacintoshHD:Omikron Basic:Programe:") |
Result: | The specified path becomes the current path. |
CHR$ | |
Type: | Function |
Syntax: | CHR$(<num.expression>) |
Explanation: | Generates a string one character in length in accordance with the ASCII table. CHR$ is the reverse function of ASC. For more information, see the ASCII table in the appendix. |
Example: | PRINT CHR$(7):'Triggers the system beep PRINT CHR$(80); CHR$(76) |
Result: | PL (indicates a short sound is emitted.) |
See also: | ASC |
CINT | |
Type: | Function |
Syntax: | CINT(<num.expression>) |
Explanation: | Converts any numerical value to the short integer format (integers of -32768 to +32767). Of course, the definition range of the function especially encompasses the range of short integer numbers. Other values lead to the error message "Integer overflow" if range control monitoring was previously activated using COMPILER "RCON." |
Example: | A=1 B=3 PRINT CINT(A/B) PRINT CINT(A)/CINT(B) PRINT CINT(40000) |
Result: | 0 0.333333333333333 Integer overflow in line no. 4 |
CINTL CSNG CDBL | |
Tech-Support | Order | Start | Home: http://www.berkhan.com |
© 1997-2004 ![]() |