Basice user documentation March, 1997 Basice is a full implementation of the BASIC language for Microsoft Windows CE. Basice features include support for floating point, long variable names, procedures, functions, a user extensible run time extension library, and the ability to draw graphics. Data Types ---------- Three data types are supported. Integer (32 bit, signed) Floating Point (64 bit, double precision, IEEE) String (length up to 512 characters) Variable names, procedure names ------------------------------- Names start with letter, may contain letters, digits, and underscores. They may be up to 15 characters in length. Variable names ending with a % are integer Variable names ending with a # are floating point Variable names ending with a $ are string All other names are procedure names Arrays ------ One dimensional arrays of the above data types may be declared (created) using the DIM statement, and deleted using the UNDIM statement. DIM AA%[55] ! creates an array 1..55 of integers UNDIM AA% ! removes the array, free's up the memory Line numbers ------------ Line number are assigned to each line. They may be from 1 to 10000000. Commands -------- These are interactive commands that can be entered at the command line to enter, change, modify, erase, and control the execution of programs. GO [ procedurename [ (argument list) ] ] GO GO CUBE(3) LIST [ first_line# [ TO last_line# ] ] LIST LIST 100 LIST CUBE LIST 100 TO 900 DEL [ first_line# [ TO last_line# ] ] DEL 100 DEL 100 TO 199 SAVE "file.bas" SAVE "myprogram.bas" LOAD "file.bas" LOAD "\basice\squares.bas" MERGE "file.bas" Same as load, but does not remove existing program first. NEW Clear Basice workspace, make new, empty program. CONTINUE Continue from breakpoint SET TRACE/CANCEL TRACE Set or cancel trace mode SET BREAK/CANCEL BREAK Set or remove a break point SET BREAK 1900 CANCEL BREAK 1900 STEP [ number_of_steps ] Step from breakpoint STEP 1 STEP STEP 12 Key words --------- These are parts of statements that make up Basice programs. IF THEN ELSE ENDIF IF (A% = 1) THEN PRINT "Success!" ELSE PRINT "Not done" ENDIF LOOP ENDLOOP FOR TO STEP WHILE BREAK LOOP FOR I%=1 TO 10 PRINT I% ENDLOOP LOOP WHILE A# < 10.5 PRINT A#, SIN(A#) A# = A# + 0.25 IF (A# = B#) THEN BREAK ENDIF ENDLOOP CALL RETURN CALL CUBE(3) PROCEDURE CUBE(AA#) PRINT AA#*AA#*AA# RETURN ENDPROC KILL (delete file) KILL "file.dat" PRINT PRINT "Hello" SQR(A#+1) PRINT #1,A$ INPUT INPUT A$,A%,A# LINPUT LINPUT A$ LINPUT #1,A$ END DIM UNDIM OPEN "x.dat",1 CREATE "x.dat",1 CLOSE 1 ON ON "ERROR" CALL ERROR_HANDLER used to trap I/O errors, end of file, etc. DONE% = 0 ON "ERROR" CALL ERR_HANDLER OPEN 1,"myfile.dat" LOOP WHILE NOT DONE% LINPUT #1,A$ PRINT A$ ENDLOOP PROCEDURE ERROR_HANDLER DONE% = 1 ENDPROC PROCEDURE ENDPROC PROCEDURE PRINTOUT(ANSWER#) PRINT "The answer is " ANSWER# ENDPROC WAIT 1.5 ! seconds EXIT Functions --------- SQR - square root SQR(9) LN - natural log LN(2) EXP - natural exp EXP(2) TAN - tangent (radians) TAN(3.1415926) ATN - arc tangent ATN(1) SIN - sine (radians) SIN(ANGLE# * 180/3.1415926) COS - cosine(radians) COS(1.5) ABS - absolute value ABS(ANUMBER%) ABS(ANUMBER#) INT% - truncate INT%(5.25) RIGHT$ - rightmost substring RIGHT$("ABCD",2) is "AB" LEFT$ - leftmost substring LEFT$("ABCD",2) is "CD" MID$ - middle substring MID$("ABCD",2,2) is "BC" LEN% - length of string LEN%("ABCD") is 4 CHR$ - convert to string CHR$(65) is "A" ASC% - convert ascii-to-int ASC%("ABCD",1) is 65 ERR% - last error number MY_ERR% = ERR% ERL% - program line number of last error MOD% - remainder MOD%(10,6) is 4 POWER - raised to the power POWER(2,2) is 2 squared is 4 POS% - string position POS%("BC","ABCD") is 2 DTIME$ - date & time function DTIME$(0) is current time, DTIME$(60) is time one minute from now KEY$ - return last key pressed (or null string if none) SHIFT% - shift bits SHIFT%(2,1) is 4, SHIFT%(2,-1) is 1 CMDLINE$ - contents of command line that started Basice Operators --------- + add (integer, floating point, string concatenation) - subtract (integer, floating point), urnary minus (as in -5) * multiply (integer, floating point) / divide (integer, floating point) OR logical or (integer) AND logical and (integer) NOT logical negate (integer) XOR logical exclusive-or (integer) > comparison (integer, floating point, string) < " >= " <= " = " <> " () grouping Notes 1) Urnary minus is the highest priority operator. -5+3 means -(5+3) not (-5)+3