Suggestions (from OmikronBasic)
Posted: Fri Nov 07, 2003 2:51 pm
Code: Select all
;i found my old OmikronBasic-Manual and i found some things:
; Local -> same as "Protect" (and it would make more sense)
; first of all: Blocks would be nice
; {
; a=10
; debug a
; }
; in combination with local
; a=10
; debug a; display 10
; {
; local a
; a=99
; debug a; display 99
; }
; debug a; display 10
; and when then the editor can fold the blocks...
Procedure AbsL(Value); - makes value always positiv
If Value<0:Value=-Value:EndIf
ProcedureReturn Value
EndProcedure
Procedure Bit(BitNumber,Value); - Test if a bit is set
If Value&(1<<BitNumber)
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
EndProcedure
;Procedure SetBit(BitNumber,Value); - set a bit in the value (name same as a userlib-command...)
; ProcedureReturn Value|(1<<BitNumber)
;EndProcedure
Procedure BLoad(File$,Address); - Load a file into memory
If ReadFile(0,File$)
ReadData(Address,Lof())
CloseFile(0)
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
EndProcedure
Procedure BSave(File$,Address,length); - Save a memory-block
If CreateFile(0,File$)
WriteData(Address,length)
CloseFile(0)
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
EndProcedure
; Clear([StringBufferSize[,StackSize]])
; clear all variables, dims, linkedlist.
; Close all open files, DLLs, etc
; -> Close everything!
; also: Set the StringBufferSize for all, who need more than 64Kbyte
; And for people, who have many procedures-in-procedures-calls, like
; Procedure CallAgain(i)
; i+1
; If i<999999
; CallAgain(i)
; Else
; Debug "ready!"
; EndIf
; EndProcedure
;
; CallAgain(-999999)
; a possibility to set the Stack-Size.
Procedure.s DateString(); - In otherlanguage it is a varibale called Date$; Return the current date in the system-default-style
Date$=Space(1000)
GetDateFormat_(#LOCALE_USER_DEFAULT ,#DATE_LONGDATE ,0,0,@Date$,1000)
ProcedureReturn Date$
EndProcedure
Procedure.s Time(); - Return the current time in the system-default-style (24-Hours or AM/PM)
time$=Space(1000)
GetTimeFormat_(#LOCALE_USER_DEFAULT,0,0,0,@time$,1000)
ProcedureReturn time$
EndProcedure
;DefInt [STRING] nearly: DefType.w
; DefInt "A-C,E" -> All variables without a type and start with a A,B,C,E will be Word
;DefIntL : DefType.l
;DefSng : DefType.f
;DefStr : DefType.s
;Deg
; all cos/sin and so on will be switch to deg
;RAD
; s. DEG
;Exit -> same as break
;Fill -> It would be nice, when i can set a Stop-Border-Color, where the fill-command will stop filling, or -1 for all colors will stop filling.
;For to [step] next
; At the moment it is impossible to use a variable after step
Procedure.f Frac(Float.f); return the float after the "dot" frac(1.345)=.345
int=Float
Float-int
ProcedureReturn Float
EndProcedure
Procedure.f Fix(Float.f); return the value before the "dot" Fix(123.55=)=123; Fix(-123.55)=-123
int=Float:Float=int
ProcedureReturn Float
EndProcedure
Procedure InStr(start,String$,find$); first parameter is optional
ProcedureReturn FindString(String$,find$,start)
EndProcedure
;Int
; Round to the nearest smallest(!) value
; int(2.5)=2 ; int(-2.5)=-3 (! PB caluculate -2)
; LET a=10
; What exact do let? Nothing, you can simple write "a=10" :)
;LineStyle()
; to set widht and style (dotted, and so on); See createpen_()
Procedure.s Lower(String$)
ProcedureReturn LCase(String$)
EndProcedure
Procedure LPeek(adr)
ProcedureReturn PeekL(adr)
EndProcedure
Procedure LPoke(adr,Value)
ProcedureReturn PokeL(adr,Value)
EndProcedure
; Procedure Max(Value1,Value2)
; If Value1>Value2
; ProcedureReturn Value1
; Else
; ProcedureReturn Value2
; EndIf
; EndProcedure
; Procedure.f MaxF(Value1.f,Value2.f)
; If Value1>Value2
; ProcedureReturn Value1
; Else
; ProcedureReturn Value2
; EndIf
; EndProcedure
; Procedure Min(Value1,Value2)
; If Value1<Value2
; ProcedureReturn Value1
; Else
; ProcedureReturn Value2
; EndIf
; EndProcedure
; Procedure.f MinF(Value1.f,Value2.f)
; If Value1<Value2
; ProcedureReturn Value1
; Else
; ProcedureReturn Value2
; EndIf
; EndProcedure
Procedure.s ReplaceMid(String$,position,length,ReplaceString$); - Replace a part in the string and return the result
ProcedureReturn Left(String$,position-1)+ReplaceString$+Right(String$,Len(String$)-position-length+1)
EndProcedure
Procedure SetMid(*string.BYTE,position,*ReplaceString.BYTE); - Replace a part in the string direct!
*string+(position-1)
While *ReplaceString\b
*string\b=*ReplaceString\b:*string+1:*ReplaceString+1
Wend
EndProcedure
Procedure Mirror(String$); mirror a string
a$=""
For i=Len(String$) To 1 Step -1
a$+Mid(String$,i,1)
Next
ProcedureReturn a$
EndProcedure
;Oct(Value) create a Octal-Value
#PI=3.1415926535897932
;Rem -> same as ;
; better loop-support
; do
; loop
; do until
; loop
; do while
; loop
; do
; loop until
; do
; loop while
Global oldRandom
Procedure.f Rnd(Value)
Result.f=0
Select Value
Case 0:Result=oldRandom
Case 1:Result=Random(9999)/10000
Default:Result=Random(Value-1)
EndSelect
ProcedureReturn Result
EndProcedure
Procedure Sgn(Value); return the signum
If Value<0
ProcedureReturn -1
ElseIf Value=0
ProcedureReturn 0
Else
ProcedureReturn 1
EndIf
EndProcedure
Procedure.s Spc(Value)
ProcedureReturn Space(Value)
EndProcedure
;Stop -> calldebugger
Procedure String(count,Char$)
ProcedureReturn LSet("",count,Char$)
EndProcedure
;Swap -> swap the values
ProcedureReturn Timer()
Procedure.s Upper(String$)
ProcedureReturn UCase(String$)
EndProcedure
; a good Using is missing...
; VAL() should handle Hexadezimal ($1f) and Binaries (%011010)
; VarPtr(Variable) same as @Variable
Procedure Wait(Value.f)
Delay(Value*1000)
EndProcedure
Procedure WPeek(adr)
ProcedureReturn PeekW(adr)
EndProcedure
Procedure WPoke(adr,Value)
ProcedureReturn PokeW(adr,Value)
EndProcedure
; And better Joystick-Routines, which are support more than one joystick, and more axis.
; I wrote a little example with simple api-calls.