Omikron BASIC for Apple Power Mac

5-2. ABS - CINT Contents | 5-4. DEFDBL - FIX

 

Chapter 5-3

The Command Set

CINTL - DEF USR

 

CINTL
Type: Function
Syntax: CINTL(<num.expression>)
Explanation: Converts any numerical value to a long integer format (integers of -2147483648 to +2147483647). The definition range of the function encompasses the number range of long integers. Other values lead to the error message "Integer overflow" if the floating point exceptions were previously activated using COMPILER "FPUEXON."
Example: A=1
B=3
PRINT CINTL(A/B)
PRINT CINTL(A)/CINTL(B)
PRINT CINTL(1E+10)
Result: 0
0.333333333333333
Integer overflow in line no. 4
See also: CDBL  CINT  CSNG 
   
 

CIRCLE
Type: Command
Syntax: CIRCLE <num.expression>,<num.expression>,<num.expression>[,<num.expression>, <num.expression>]
CIRCLE <X>,<Y>,<radius>[,<start angle>,<end angle>]
Explanation: Draws an unfilled circle on the screen. <X> and <Y> specifies the center of the circle. Start and end angles can be indicated in one tenth of a degree. Angle=0 is to the right of the center, angle=900 is above the center, etc.
Color, line style, and width can be determined using LINE COLOR, LINE STYLE and LINE WIDTH respectively. If a window is defined by means of CLIP, nothing is drawn outside of this area.
Example: CIRCLE 70,50,40
CIRCLE 70,50,30,0,1800
CIRCLE 60,50,20,1800,3200
CIRCLE 70,50,25,500,600
CIRCLE 70,50,25,1200,1300
Result: Various circles and arcs of circles are drawn on the screen.
See also: ELLIPSE   PCIRCLE   PELLIPSE 
   

 

CLEAR
Type: Command
Syntax: CLEAR [<num.expression>][,<num.expression>]
CLEAR [<heap memory>][,<stack size>]
Explanation: Deletes contents of all variables and the dimensioning. Open files are closed; any data perhaps still present in the printer buffer are output; ON ERROR GOTO, ON HELP GOSUB, ON MOUSEBUT GOSUB, ON KEY GOSUB, and ON TIMER GOSUB calls are disabled. In Omikron Basic 6, this command is only significant without a parameter. Please, you use the corresponding compiler control words in order to adjust the size of the heap memory and/or stack.
See also: COMPILER "PRE_SIZE X"      COMPILER "STACK X"
   

 

CLIP
Type: Command
Syntax: CLIP [<num.expression>,<num.expression>{TO <num.expression>,<num.expression>|,<num.expression>,<num.expression>}]
CLIP [<X>,<Y>{ TO <X2>,<Y2>|,width,heigth}]
Explanation: Defines a graphics window, which limits the drawing range for the following draw commands: BITBLT, BOX, CIRCLE, DRAW, ELLIPSE, FILL, PBOX, PCIRCLE, PELLIPSE, POLYGON, PPOLYGON, PRBOX, RBOX, TEXT, PRINT, WRITE
Outside of this window, the drawing is still executed, but the screen remains unchanged.
The window can be defined either by means of specifying two opposing corner points or by indicating one corner point with width and height. Are no parameters indicated, the graphics window is disabled (this is also the default setting).
Example: CLIP 30,30,20,20
PCIRCLE 30,30,20
CLIP 60,60 TO 150,100
PRBOX 65,65,200,200
Result: A circle limited by CLIP and a limited rectangle are drawn.
   

 

CLOSE
Type: Command
Syntax: CLOSE [<num.expression>[[<num.expression>]]]
CLOSE [<file number>[[<file number>]]]
Explanation: Closes the file(s) associated with this file number. Without specification of parameters, all files will be closed.
Example: CLOSE
CLOSE 1,7,Om
Result: Closing file(s).
See also: OPEN
   
 


CLS
Type: Command
Syntax: CLS
Explanation: The entire screen is cleared and the PRINT cursor is set to its home position (upper left corner).
Example: PELLIPSE 50,50,40,20
WAIT .5
CLS
Result: First, an ellipse is drawn. After 0.5 seconds, the screen is cleared again.
   
 


CMD
Type: Function
Syntax: CMD <num.expression>
CMD <file number>
Explanation: Redirects output of PRINT and WRITE to a file. The file corresponding with the file number has to be opened first using OPEN. Due to the option to print files on a printer (see OPEN), the output can also be rerouted to the printer or serial interface. If the numerical expression equals zero, the output is displayed on the screen again.

Note: Working with MacOS, printers are usually not selected directly. If screen information is supposed to be rerouted to the printer, the command GRAF_PORT 1 should be used.
Example: OPEN "O",3,FN Get_Fsspec$(0,0,"Macintosh HD:CMDTest")
CMD 3
PRINT "This text will now be written to file."
CMD 0
Result: First, a file is opened via channel 3; using CMD 3 all output is redirected to this file. As a result, the text behind PRINT no longer appears on the screen but is written to the file.
See also: GRAF_PORT
   
 


COLOR
See also: BITBLT    LINE COLOR    FILL COLOR   TEXT COLOR
   

 

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

 

COMPILER as command
Type: Command
Syntax: COMPILER {OFF|ON|<string expression>}
Explanation: Program parts located between COMPILER OFF and COMPILER ON are not translated during the compilation procedure and are thus eliminated from the program. Control words can be passed to the compiler in <string expression>.

Important: In order to receive a securely executable compilation product, some of the following control words should be utilized at the beginning of every program (for more information, see the program 'Mandelbrot.BAS' in the folder DEMO).

The following control words are possible:

COMPILER "BAS_MEM X"
This setting informs the compiler of the required amount of basic memory. X represents the necessary number of bytes. If this control word is absent, a value of 262144 is assumed.

COMPILER "CONST_IF_EXCLUDE" or COMPILER "CIE"
This compiler control word allows for the omission of redundant program parts when compiling.
This means the following:
Whenever an IF condition returns a constant value, if therefore the condition is either always or never true, the part that is not used and thus superfluous, is simply left out completely. In connection with constants (see DEF_CONST), this allows for the translation of a program in different ways. The constants act as switches, which control compilation depending on the allocated value. For example, a constant called "Demo" would be conceivable, which - if unequal to zero - excludes certain parts of the program. Those parts of the program that do not appertain to the demonstration version are then not translated at all, which makes it impossible to convert a demo version back to a full release version. In a similar way, it is also possible to create multilingual program versions. They, depending of the "language" constant, always contain the correct, country-specific texts and subprograms.

COMPILER "CONST_IF_INCLUDE or COMPILER"CII"
Reactivates the normal processing of not utilized IF branches. Therefore, everything is always translated. This is also the default value of the compiler.

COMPILER "CTRL_C ON|OFF"
This can be used to determine whether the compiled program can be aborted at any time using the key combination [CTRL]+[C] or not. The default value is CTRL_C OFF.

COMPILER "CUT_ON|OFF"
If CUT is on, the compiler truncates all functions and all procedures, which are not used anywhere in the program. A prerequisite for this task is that all procedures and functions are clearly separated, i.e., each is marked with END_PROC and/or END_FN. Procedures and functions can also be concluded with RETURN. In this case, the first unconditional RETURN, which is not located behind an IF, is regarded as the end.

COMPILER "DEBUG ON|OFF"
This control word is a summary of "IUEX", "FPUEX", "RC", and "SC". In the case of redesigned programs, we recommend urgently to set this control word. Omikron Basic will then notify the user of program errors (e.g., division by zero, fields dimensioned too small, stack calculated too small, false variable type in the case of READ, etc.). If such errors are not detected, eventually this will usually result in a crash without the actual reason for the crash becoming apparent.

Note: Placement of this control word will extend the length of your program and decreasing execution speed since certain checks are performed constantly throughout. However, this is a small inconvenience, which should be accepted during the developmental phase to produce a product that is as error-free as possible.

COMPILER "DEF_CONST"
This control word introduces a constant definition. All subsequent allocations to individual variables (fields and strings are not allowed!) are now defining a constant. The use of such constants has several advantages:

1. Such symbolic names are easier to read than "true" constant expressions and can also be changed more easily since they are assigned only once.

2. If the constant expressions are calculations, they can indeed be executed and replaced by the compiler. This results in a shorter and faster compilation product.

3. Conditional compilation with CONST_IF_EXCLUDE and CONST_IF_INCLUDE is simplified by the use of constants: If different program versions feature individual parts of the program that are to be compiled under specific but identical conditions, then the constant has to be modified only once when it is being declared.
Constants should always be defined at the beginning of the program code; however, not until after the first CLEAR. Of course, as the name implies, constants may be allocated only one value once in the entire program.

COMPILER "END_CONST"
This compiler control word must be at the end of a constant declaration, which has been commenced with DEF_CONST.

COMPILER "EVENT"
If the Omikron Basic output window is active, a 'WaitNextEvent' is compiled into the program at this point.

COMPILER "FILE_TYPE XXXX" 
Each file on a Mac computer has a specific type consisting of 4 characters. Under normal circumstances, Omikron Basic generates executable programs of the "APPL" type. However, if you would like to write, for example, a shared library, a plugin, or a system extension, you have to assign the file an appropriate type. System extensions have the type "INIT," shared libraries "shlb," and for plugins the type depends on the program with which it is to be used.


COMPILER "FPU_EXCEPTIONS ON|OFF" or COMPILER "FPUEXON|OFF"
If the floating point unit reports an exception in the processor, e.g., if the result of an arithmetic operation is a not representable number or an invalid operation occurred, a warning is issued.

Note: Placement of this control word will extend the length of your program and decrease execution speed since certain checks are performed constantly throughout. However, this is a small inconvenience, which should be accepted during the developmental phase to produce a product that is as error-free as possible.

COMPILER "IU_EXCEPTIONS ON|OFF" or COMPILER "IUEXON|OFF"
If the integer unit reports an exception in the processor such as e.g., "Integer overflow" or "Division by Zero", a warning is issued.

Note: Placement of this control word will extend the length of your program and decrease execution speed since certain checks are performed constantly throughout. However, this is a small inconvenience, which should be accepted during the developmental phase to produce a product that is as error-free as possible.

COMPILER "LIB_MAKER ON|OFF"
This control word is ignored by the compiler and is only evaluated by the Library Maker.

COMPILER "MEMORY_MOVE_BACK" or COMPILER "MMB"
MEMORY_MOVE now copies memory blocks from the back to the front. The copy direction is important if source and target area overlap.

COMPILER "MEMORY_MOVE_FORWARD" or COMPILER "MMF"
MEMORY_MOVE now copies memory blocks from the front to the back. This is also the default setting. The copy direction is important if source and target area overlap.

COMPILER "MIN_SIZE X"
X specifies, the minimum size of the application heap that must be allocated to your program after its initial start in order to ensure that it will even load and run. Please, remember that e.g., the Omikron Basic output window is buffered in the application heap. If this control word is omitted, a default value of 262144 bytes is registered. This setting can also be effected using the finder via the menu point 'Get Info'.

COMPILER "NO LINENUMBERS" or COMPILER "NOLNR"
In order to determine affinity of a program location with a specific line in the case of an error or for RESUME (see also TRACE ON), it is common procedure to create a table. This requires 6 bytes per line and consequently extends larger programs by some Kbytes. The creation of this table can be suppressed with NO LINENUMBERS. However, determining a specific line is impossible without this table; in the case of an error, the line number 0 will then always be returned. The line number table should thus not be suppressed during the developmental phase of the program.

COMPILER "OUTPUT_WINDOW X*Y" or COMPILER "OPW X*Y"
The Omikron Basic Output Window is set up with the width X and the height Y.

Caution: This control word must be specified using SCREEN, if additional Omikron Basic output windows are to be opened or if the pseudo multitasking operation commands ON TIMER, ON MOUSEBUT, etc. should be used.

COMPILER "PRE_SIZE X"
X specifies the preferred size of the application heap that should be allocated to your program after its initial start. Please, remember that e.g., the Omikron Basic output window is buffered in the application heap. If this control word is omitted, a default value of 262144 bytes is registered. This setting can also be effected using the finder via the menu point 'Get Info'.

COMPILER "RANGE_CONTROL ON|OFF" or COMPILER "RCON|OFF"
Anytime a field variable is accessed during the execution of your program, it is checked whether the indicated indices are located within the dimensioned range. In addition, care is taken that the bit number for the BIT command has a permissible value and that the argument lies in the permitted number range when using CINT. If not, the program aborts with an error message.

Note: Placement of this control word will extend the length of your program and decrease execution speed since certain checks are performed constantly throughout. However, this is a small inconvenience, which should be accepted during the developmental phase to produce a product that is as error-free as possible.

COMPILER "SHARED_LIBRARY|SHLB" 
The compiler is instructed to generate a so-called shared library instead of an executable program. Such a library consists of the functions (DEF FNEX) and data, which can be called by other programs. Unlike the static Omikron Basic Libraries, which are firmly linked with the respective program, shared libraries can be used by several different programs.
This advantage is countered with the disadvantage of slower executed functions due to the standardized parameter passing and the complex call procedures. Omikron Basic Library functions are executed faster.
If you would like to write plugins, you also have to set this control word and also adjust the file type appropriately with COMPILER "FILE_TYPE XXXX" so that the program for which the plugin is intended can recognize it as such.
See also the sample program "SharedLib.BAS" in the DEMO folder.


COMPILER "SIGNATURE SIGN"
On the Mac, every program receives its own signature, which consists of 4 characters. The MacOS identifies the installed programs with this signature unlike other operating systems that use their name. This means that a newly written program should also be given its own signature. If the program is to be distributed, this signature has to be approved by Apple in order to guarantee uniqueness. Signatures that consist of only lower case letters or contain special characters are reserved for use by Apple itself. If a signature is not specified, four question marks are registered instead.

COMPILER "STACK_CONTROL ON|OFF" or COMPILER "SCON|OFF"
A check is performed during the runtime of the program at the beginning of every program line to ensure sufficient space is left on the stack. If this is not the case, the program aborts with an error message.

Note: Placement of this control word will extend the length of your program and decrease execution speed since certain checks are performed constantly throughout. However, this is a small inconvenience, which should be accepted during the developmental phase to produce a product that is as error-free as possible.

COMPILER "STACK X"
This setting informs the compiler of the required stack size. X represents the necessary number of bytes. If this control word is omitted, a value of 16384 is assumed.

COMPILER "STRING +|*X"
Omikron Basic features effective and efficient string management, which can be customized to the requirements of your program even further using this control word. You can use it to determine how much space is going to be additionally reserved when setting up a string. This additional area prevents repetitious copying processes within the memory area (e.g., if additional characters are added to the string). This increases overall performance significantly.
A plus or multiplication sign may be indicated before the X. In the first case, the amount of bytes set by X are simply added to the length of the string, in the latter case, the length of the string is multiplied with X and the resulting number of bytes is then reserved. In both instances, the result is rounded up to a number divisible by 8.
For example, COMPILER "STRING +64" would cause the command A$="Test-String" in the memory area 11+64=75 being rounded up to a number divisible by 8 = 80 bytes reserved for the string. If it is desired to add additional characters (less than 70) to the string at a later time, it is not necessary to search for and copy the new string to any available memory first; instead, it is simply possible to add the additional characters to the already existing string.
On the other hand, if processing speed is not quite that important to you, but you would rather the program uses a minimal amount of memory (e.g., because you are working with extremely long string fields), you can then use COMPILER "STRING +0" to ensure that only a minimal amount of memory is being utilized. However, numbers are also rounded up to the nearest number divisible by 8 - even in this case. The above listed "Test-String" would therefore occupy 16 bytes.
The default for this control word is COMPILER "STRING *2", which means that twice as much memory as the length of the string is always being reserved.


COMPILER "TRACE ON|OFF" or COMPILER "TRON|OFF"
Before every program line, the keyboard, timer and mouse interrupts are checked. This is an absolute requirement for the pseudo multitasking operation commands ON TIMER, ON HELP, ON KEY, and ON MOUSEBUT. In addition, the current program pointer, and if necessary, the stack pointer as well, are saved. If an error condition should exist, this is the only possible way to identify the line in which an error occurred. During the developmental phase of the program, TRACE ON should always be active, making it possible to locate the erroneous line in the event an error message is issued.

If an individual error routine has been programmed using ON ERROR GOTO and RESUME, TRACE ON must be activated; otherwise, these commands do not function.

Note: Using TRACE ON will extend the length of the program and decrease execution speed.

COMPILER "WARNINGS ON|OFF"
Certain warning messages might be issued during compilation of a program, which are supposed to draw the programmer's attention to possible errors. None of these errors, however, are so grave as to prevent a runable program from being created. Thus, the compilation is not aborted and only a warning is issued. This can be suppressed with WARNINGS OFF.
Example: COMPILER "DEF_CONST"
German%=1
English%=2
Spanish%=3
Language%=German%
COMPILER "END_CONST"
COMPILER "CIE"
IF Language%=German%
THEN PRINT "Wir sprechen Deutsch."
ELSE
IF Language%=English%
THEN PRINT "We speak English."
ELSE
IF Language%=Spanish% THEN PRINT "Hablamos espanol"
ENDIF
ENDIF
COMPILER "CII"
Result: Since the setting was Language%=Deutsch% and "CIE" is activated, only the German part is translated while compiling. The other pointers are skipped and are thus not even in the finished program at all.
See also: COMPILER as a function Program 'Mandelbrot' in the folder DEMO
   
 


COMPILER as a function
Type: Function
Syntax: COMPILER
Explanation: Always returns the value -1 and thus has no practical application purpose in Omikron Basic 6.
Example: IF COMPILER THEN PRINT "Compiler!"
Result: Compiler!
See also: COMPILER as command
   

 

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

 

CONTINUE
Type: Command
Syntax: CONTINUE
Explanation: CONTINUE within a SELECT ... CASES statement skips each next CASE condition and continues execution of the program behind the CASE.
Example:

    A$="Q"
    SELECT A$
    CASE "Q" :PRINT "The character was a Q"
    CONTINUE
    CASE "0" TO "9":PRINT "The character was a digit"
    END_SELECT

Result:

    The character was a Q
    The character was a digit

See also: SELECT CASE

 


COPY
Type: Command
Syntax: COPY <file name>TO <file name>
COPY <source file name>TO <target file name>
Explanation: Generates a copy with the name <target file name> from <source file name>. Such a FileSpecificationRecord must be specified for each source and target file as returned by e.g., FILESELECT or FN Get_Fsspec$ from the ExtensionLibrary.
Wildcard characters are not permitted in the file name. If the file cannot be located, the command is aborted and an error message is issued, if Error_Messages is activated.
Example: COPY Fn GetFsspec$(0,0,"OmikronBasic") TO Fn GetFsspec$(0,0,"OmikronBasic.copy")
Result: The file OmikronBasic is copied. The new file receives the name OmikronBasic.copy
See also: BACKUP
   
 


COS
Type: Function
Syntax: COS(<num.expression>)
Explanation: Calculates the cosine of the numerical expression. The result is dependent on the adjusted angle mode (see DEG, RAD).
Example: PRINT COS( PI )
DEG
PRINT COS(90)
Result: -1
0
See also: ARCCOS
   

 

COSEC
Type: Function
Syntax: COSEC(<num.expression>)
Explanation: Calculates the cosecant of the numerical expression. The result is dependent on the adjusted angle mode (see also DEG, RAD).
Example: PRINT COSEC( PI /2)
DEG
PRINT COSEC(135)
Result: 1
1.4142135623731
   
 

COSECH
Type: Function
Syntax: COSECH(<num.expression>)
Explanation: Calculates the hyperbolic cosecants of the numerical expression.
Example: PRINT COSECH(1)
Result: 0.850918128239322
   

 

COSH
Type: Function
Syntax: COSH(<num.expression>)
Explanation: Calculates the hyperbolic cosine of the numerical expression.
Example: PRINT COSH(0.5)
Result: 1.12762596520638
   

 

COT
Type: Function
Syntax: COT(<num.expression>)
Explanation: Calculates the cotangent of the numerical expression. The result is dependent on the adjusted angle mode (see also DEG, RAD)
Example: PRINT COT(3)
DEG
PRINT COT(90)
Result: -7.01525255143454
0
   

 

COTH
Type: Function
Syntax: COTH(<num.expression>)
Explanation: Calculates the hyperbolic cotangent of the numerical expression. The numerical value must be unequal to zero.
Example: PRINT COTH(1)
Result: 1.31303528549933
   

 

CSNG
Type: Function
Syntax: CSNG(<num.expression>)
Explanation: Converts any numerical expression into a single float format.
Example: A#=1#
B#=3#
PRINT CSNG(A#/B#)
PRINT CSNG(A#)/CDBL(B#)
Result: 0.3333333
0.333333333333333
See also: CDBL   CINT   CINTL 
   

 

CSRLIN
Type: Function
Syntax: CSRLIN
Explanation: Results in the line in which the cursor is currently located. The uppermost line has the number one, unlike "@," where the uppermost line carries the number zero.
Example: PRINT @(10,0);"Here is line: "; CSRLIN
Result: Here is line: 11
See also: POS   LOCATE    PRINT   @
   
 


CVD
Type: Function
Syntax: CVD(<string expression>)
Explanation: The first 8 characters of the string expression are converted into a double floating number. CVD is the reverse function of MKD$. The function's primary application purpose is to read binary files, which do not display double floating numbers in their readable ASCII representation but in their binary representation instead.

Caution: If A$ consists of less than 8 characters, 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 CVD("12345678")
PRINT CVD( MKD$(12345678))
Result: 1.03008436562014D-71
12345678
See also: CVI   CVIL  CVS   MKD$
   

 

CVI
Type: Function
Syntax: CVI(<string expression>)
Explanation: The first two characters of the string expression are converted into a short integer number. CVI is the reverse function of MKI$. The function's primary application purpose is to read binary files, which do not display short integer numbers in their readable ASCII representation but in their binary representation instead.

Caution: If A$ consists of less than 2 characters, 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 CVI("12")
PRINT CVI( MKI$(12))
Result: 12594
12
See also: CVD   CVIL    CVS   MKI$
   

 

CVIL
Type: Function
Syntax: CVIL(<string expression>)
Explanation: The first 4 characters of the string expression are converted into a long integer number. CVIL is the reverse function of MKIL$. The function's primary application purpose is to read binary files, which do not display long integer numbers in their readable ASCII representation but in their binary representation instead.

Caution: If A$ consists of less than 4 characters, 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 CVIL("1234")
PRINT CVIL( MKIL$(1234))
Result: 825373492
1234
See also: CVD   CVI   CVS   MKIL$ 
   


 

CVS
Type: Function
Syntax: CVS(<string expression>)
Explanation: The first 4 characters of the string expression are converted into a single floating number. CVS is the reverse function of MKS$. The function's primary application purpose is to read binary files, which do not display single floating numbers in their readable ASCII representation but in their binary representation instead.

Caution: If A$ consists of less than 4 characters, 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 CVS("1234")
PRINT CVS( MKS$(1234))
Result: 2.593151E-9
1234
See also: CVD   CVI  CVIL   MKS$
   

 

DATA
Type: Command
Syntax: DATA <expression>[[,<expression>]]
Explanation: The numerical expressions and string expressions, respectively, are successively stored in the program as open allocations. The DATA allocation has validity even if it has not been yet accessed by the program.
By means of READ, the expressions can be allocated to a corresponding variable - again successively. RESTORE moves the pointer, which points to the subsequent open allocation.

Important: It is of absolute necessity that numerical expressions are only allocated to numerical variables and string expressions are only allocated to string variables.
Example: DATA "Dog",A$
Inh=2
READ A$,B$,C$,A
PRINT A$,B$,C$,A
DATA "Cat",23*Inh
Result: Dog Dog Cat 46
See also: READ    RESTORE 
   

 

DATE$
Type: Command
Syntax: DATE$=<string expression>
Explanation: Allocates the date <string expression> to the system clock. The <string expression> is to be specified in the format "DD.MM.YYYY" (D=day, M=month, Y=year).

Note: Your country might employ a different date/time format! Since adjusting Omikron Basic 6 to accommodate all possible date/time formats would have required completely different versions, we opted to use the European format.
Example: DATE$="08.11.1997"
Result: The current date is set to 08.11.1997.
See also: DATE$ as function    TIME$ as command 
   
 


DATE$
Type: Function
Syntax: DATE$
Explanation: Returns a string expression of the date in accordance with the set format of your computer. You can change the format with the control field 'Date & Time'.
Example: PRINT DATE$
Result: The current date is displayed to the screen.
See also: DATE$ as command    TIME$ as function 
   

DEFAULT
Type: Command
Syntax: DEFAULT
Explanation: The program branch to be executed is initiated with DEFAULT or OTHERWISE within a SELECT ... CASE statement if no other alternatives apply. The DEFAULT branch must always be the last possibility within the SELECT ... CASE statement. Another CASE may not follow.
See also: OTHERWISE
   

 

DEFER
Explanation: Allocated for future applications!
Please, do not use this word!!
   

 

DEF FN
Type: Command
Syntax: DEF FN <variable>[(<variable>[[,<variable>]])][=<expression>]
DEF FN <function variable>[(<parameter>[[,parameter]])] [=<expression>]
Explanation: Allocates the function to the function variable. One or several parameters may be defined, which must be specified when called. The parameters are local variables (see also LOCAL). The value of the function can be specified directly using =<expression> or, as an alternative, after a one- or multi-line calculation with RETURN <expression>.
The function can be called in the program via FN<function variable>[(<parameter>[[,parameter]])].
The function definition can appear anywhere in the program. A multi-line function definition may not be executed during the execution of the program. A multi-line function definition should be concluded with END_FN. This statement has the effect of a normal RETURN and is primarily used to improve structuring of the program.
Example: PRINT FN Double(13)
PRINT FN Prime_Number$(13)
END

DEF FN Double(A)=2*A

DEF FN Prime_Number$(A)
LOCAL N,P$="Prime number"
FOR N=2 TO SQR(A)
IF A MOD N=0 THEN P$="Not a prime number"
NEXT N
RETURN P$
END_FN
Result: 26
Prime number
See also: DEF PROC    DEF USR 
   

 
DEF FNEX 
Type: Command
Syntax:  DEF FNEX <num.variable>[(<num.variable>[[,<num.variable>]])][=<num.expression>] 
DEF FNEX <function.variable>[(<num.parameter>[[,num.parameter]])][=<num.expression>] 
Explanation:  Defines the function you would like to export to other programs or the operating system. One or more numerical parameters may be defined, which have to be indicated when a call is issued by another program. The parameters are local variables (see also LOCAL). The value of the function can be indicated directly with =<num.expression> or after a calculation with one or more lines by using RETURN <num.expression>. 
A function defined with DEF FNEX cannot be called from the program in which it was defined. That would also serve no real purpose since the call formalism standardized by Apple is rather complex and thus takes significantly longer than the optimized call of an Omikron Basic function defined with DEF FN.
The function definition may appear at any location within the program. A multi-line function definition may not be executed during the execution of the program. A function definition with several lines should be ended with END_FN. This instruction has the effect of a normal RETURN and mainly serve to structure the program better.
DEF FNEX may not be used to define string functions. Editing of the strings can be performed by passing a pointer to the string.
If more than one result is to be returned it is also necessary to pass pointers to the additional variables so that the called program can post the result at these positions.
If you want to write shared libraries or plugins you can mark the functions defined with DEF FNEX as exported using EXPORT.
Some of the functions of the Macintosh operating system require pointers to the callback routines in the form of parameters for the purpose of, for example, continuously update the window content, while the user moves the window scroll bar or as a so-called completion routine in case of asynchronous data transfer. Functions also defined with DEF FNEX may be employed for such tasks by passing the address of the function determined with "&" to the MAC_OS command.

Note: Please make sure to use the appropriate data type when defining and calling functions. If, for example, the function defined with DEF FNEX expects an integer, a floating point number may not be passed instead. Unlike the internal Omikron Basic function calls (DEF FN) it is not possible to perform an automatic type adjustment during runtime. Incorrect data types usually lead to total system crashes, especially when pointers are being passed.
Example: Sample program "SharedLib.BAS" in the DEMO folder.
Result:   
See also:  DEF FN    EXPORT     EXPORT_INIT    EXPORT_EXIT   COMPILER "shlb"    MAC_OS
   

 

DEF PROC
Type: Command
Syntax: DEF PROC <procedure name>[([R]<variable>[[,[R ]<variable>]])]
Explanation: Initiates a procedure definition. One or several parameters can be defined. The parameters are local variables (see also LOCAL). The values at the completion of the procedure are transferred to the variables indicated in the procedure call if a prefixed R is used. The procedure is terminated using RETURN or better yet, using END_PROC.
To initiate the call, the procedure name has to be indicated as well as - if necessary - the expressions set in parentheses and separated by commas. If an "R" precedes the variable at some location in the definition, a variable has to be set in the corresponding location in the call.
At the end of the procedure, this variable will receive the content of the procedure variable. In the case of the procedure call, the parentheses can also be omitted.
The procedure definition can appear anywhere in the program. The procedure definition may not be executed during the execution of the program.
Example: Center "This text appears centered"
Blocked "OMIKRON-BASIC",2
END

DEF PROC Center(Text$)
PRINT TAB((W_CHAR-LEN(Text$))/2);Text$;
END_PROC

DEF PROC Blocked(Text$, Number_of_Blanks)
LOCAL I
FOR I=1 TO LEN(Text$)
PRINT MID$(Text$,I,1);
PRINT " "*Number_of_Blanks;
NEXT I
END_PROC
Result: This text appears centered
O M I K R O N - B A S I C
See also: DEF FN   DEF USR 
   

 

DEF USR
Type: Command
Syntax: DEF USR=<num.expression>
Explanation: Determines the address, which is accessed by USR when a call is issued in a machine language program.
Example: DEF USR Scroll_Screen
Result: The machine program now can be called with USR(parameter).
See also: DEF FN     DEF PROC
   
 


5-2. ABS - CINT Contents | 5-4. DEFDBL - FIX

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


© 1997-2001 Berkhan-Software