Can we keep the (forum-)jokes? :P
Rem ' ' Banksize ' ' returns the size (in bytes) of a bank ' Local bank:TBank=CreateBank( 10 + Rnd(40) ) Print "size of the bank is: "+BankSize(bank) End ' ' Debuglog ' ' When running in debugmode, Debuglog prints given strings in the same tab where Print outputs to. ' DebugLog "My debug text" ' ' Debugstop ' ' Debugstop halts program execution and offers you to inspect your variables as they were at the moment of halting ' Graphics 640,480 Local a:Int Repeat a=Rnd(20) Until KeyDown(KEY_ESCAPE) DebugStop ' ' Ceil ' ' Gives the integer value of a given value at the "ceiling" of that value. ' For Local t:Int=-31 To 31 Print "real value: "+t/10.0+" Ceil value: "+Ceil(Double(t/10.0)) Next End ' ' Floor ' ' Gives the integer value of a given value at the "floor" of that value. ' For Local t:Int=-31 To 31 Print "real value: "+t/10.0+" Floor value: "+Floor(Double(t/10.0)) Next End ' ' A practical example of Ceil and Floor ' Graphics 640,480 Local x:Int,y:Int Local mx:Int,my:Int HideMouse Repeat mx=MouseX() my=MouseY() Cls ' draw grid SetColor 90,90,90 For y=0 Until 480 Step 20 For x=0 Until 640 Step 20 Plot x,y Next Next 'draw mouse mx,my SetColor 255,255,255 DrawRect mx-1,my-1,3,3 ' draw ceiled and floored mouse mx,my SetColor 255,255,0 DrawRect Ceil( mx/20.0)*20-1,Ceil(my/20.0)*20-1,3,3 SetColor 0,255,255 DrawRect Floor(mx/20.0)*20-1,Floor( my/20.0)*20-1,3,3 Flip Until KeyDown(KEY_ESCAPE) End ' ' GadgetX(gadget) ' ' Gives the X coordinate of a given gadget ' ' ' GadgetY(gadget) ' ' Gives the Y coordinate of a given gadget ' ' ' GadgetWidth(gadget) ' ' Gives the width of a given gadget ' ' ' GadgetHeighth(gadget) ' ' Gives the height of a given gadget ' Local window:tgadget=CreateWindow("example",16,0,320,240) Local label:tgadget=CreateLabel("",4,4,160,30,window) SetGadgetText label,GadgetX(window)+" "+GadgetY(window)+" "+GadgetWidth(window)+" "+GadgetHeight(window) Repeat WaitEvent();If EventID()=EVENT_WINDOWCLOSE End Forever ' ' Hex(value) ' ' Hex gives the hexademimal string of a given value, with a 'width' of 8 digits, being the 4 bytes of the given int value. ' For Local t:Int=0 To 255 If Not(t Mod 16) Print Print "decimal: "+RSet(t,3)+" | hex: "+Hex(t) Next End ' ' ImageWidth(image) ' ' Gives the width of an image. ' Local myimage:Timage=CreateImage(64,32) Print ImageWidth(myimage) End ' ' ImageHeight(image) ' ' Gives the height of an image. ' Local myimage:Timage=CreateImage(64,32) Print ImageHeight(myimage) End ' ' Instr ' ' Returns the position in a given string where a given substring can be found. It returns 0 when the substring ' is not found. This can typically be used to check whether a substring is present at all, as a given offset represents ' True. ' Local mystring$="*sniffage*, I need more media!" ' check for the position Print Instr(mystring,"more") If Instr(mystring,"new PC") Print "large!" If Not Instr(mystring,"new PC") Print "*sniff*" If Instr(mystring,"media") Print "large!" End ' ' Lower(string) ' ' Returns the given string in lower-case. ' Print Lower("abcdEFGH") End ' ' Max(a,b) ' ' Returns the biggest of the two given values ' Print Max( 1,10 ) Print Max( Max(1,10), Max(-50,-5) ) End ' ' Min(a,b) ' ' Returns the smallest of the two given values ' Print Min(99,9 ) Print Min( Min(-1,-10), Min(-50,-5) ) End ' ' Mid(str$,pos,size=-1) ' ' Returns a section of the given string, note that the pos arguement is one-based, not zero-based. ' Local a$="abcd1234efgh" Print Mid(a,5,4) End ' ' Left(str$,n) ' ' Prints the most left n characters from the given string ' Print Left("12345678",4) End ' ' Right(str$,n) ' ' Prints the most right n characters from the given string ' Print Right("12345678",4) End ' ' LSet(str$,n) ' ' Changes the length of a string. If the originel string was longer then n characters from the left are used. If the new ' length is longer than the originel length, spaces are added right from the original string. Print LSet("12345678",3) Print "["+LSet("12345678",10)+"]" End ' ' RSet(str$,n) ' ' Changes the length of a string. If the originel string was longer then n characters from the right are used. If the new ' length is longer than the originel length, spaces are added left from the original string. Print RSet("12345678",3) Print "["+RSet("12345678",10)+"]" End EndRem