Pocket Basic Documentation (for version 0.5) Pocket Basic - interpreted without a strongly typed programming language. Annotations: Argument types: string - text value int - whole number double - a floating point number boolean - having two values (denoted true and false) bitmap - image object - any type of the above # - operator, which guarantees that the line before the start of the application. @ - Appeal to the constant Functions Console: print(object value) printline(object value) clearconsole() System: fullscreen(boolean) - must called with # operator orientation(int orientationId) - must called with # operator - @landscape, @portrait, @user stop() sleep(int ms) smartsleep(int ms) - automatically calculates the time required for the delay. Effective for use in cycles. setview(int viewId) - @console, @canvas setuiparam(int paramnum, param) - @consolebackground, @consoletext mark(string markName) - must called with # operator goto(string markName) gosub(string markname) return() - continues execution after the last caused gosub trap(int ID, string markName, boolean useReturn, boolean destroyable) getlastexception() - return string throw(string) Info: timenow() - return string currenttime(int timeValueId) - return int - @millisecond, @second, @minute, @hour, @day, @month, @year meterstart() meterfinish() - return string - returns the time in milliseconds since the call meterstart String utils: substring(string text,int start,int finish) - return string stringsize(string text) - return int stringreplace(string text,string oldWord,string newWord) return string stringup(string text) - return string stringdown(string text) - return string stringindexof(string text, string text) - return int stringlastindexof(string text, string text) - return int stringsplit(string text, string separator) - return object array Data: chr(int num) - return string asc(string) - return int Data convert: tostring(object value) - return string toint(object value) return int todouble(object value) - return double typeof(object value) - return string Mathematics: random(int min, int max) - return int floor(object value) return int round(object value) - return int mod(int value, int value) return int abs(object value) - return double sin(object value) - return double cos(object value) - return double tan(object value) - return double asin(object value) - return double acos(object value) - return double atan(object value) - return double atan2(object x,object y) - return double pow(object value, object value) - return double sqrt(object value) - return double log(object value) - return double exp(object value) - return double rad(object angdeg) - return double deg(object angrad) - return double Arrays: arraycreate(int size) - return object array arraycreate2(object 1, object 2, object3, ..., ...) - return object array arrayget(object array, int index) - return object arrayset(object array, int index, object value) arrayfill(object array, object value) arraysize(object array) - return int arrayindexof(object array, object value) - return int arraylastindexof(object array, object value) - return int Lists: listcreate() - return object list listadd(object list, object value) listget(object list, int index) - return object listdel(object list, ind index) listset(object list, int index, object value) listsize(object list) - retirn int listindexof(object list, object value) - return int listlastindexof(object list, object value) - return int listinsert(object list, int index, object value) Stacks: stackcreate() - return object stack stackpop(object stack) - return object stackpush(object stack, object value) stackpeek(object stack) - return object stackget(object stack, int index) - return object stackset(object stack, int index, object value) stacksize(object stack) - return int Maps: mapcreate() return object map mapadd(object map, object key, object value) mapget(object map, object key) - return object value mapset(object map, object key, object value) mapcontain(object map, object key) - return boolean mapdel(object map, object key) Media: bitmapload(string folder, string filename) - return bitmap bitmapwidth(object bitmap) - return int bitmapheight(object bitmap) - return int soundload(string folder, string filename) - return int soundId soundplay(int soundId) mediaplayeropen(String folder, String filename) - return int duration mediaplayerplay() mediaplayerstop() mediaplayerpause() mediaplayergetposition() - return int position mediaplayersetposition(int ms) mediaplayersetvolume(double value) - get 0.0 - 1.0 playtone(int duration, int tone) playtone2(int type, int samplerate, int waveFrequency, int waveVolume, int duration) Files: filelist(String folder) - return object list filereadtext(string folder, string filename) - return string filewritetext(string folder, string filename, string text) filedelete(string folder, string filename) fileexist(string folder, string filename) - return boolean fileisfolder(string path) - return boolean filemakedirs(string path) Graphics: initcanvas(int width, int height, int priority, boolean useDoubleBuffer) clearcanvas() repaint() color(int a, int r, int g, int b) - return int color drawcolor(int color) drawrect(int x, int y, int width, int height, int color, boolean fill, int strokeWidth) drawtext(string text, int x, int y, int color, int textSize) drawpoint(int x, int y, int color) drawcircle(int x, int y, int radius, boolean fill, int strokeWidth) drawline(int x1, int y1, int x1, int y1, int color, int strokeWidth) drawbitmap(bitmap, int x, int y, int width, int height) textwidth(string text, int testSize) - return int textheight(string text, int testSize) - return int touchx() - return int touchy() - return int hitrects(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2) - return boolean hitpointrect(int x, int y, int x1, int y1, int w1, int h1) - return boolean Network: tcpclientstart(string ip, int port) - return boolean tcpclientstop() tcpclientsend(string text) tcpclientget() - return string tcpclientisconnected() - return boolean UI: showmsg(string text) - return int inputtext(string title, string defaultText) - return string selectlist(string title, object list) - return int Shell: shellopen(dtring text1, string text2,...) shellclose() shellread() - return string shellwrite(string text) Constructions: { } - optional parameters code - user code dim variableName {, variableName2, variableName3, ...} {= value} - Creates a new variable (variableName) and assigns it a value undim variableName - Removes a variable (variableName) nullify variableName - Set value of variable to null if expression1 {and/or expression2 ...} then is true code {else} is false code endif - Creates a new condition (or set of conditions). ELSE statement is executed in the case where the condition is not satisfied. IMPORTANT! Isolates in brackets are the conditions [] Sample: if 0=0 and [1<0 or 2>=10] then This code will not be executed else This code will be executed endif for int variable to int target {step int stepValue} code {endfor} next - Creates a new cycle, where the variable - variable ,target - maximum value, stepValue - step size. next operator adds to the variable stepValue until variable equals (or exceeds) target. endfor operator stops the cycle. Other constants: @pi - PI (3.141592) @width, @height - screen sizes in pixels. Can be obtained only after the installation setview(@canvas) @appdata - path of application data folder @sdcard - path of primary sdcard @crlf - newline character @quote - quote character ( ' ) @doublequote - double quote character ( " )