Omikron BASIC for Apple Power Mac

5-9. POS - SAVE Contents | 5-11. TEXT ROTATION - XOR

 

Chapter 5-10

The Command Set

SCREEN - TEXT HEIGHT

SCREEN
Type: Command
Syntax: SCREEN <num.expression>[,<num.expression>,<num.expression>[,<num.expression>,<num.expression>]]
SCREEN <screen number>[,<X>,<Y>[,<W>,<H>]]
Explanation: Additional Omikron Basic output windows can be opened with this command. These output windows Omikron Basic then manages automatically. Thus, the user does not have to worry about such effects as redraw. The command is only then functional, if the compiler was previously instructed to include an event handler for the output windows using the COMPILER "OUTPUT_WINDOW X*Y" control word.
The syntax with one parameter can be used to determine which window is supposed to receive the output generated with PRINT, TEXT, DRAW, etc. The syntax with 3 parameters opens a new window in the upper left corner of the screen consisting of the width <X> and the height <Y>, while the version with 5 parameters creates a new window in position (<X>,<Y>) with the width of <W> and the height of <H>. The syntax with 3 parameters can also be used to delete output windows if the width is indicated as 0. The values <X>, <Y>, <W>, and <H> always refer to the interior of the window.
If an output window with <screen number> already exists, a new window is not opened; the available window is moved according to the parameters <X>, <Y>, <W>, and <H> and changed in size instead.
Omikron Basic can manage a total of 32 such windows.

Note: If QuickDraw commands or functions of the Macintosh Toolbox are to be applied to the Omikron Basic output windows, the associated WindowPtr and GWorldPtr have to be loaded from the Extension Library first with the functions 'Get_Window_Ptr' and 'Get_G_World_Ptr' . These are then to be passed to the corresponding MacOS functions. The fact that each window has a corresponding Offscreen-Graphics-World buffering the window content has to be considered. Therefore, drawing commands must be executed both in the window and in the Offscreen-Graphics-World.

Caution: Since each window has a corresponding buffer in memory, care should be taken to ensure that enough heap memory is available using the COMPILER control word "PRE_SIZE" and/or "MIN_SIZE".
A window with 1280x960 pixels and 256 colors requires 1.2 MB memory.
Example: See the program 'Mandelbrot.BAS' in the folder 'DEMO'
Result:  
   
 


SEC
Type: Function
Syntax: SEC(<num.expression>)
Explanation: Calculates the secant of the numerical expression. The result is dependent from the adjusted angle mode.
Example: RAD
PRINT SEC(0.5)
Result: 1.13949392732455
See also: COSEC   SIN   DEG    RAD 
   

 

SECH
Type: Function
Syntax: SECH(<num.expression>)
Explanation: Calculates the hyperbolic secant of the numerical expression.
Example: PRINT SECH(1)
Result: 0.648054273663886
See also: COSECH   SINH    DEG    RAD 
   
 

SEEK
Type: Command
Syntax: SEEK <file number>, <position>[,<mode>]
Explanation: The SEEK command is used to set the internal file pointer for user files. The subsequent PUT or GET command then writes to or reads from the file starting at the indicated position.

<mode> has the following purpose:
<mode>=0: The specified position refers to the beginning of the file.
<mode>=1: The position is interpreted relative to the current position. Negative values are possible here as well (e.g., -5 sets the file pointer back 5 positions)
<mode>=2: The position refers to EOF. Only negative values or 0 are permitted.

If the mode specification is omitted, <position> refers to the beginning of the file.
See also: OPEN   PUT   GET 
   
 

SEGPTR
Type: Function
Syntax: SEGPTR
Explanation: The function SEGPTR returns a pointer to the global variables of Omikron Basic. Application of these pointers should remain reserved for the expert programmer because it is rather easy to cause an entire system crash by applying defective modifications of the entries.

Offset memory area

0 Reserved
4 Reserved
8 Reserved
12 Reserved
16 Reserved
20 0
24 Pointer behind the array area
28 0
32 Pointer to the currently available BASIC memory
36 Pointer points to the beginning of the program line currently executed
40 Garbage top
44 Garbage bottom
48 Reserved
52 Bottommost address of the BASIC stack (adjustable with COMPILER "STACK X")
56 Reserved
60 Uppermost storage address of the BASIC stack (adjustable with COMPILER "BAS_MEM" X)
64 Reserved
68 Pointer to the arrays
72 Pointer to the string heap

Note: Further global variables of Omikron Basic can be queried and changed with specific functions and procedures of the Extension Library (e.g., FN Get_Window_Ptr, PROC Set_Pen_Size).
See also: VARPTR    Extension Library   Memory Organization in Omikron Basic
   

 

SELECT
Type: Command
Syntax: SELECT <expression>
Explanation: The SELECT ... CASE statement is initiated with SELECT. The expression behind SELECT is analyzed and mapped on a long integer number. Therefore, only the first four characters of string expressions are of importance. A branch to the subsequent CASE parts is initiated depending on this once ascertained value. The expression is weighted only once at the beginning, that is, if it is modified again at a later time, it has no further effects on the SELECT ... CASE branches.
See also: END_SELECT   CASE   DEFAULT   OTHERWISE   CONTINUE   IF 
   



SGN
Type: Function
Syntax: SGN(<num.expression>)
SGN( X )
Explanation: The SIGN(X) function returns:

-1 for X <0
0 for X = 0
1 for X> 0
Example: PRINT SGN(7), SGN(-6), SGN(0)
Result: 1 -1 0
   
 


SHL
Type: Operator
Syntax: <num.expression>SHL <num.expression>
<num.expression>SHL <number>
Explanation: Reallocates bit-wise to the left. The most significant bits are lost. The zeros are incorporated subsequently in the least significant bits. Only the 5 least significant bits from <number> are always considered with the values of <number> being located between 0 and 31. SHL relays an unsigned integer multiplication with powers of two ("X SHL Y" corresponds to "X*(2^Y)").
Example: PRINT 4 SHL 2,1 SHL 10
PRINT BIN$(%100 SHL 2),BIN$(%1 SHL 10)
Result: 16 1024
%10000 %10000000000
See also: SHR
 


SHR
Type: Operator
Syntax: <num.expression>SHR <num.expression>
<num.expression>SHR <number>
Explanation: Reallocates bit-by-bit to the right. The least significant bits are lost. The zeros are incorporated subsequently in the most significant bits. Only the 5 least significant bits from <number> are always considered with the values of <number> being located between 0 and 31.
SHR relays an unsigned integer division with powers of two ("X SHR Y" corresponds to "X\(2^Y)").
Example: PRINT 81 SHR 2,64 SHR 1
Result: 20 32
See also: SHL
   

 

SIN
Type: Function
Syntax: SIN(<num.expression>)
Explanation: Calculates the sine of the numerical expression. The result is dependent on the adjusted angle mode (see DEG, RAD).
See also: DEG   RAD   COS 
   
 


SINH
Type: Function
Syntax: SINH(<num.expression>)
Explanation: Calculates the hyperbolic sine of the numerical expression.
Example: PRINT SINH(10)
Result: 11013.232
See also: DEG   RAD   COSH 
   
 


SORT [ASC]
Type: Command
Syntax: SORT [ASC] <field identifier>([<num.expression>]) [TO< field identifier >([<num.expression>]) [,<field identifier >([<num.expression>])]...]
SORT [ASC] < field identifier >([<number>]) [TO< field identifier >([<dummy>]) [,<field identifier >([<dummy>])]...]
Explanation: SORT sorts a one-dimensional field. The field elements are placed in ascending order. In the case of string fields, the sort operation is performed strictly according to DIN 5007, i.e., upper and lower case are not considered. All umlauts are treated as written out alpha character combinations (Ä = AE, Ö = OE ...). If the sort operation is to be performed only according to ASCII values, ASC has to be added.
If a TO follows behind the SORT command, as many as desired additional field identifiers may be appended, which are then re-sorted immediately as well. As a result, it is possible e.g., to sort an address data record consisting of the fields Name$(), Street$(), Zip(), City$(), Telephone() according to names and at the same time re-organize the fields so that related elements subsequently have identical indices as well. The BASIC command would read in this case as follows:
SORT Name$() TO Street$(),Zip(),City$(),Telephone()

<Number> specifies the number of the elements to be sorted. If 0 is specified, the entire field is sorted. Omission of the number parameter has the same effect as if the highest index would have been indicated. In this case scenario, everything is sorted up to the last element.

Note: If additional fields are to be sorted at the same time, additional memory in the garbage area is also required. See the chapter 'Memory Organization in Omikron Basic'. The required memory amounts can be calculated as follows: Number of elements in the field identifier() times 4 plus memory requirement of the largest field to be sorted at the same time.
Example: DIM Values(10)
FOR I=0 TO 10
Values(I)= RND(10)
NEXT I
SORT Values()
FOR I=0 TO 10
PRINT Values(I)
NEXT I

DIM Texts$(11)
REPEAT
INPUT "Any text [Return] >END: ";Texts$(N)
IF LEN(Texts$(N))=0 THEN EXIT
N+=1
UNTIL N>11
N-=1
IF N>0
THEN SORT Texts$(N)
FOR I=0 TO N
PRINT Texts$(I)
NEXT I
ELSE PRINT "Nothing to sort"
ENDIF
INPUT "Conclude program with 'RETURN' ";E
END
Result: First, 11 random numbers are assigned to the field 'Values()', followed by sorting the field and displaying the elements on the screen.

The second program loads max. 12 user strings, sorts and then displays them on the screen.
   

 

SPACE$
Type: Function
Syntax: SPACE$(<num.expression>)
Explanation: Returns a string filled with blanks (CHR$(32)) with the length indicated by the numerical expression. The function is identical to SPC.
Example: PRINT "*";SPACE$(14);"*"
Result: * *
See also: SPC    STRING$
   
 


SPC
Type: Function
Syntax: SPC(<num.expression>)
Explanation: Returns a string filled with blanks (CHR$(32)) with the length indicated by the numerical expression. The function is identical to SPACE$.
Example: PRINT "*";SPC(14);"*"
Result: * *
See also: SPACE$    STRING$ 
   
 
SPEEK 
Type: Function
Syntax: 

SPEEK
(<num.expression>) 
SPEEK(<address>) 
Explanation:  Reads a floating point number with double precision at the address resulting from the numerical expression. This command might be used, e.g., to import non-Omikron-Basic data structures into Omikron Basic floating point numbers. <Address> should be a number divisible by 4; otherwise, the function will be executed significantly slower.
See also:  PEEK   WPEEK   LPEEK   DPEEK   POKE   WPOKE    LPOKE    SPOKE   DPOKE
   

   
SPOKE 
Type: Command
Syntax: 

SPOKE
<num.expression>,<num. expression> 
SPOKE <address>,<value> 
Explanation:  Posts the value at the indicated address in the form of a single float number. This command is quite useful for the construction of one's own data structures with floating point numbers. <Address> should be a number divisible by 4; otherwise, the function will be carried out significantly slower.
See also:  PEEK   WPEEK   LPEEK   SPEEK   DPEEK   POKE   WPOKE   LPOKE   DPOKE 
   


SQR
Type: Function
Syntax: SQR(<num.expression>)
Explanation: Calculates the square root of the numerical expression. The numerical expression must be a positive value.
Example: PRINT SQR(2)
Result: 1.4142135623731
See also: ^ (Power Operator)
   
 


STEP
Type: Command
Syntax: STEP <num.expression>
Explanation: STEP may be used to establish the increment interval for FOR ... NEXT loops. Any integer or floating point number can be substituted for the numerical expression. Negative numbers are permitted as well.
See also: FOR   NEXT
   
 

STOP
Type: Command
Syntax: STOP
Explanation: STOP cancels program execution. Contrary to END, an error message is still issued first.
If the program was started with Debug it is halted right after the STOP command and the debugger is being activated so that you can monitor the remaining program execution via the debugger.
   

 

STR$
Type: Function
Syntax: STR$(<num.expression>)
Explanation: STR$ converts the numerical expression to a string. Therefore, STR$ is the reverse function of VAL. All settings and adjustments effected with USING are considered during the conversion.
STR$ always converts to a decimal format, if necessary in exponential representation. HEX$, OCT$, or BIN$ may be used to convert to other number systems.
Example: Pi$=STR$(PI)
USING " $ ###.##"
Amount$=STR$(12.121)
USING 'Deactivate'
PRINT Pi$,Amount$
Result: 3.14159265358979 12.12
See also: VAL   BIN$    HEX$    OCT$    USING 
   
 


STRING$
Type: Function
Syntax: STRING$(<num.expression>,{<num.expression>|<string expression>})
STRING$(<number>,{ASCII code|<string expression>}
Explanation: Creates a string of the length <number>, which contains the character indicated by <string expression> or its corresponding <ASCII code> (see ASCII table) as many times as marked. Only the first character appearing in <string expression> is valid.
Example: PRINT STRING$(10,"*"),STRING$(10,95)
Result: ********** __________
See also: SPACE$    SPC   *(String Multiplication)
   

 

SWAP
Type: Command
Syntax: SWAP <variable>,<variable>
Explanation: Exchanges (swaps) the contents of the two given variables. The two variables must be identical variable types. Field variables may also be swapped with individual variables.
Example: A=10:B=20
SWAP A,B
PRINT A,B
Result: 20 10
   

 

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


TAB
Type: Function
Syntax: TAB(<num.expression>)
Explanation: This function tabulates output generated by PRINT, LPRINT, or PRINT #. The numerical expression specifies the new output column to which the write pointer jumps. If the pointer is already behind the column defined by means of TAB, the pointer remains unchanged. Thus, unlike in the case of @, the pointer will not be set back.
Example: PRINT TAB(10);"10. column";TAB(25);"25. column"
PRINT TAB(10);1.256;TAB(25);3.6589
Result: 10. column 25. column
1.256 3.6589
See also: PRINT    PRINT @    LPRINT 
   
 


TAN
Type: Function
Syntax: TAN(<num.expression>)
Explanation: Calculates the tangent of the numerical expression. The result is dependent from the adjusted angle mode.
Example: RAD: PRINT TAN(PI / 8)
Result: 0.414213562373095
See also: COT
   

 

TANH
Type: Function
Syntax: TANH(<num.expression>)
Explanation: Calculates the hyperbolic tangents of the numerical expression.
Example: PRINT TANH(0.5)
Result: 0.46211715726001
See also: COTH
   

 

TEXT
Type: Command
Syntax: TEXT <num.expression>,<num.expression>,<string expression> [,<num.expression>,<num.expression>,<num.expression>]
TEXT <X>,<Y>,<output text> [,<width>,<word flag>, <letter flag>]
Explanation: This command outputs a formatted graphics text. The coordinates <X> and <Y> make it possible to position the text with pixel precision. Text is then output with the left corner of the base line being located at the (<X>,<Y>) position.
If text width and format flags are specified, additional formatting depending on the settings is performed. If the word flag is set to 1, width adjustment is accomplished by extending the spaces between each word. If the letter flag is set in addition, the spaces between each letter are also adjusted, producing an evenly spaced justification. Text color, style, and size can be determined via TEXT COLOR, TEXT STYLE, ans TEXT HEIGHT. If a window is defined by means of CLIP, nothing is drawn outside of this area.
The used font can be determined with the procedure 'Set_Text_Font' from the Extension Library.
Example: TEXT 10,23,"Fit this sentence exactly into the box",420,1,0
BOX 9,9,423,20
PRINT : PRINT
Result: Text is formatted by broadening the spaces between words and now fits exactly into the drawn box.
See also: TEXT COLOR    TEXT HEIGHT    TEXT STYLE    Set_Text_Font 
   
 


TEXT COLOR
Type: Command
Syntax: TEXT COLOR = <num.expression>
TEXT COLOR = <color number>
Explanation: Defines the font color for a graphics text. The background color can also be changed using the procedure 'Set_Text_Back_Color' from the Extension Library.
See also: TEXT    Set_Text_Fore_Color    Set_Text_Back_Color 
   
 


TEXT HEIGHT
Type: Command
Syntax: TEXT HEIGHT = <num.expression>
TEXT HEIGHT = <height in pixels>
Explanation: Sets the text height of the graphics text.
Example: FOR Text_H=2 TO 17
TEXT HEIGHT =Text_H
TEXT 10,Y+5, STR$(Text_H)+"Point text sample"
Y+=Text_H*2
NEXT Text_H
Result: Different-sized text is written on the screen.
See also: TEXT Set_Text_Size
   
 

5-9. POS - SAVE Contents | 5-11. TEXT ROTATION - XOR

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


© 1997-2001 Berkhan-Software