Suggestions (from OmikronBasic)

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Suggestions (from OmikronBasic)

Post by GPI »

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.
Not all makes sense, it is only a suggestion...
freedimension
Enthusiast
Enthusiast
Posts: 613
Joined: Tue May 06, 2003 2:50 pm
Location: Germany
Contact:

Post by freedimension »

While we're at it, we could introduce LineNumbers like in Omikron Basic.

10: If a=10 Goto 20
20: End


:D :D
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

10: If a=10 Goto 20
20: End
No no no! This should be avoided. What if you were to add some code after the 'Goto' and before the 'End' statement? your code would break!
--Kale

Image
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

freedimension wrote:While we're at it, we could introduce LineNumbers like in Omikron Basic.

10: If a=10 Goto 20
20: End


:D :D
Which version did you have? My 3.6 don't need Linenumbers (and i never used them). In Omikron-Basic you can deactivate the linenumbers in editormode.
Johan_Haegg
User
User
Posts: 60
Joined: Wed Apr 30, 2003 2:25 pm
Location: Västerås
Contact:

Post by Johan_Haegg »

10: If a=10 Goto 20
20: End
15: Display "I r teh l33t"

Have a Casio-calculator with Basic-interpreter. Debugging is like, hell on steroids :>
freedimension
Enthusiast
Enthusiast
Posts: 613
Joined: Tue May 06, 2003 2:50 pm
Location: Germany
Contact:

Post by freedimension »

GPI wrote:Which version did you have? My 3.6 don't need Linenumbers (and i never used them). In Omikron-Basic you can deactivate the linenumbers in editormode.
Yeehaaa, that was back in 1987 on my old ST. Version?? No idea, it's been quite a long time.
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

freedimension wrote:
GPI wrote:Which version did you have? My 3.6 don't need Linenumbers (and i never used them). In Omikron-Basic you can deactivate the linenumbers in editormode.
Yeehaaa, that was back in 1987 on my old ST. Version?? No idea, it's been quite a long time.
My Manual is from 91 ...

(And is a nice Folder, so sides can be easy replaced...)
Post Reply