diff --git a/Examples/Core/DataTypes/boolean.bas b/Examples/Core/DataTypes/boolean.bas new file mode 100644 index 0000000..ba3eea6 --- /dev/null +++ b/Examples/Core/DataTypes/boolean.bas @@ -0,0 +1,7 @@ +SUB MAIN + DIM X AS BOOLEAN + X=FALSE + PRINT "X=" + STRING(X) + X=TRUE + PRINT "X=" + STRING(X) +END SUB diff --git a/Examples/Core/DataTypes/byte.bas b/Examples/Core/DataTypes/byte.bas new file mode 100644 index 0000000..9cb3247 --- /dev/null +++ b/Examples/Core/DataTypes/byte.bas @@ -0,0 +1,7 @@ +SUB MAIN + DIM X AS BYTE + X=BYTE(0x80) + PRINT "X=" + STRING(X) + X=BYTE(127) + PRINT "X=" + STRING(X) +END SUB diff --git a/Examples/Core/DataTypes/complex.bas b/Examples/Core/DataTypes/complex.bas new file mode 100644 index 0000000..7541dc3 --- /dev/null +++ b/Examples/Core/DataTypes/complex.bas @@ -0,0 +1,5 @@ +SUB MAIN + DIM C AS COMPLEX + C = COMPLEX(2.2, 1.1) + PRINT C + C +END SUB diff --git a/Examples/Core/DataTypes/double.bas b/Examples/Core/DataTypes/double.bas new file mode 100644 index 0000000..3abdfb5 --- /dev/null +++ b/Examples/Core/DataTypes/double.bas @@ -0,0 +1,12 @@ +SUB MAIN + DIM X AS DOUBLE + X=1.234E+2 + PRINT "X=" + STRING(X) + X=-1234.56E-2 + PRINT "X=" + STRING(X) + X=321.1234567890123 + PRINT "X=" + STRING(X) + X=PI + PRINT "X=" + STRING(X) +END SUB + diff --git a/Examples/Core/DataTypes/float.bas b/Examples/Core/DataTypes/float.bas new file mode 100644 index 0000000..a47a91f --- /dev/null +++ b/Examples/Core/DataTypes/float.bas @@ -0,0 +1,9 @@ +SUB MAIN + DIM X AS FLOAT + X=321.1234f // Note the trailing f + PRINT "X=" + STRING(X) + X=1.234E+2f + PRINT "X=" + STRING(X) + X=-1234.56E-2f + PRINT "X=" + STRING(X) +END SUB diff --git a/Examples/Core/DataTypes/integer.bas b/Examples/Core/DataTypes/integer.bas new file mode 100644 index 0000000..efd0817 --- /dev/null +++ b/Examples/Core/DataTypes/integer.bas @@ -0,0 +1,9 @@ +SUB MAIN + DIM X AS INTEGER + X=1234 + PRINT X + X=0x80000000 + PRINT X + X=0x7fffffff + PRINT X +END SUB diff --git a/Examples/Core/DataTypes/long.bas b/Examples/Core/DataTypes/long.bas new file mode 100644 index 0000000..e2b3be5 --- /dev/null +++ b/Examples/Core/DataTypes/long.bas @@ -0,0 +1,9 @@ +SUB MAIN + DIM X AS LONG + X=123L // Note the trailing L + PRINT X + X=0x8000000000000000L + PRINT X + X=0x7fffffffffffffffL + PRINT X +END SUB diff --git a/Examples/Core/DataTypes/short.bas b/Examples/Core/DataTypes/short.bas new file mode 100644 index 0000000..28bec13 --- /dev/null +++ b/Examples/Core/DataTypes/short.bas @@ -0,0 +1,9 @@ +SUB MAIN + DIM X AS SHORT + X=SHORT(123) + PRINT X + X=SHORT(0x8000) + PRINT X + X=SHORT(0x7fff) + PRINT X +END SUB diff --git a/Examples/Core/DataTypes/string.bas b/Examples/Core/DataTypes/string.bas new file mode 100644 index 0000000..b151e43 --- /dev/null +++ b/Examples/Core/DataTypes/string.bas @@ -0,0 +1,11 @@ +SUB MAIN + DIM X AS STRING + X="Backslash character=\\" + PRINT "X: " + X + X="Quote Character=\"" + PRINT "X: " + X + X="First line\nSecond line" + PRINT "X: " + X + X=STRING(123) + PRINT "X=" + X +END SUB diff --git a/Examples/Core/DataTypes/variant.bas b/Examples/Core/DataTypes/variant.bas new file mode 100644 index 0000000..b855e65 --- /dev/null +++ b/Examples/Core/DataTypes/variant.bas @@ -0,0 +1,15 @@ +FUNCTION DBL(X AS VARIANT) AS VARIANT + DBL = X + X +END FUNCTION + +SUB MAIN + DIM V AS VARIANT + V=VARIANT(5) + PRINT DBL(V) + V=VARIANT(5.5) + PRINT DBL(V) + V=VARIANT(COMPLEX(2.2,1.1)) + PRINT DBL(V) + V=VARIANT("Test") + PRINT DBL(V) +END SUB diff --git a/Examples/Core/Operators/arithmetic.bas b/Examples/Core/Operators/arithmetic.bas new file mode 100644 index 0000000..e59317d --- /dev/null +++ b/Examples/Core/Operators/arithmetic.bas @@ -0,0 +1,13 @@ +SUB MAIN + PRINT "14 + 2 = " + STRING(14 + 2) + PRINT "14 - 2 = " + STRING(14 - 2) + PRINT "14 * 2 = " + STRING(14 * 2) + PRINT "14 / 2 = " + STRING(14 / 2) + PRINT "157 % 100 = " + STRING(157 % 100) + PRINT "10.0 ** 2.0 = " + STRING(10.0 ** 2.0) + PRINT "5 * -3 = " + STRING(5 * -3) + + PRINT "3 * 4 + 2 = " + STRING(3*4+2) + PRINT "(3 * 4) + 2 = " + STRING((3*4)+2) + PRINT "3 * (4 + 2) = " + STRING(3*(4+2)) +END SUB diff --git a/Examples/Core/Operators/bitshift.bas b/Examples/Core/Operators/bitshift.bas new file mode 100644 index 0000000..237e3ec --- /dev/null +++ b/Examples/Core/Operators/bitshift.bas @@ -0,0 +1,24 @@ +FUNCTION toHexString(N AS INTEGER) AS STRING + DIM S AS STRING + DIM I, J AS INTEGER + + S = "" + + FOR I=1 TO 8 + J = N & 0x0000000f + IF (J < 10) THEN + S = CHR$(ASC("0") + J) + S + ELSE + S = CHR$(ASC("A") + (J-10)) + S + END IF + N = N >> 4 + END FOR + + toHexString = "0x" + S +END FUNCTION + +SUB MAIN + PRINT "0x000000f0 << 4 = " + toHexString(0x000000f0 << 4) + PRINT "0xf0000000 >> 4 = " + toHexString(0xf0000000 >> 4) + PRINT "0xf0000000 >>> 4 = " + toHexString(0xf0000000 >>> 4) +END SUB diff --git a/Examples/Core/Operators/bitwise.bas b/Examples/Core/Operators/bitwise.bas new file mode 100644 index 0000000..83f6de6 --- /dev/null +++ b/Examples/Core/Operators/bitwise.bas @@ -0,0 +1,9 @@ +SUB MAIN + PRINT "0x0ffff & 0x00ff = " + STRING(0x0ffff & 0x00ff) + PRINT "0xff00 | 0x00ff = " + STRING(0xff00 | 0x00ff) + PRINT "0xff00 ^ 0x00ff = " + STRING(0xff00 ^ 0x00ff) + PRINT "~0xffffffff = " + STRING(~0xffffffff) + PRINT "~0xfffffffe = " + STRING(~0xfffffffe) + PRINT "~0xffffffffffffffffL = " + STRING(~0xffffffffffffffffL) + PRINT "~0xfffffffffffffffeL = " + STRING(~0xfffffffffffffffeL) +END SUB diff --git a/Examples/Core/Operators/logical.bas b/Examples/Core/Operators/logical.bas new file mode 100644 index 0000000..8fb6fcd --- /dev/null +++ b/Examples/Core/Operators/logical.bas @@ -0,0 +1,26 @@ +SUB MAIN + DIM I, J AS INTEGER + + PRINT "NOT false = " + STRING(NOT false) + PRINT "NOT true = " + STRING(NOT true) + + PRINT "false AND false = " + STRING(false AND false) + PRINT "false AND true = " + STRING(false AND true) + PRINT "true AND false = " + STRING(true AND false) + PRINT "true AND true = " + STRING(true AND true) + + PRINT "false OR false = " + STRING(false OR false) + PRINT "false OR true = " + STRING(false OR true) + PRINT "true OR false = " + STRING(true OR false) + PRINT "true OR true = " + STRING(true OR true) + + FOR I=1 TO 10 + FOR J=1 TO 10 + IF (I=5 AND J=5) THEN + PRINT "I AND J ARE BOTH 5, I=" + STRING(I) + ", J=" + STRING(J) + ELSEIF (I=5 OR J=5) THEN + PRINT "EITHER I OR J IS 5, I=" + STRING(I) + ", J=" + STRING(J) + END IF + END FOR + END FOR +END SUB diff --git a/Examples/Core/Operators/relational.bas b/Examples/Core/Operators/relational.bas new file mode 100644 index 0000000..3f3bdb4 --- /dev/null +++ b/Examples/Core/Operators/relational.bas @@ -0,0 +1,8 @@ +SUB MAIN + PRINT "(10 = 12) = " + STRING(10 = 12) + PRINT "(10 <> 12) = " + STRING(10 <> 12) + PRINT "(10 < 12) = " + STRING(10 < 12) + PRINT "(10 <= 12) = " + STRING(10 <= 12) + PRINT "(10 > 12) = " + STRING(10 > 12) + PRINT "(10 >= 12) = " + STRING(10 >= 12) +END SUB diff --git a/Examples/Core/array.bas b/Examples/Core/array.bas new file mode 100644 index 0000000..859a219 --- /dev/null +++ b/Examples/Core/array.bas @@ -0,0 +1,31 @@ +SUB PASS_ARRAY_1D(ARRAY(3) AS INTEGER) + DIM I AS INTEGER + FOR I=1 TO 3 + PRINT "PASS_ARRAY_1D> ARRAY(" + STRING(I) + ")=" + STRING(ARRAY(I)) + END FOR +END SUB + +SUB PASS_ARRAY_2D(ARRAY(3,3) AS INTEGER) + DIM I,J AS INTEGER + FOR I=1 TO 3 + FOR J=1 TO 3 + PRINT "PASS_ARRAY_2D> ARRAY(" + STRING(I) + "," + STRING(J) + ")=" + STRING(ARRAY(I,J)) + END FOR + END FOR +END SUB + +SUB MAIN + DIM ARRAY1(3) AS INTEGER + DIM ARRAY2(3,3) AS INTEGER + DIM I,J AS INTEGER + + FOR I=1 TO 3 + ARRAY1(I) = I + FOR J=1 TO 3 + ARRAY2(I,J) = (I-1) * 3 + J + END FOR + END FOR + + CALL PASS_ARRAY_1D(ARRAY1) + CALL PASS_ARRAY_2D(ARRAY2) +END SUB diff --git a/Examples/Core/data.bas b/Examples/Core/data.bas new file mode 100644 index 0000000..ee14688 --- /dev/null +++ b/Examples/Core/data.bas @@ -0,0 +1,56 @@ +SUB MAIN + DIM S AS STRING + DIM X AS DOUBLE + DIM I, N AS INTEGER + + PRINT "Starting" + + RESTORE dataList1 + READ S + PRINT S + READ N + FOR I=1 TO N + READ X + PRINT X + END FOR + + RESTORE dataList2 + READ S + PRINT S + READ N + FOR I=1 TO N + READ S + PRINT S + END FOR + + RESTORE dataList3 + READ S + PRINT S + READ N + FOR I=1 TO N + READ S + PRINT S + END FOR + + PRINT "Finished" + + datalist1: + DATA Data List 1 + DATA 9 + DATA 1,2,3 + DATA 4,5,6 + DATA 7,8,9 + + dataList2: + DATA Data List 2 + DATA 3 + DATA ABC,DEF,GHI + + dataList3: + DATA Data List 3 + DATA 5 + DATA "Hello World","Hello, World!" + DATA Hello\ World,Hello\\World + DATA \"Hello World\" + +END SUB diff --git a/Examples/Core/dim.bas b/Examples/Core/dim.bas new file mode 100644 index 0000000..edc9dd9 --- /dev/null +++ b/Examples/Core/dim.bas @@ -0,0 +1,21 @@ +SUB MAIN + DIM MONTH_ARRAY(12) AS STRING + DIM I AS INTEGER + + MONTH_ARRAY(1)="January" + MONTH_ARRAY(2)="February" + MONTH_ARRAY(3)="March" + MONTH_ARRAY(4)="April" + MONTH_ARRAY(5)="May" + MONTH_ARRAY(6)="June" + MONTH_ARRAY(7)="July" + MONTH_ARRAY(8)="August" + MONTH_ARRAY(9)="September" + MONTH_ARRAY(10)="October" + MONTH_ARRAY(11)="November" + MONTH_ARRAY(12)="December" + + FOR I=1 TO 12 + PRINT "Month " + STRING(I) + " = " + MONTH_ARRAY(I) + END FOR +END SUB \ No newline at end of file diff --git a/Examples/Core/for.bas b/Examples/Core/for.bas new file mode 100644 index 0000000..8bbc39e --- /dev/null +++ b/Examples/Core/for.bas @@ -0,0 +1,25 @@ +SUB MAIN + DIM I, J AS INTEGER + + PRINT "FOR Loop counting from 1 up to 10" + FOR I=1 TO 10 + PRINT "I=" + STRING(I) + END FOR + + PRINT "FOR Loop counting from 1 to 50 in steps of 10" + FOR I=1 TO 50 STEP 10 + PRINT "I=" + STRING(I) + END FOR + + PRINT "FOR Loop counting from 99 down to 11 in steps of -11" + FOR I=99 TO 11 STEP -11 + PRINT "I=" + STRING(I) + END FOR + + PRINT "Nested FOR Loops, Both Loops are counting from 0 TO 9" + FOR I=0 TO 9 + FOR J=0 TO 9 + PRINT "I=" + STRING(I) + ", J=" + STRING(J) + END FOR + END FOR +END SUB \ No newline at end of file diff --git a/Examples/Core/function.bas b/Examples/Core/function.bas new file mode 100644 index 0000000..82fa2c3 --- /dev/null +++ b/Examples/Core/function.bas @@ -0,0 +1,7 @@ +FUNCTION SUM(X AS INTEGER, Y AS INTEGER) AS INTEGER + SUM = X + Y +END FUNCTION + +SUB MAIN + PRINT SUM(5, 7) +END SUB \ No newline at end of file diff --git a/Examples/Core/if.bas b/Examples/Core/if.bas new file mode 100644 index 0000000..6916352 --- /dev/null +++ b/Examples/Core/if.bas @@ -0,0 +1,26 @@ +SUB MAIN + DIM I AS INTEGER + FOR I=1 TO 10 + IF (I = 1) THEN + PRINT "ONE" + ELSEIF (I = 2) THEN + PRINT "TWO" + ELSEIF (I = 3) THEN + PRINT "THREE" + ELSEIF (I = 4) THEN + PRINT "FOUR" + ELSEIF (I = 5) THEN + PRINT "FIVE" + ELSEIF (I = 6) THEN + PRINT "SIX" + ELSEIF (I = 7) THEN + PRINT "SEVEN" + ELSEIF (I = 8) THEN + PRINT "EIGHT" + ELSEIF (I = 9) THEN + PRINT "NINE" + ELSE + PRINT "TEN" + END IF + END FOR +END SUB diff --git a/Examples/Core/input.bas b/Examples/Core/input.bas new file mode 100644 index 0000000..75f23f3 --- /dev/null +++ b/Examples/Core/input.bas @@ -0,0 +1,5 @@ +SUB MAIN + DIM S AS STRING + INPUT "What is your name?",S + PRINT "Hello " + S +END SUB diff --git a/Examples/Core/repeat.bas b/Examples/Core/repeat.bas new file mode 100644 index 0000000..8d06fed --- /dev/null +++ b/Examples/Core/repeat.bas @@ -0,0 +1,9 @@ +SUB MAIN + DIM I AS INTEGER + I=1 + REPEAT + PRINT I + I=I+1 + UNTIL I=10 + PRINT "Finished" +END SUB \ No newline at end of file diff --git a/Examples/Core/sleep.bas b/Examples/Core/sleep.bas new file mode 100644 index 0000000..9b3dfed --- /dev/null +++ b/Examples/Core/sleep.bas @@ -0,0 +1,8 @@ +SUB MAIN + DIM I AS INTEGER + FOR I=1 TO 10 + PRINT I + SLEEP 1000 + END FOR + PRINT "Finished" +END SUB diff --git a/Examples/Core/throw.bas b/Examples/Core/throw.bas new file mode 100644 index 0000000..19ce28d --- /dev/null +++ b/Examples/Core/throw.bas @@ -0,0 +1,26 @@ +SUB MAIN + DIM I AS INTEGER + DIM ERR AS STRING + + TRY + FOR I=1 TO 10 + PRINT I + IF (I=5) THEN + THROW "I=5" + END IF + END FOR + CATCH ERR + PRINT "ERROR> " + ERR + + /* + * THROW A Second Error from within the Error Handler + * This time there isn't a current error handler so it + * will cause the program to abort - you will notice + * that the program doesn't print "Program Finished". + */ + + THROW ERR + " THROWN by ERROR1" + END TRY + + PRINT "Program Finished" +END SUB \ No newline at end of file diff --git a/Examples/Core/try.bas b/Examples/Core/try.bas new file mode 100644 index 0000000..a0293c4 --- /dev/null +++ b/Examples/Core/try.bas @@ -0,0 +1,23 @@ +SUB MAIN + DIM I AS INTEGER + DIM ERR1 AS STRING + DIM ERR2 AS STRING + + TRY + TRY + FOR I=1 TO 10 + PRINT I + IF (I=5) THEN + THROW "I=5" + END IF + END FOR + CATCH ERR1 + PRINT "ERROR1> " + ERR1 + THROW ERR1 + " THROWN by ERROR1" + ENDTRY + CATCH ERR2 + PRINT "ERROR2> " + ERR2 + END TRY + + PRINT "Program Finished" +END SUB diff --git a/Examples/Core/while.bas b/Examples/Core/while.bas new file mode 100644 index 0000000..e2644f7 --- /dev/null +++ b/Examples/Core/while.bas @@ -0,0 +1,9 @@ +SUB MAIN + DIM I AS INTEGER + I=1 + WHILE I<10 + PRINT I + I=I+1 + END WHILE + PRINT "Finished" +END SUB \ No newline at end of file diff --git a/Examples/Dialogues/alert.bas b/Examples/Dialogues/alert.bas new file mode 100644 index 0000000..9dfcd7c --- /dev/null +++ b/Examples/Dialogues/alert.bas @@ -0,0 +1,12 @@ +SUB MAIN + DIM R AS INTEGER + R = ALERT("OK Dialog", "OK Dialog Message which cannot be cancelled", "OK", "", "", FALSE) + PRINT R + R = ALERT("OK Dialog", "OK Dialog Message which can be cancelled", "OK", "", "", TRUE) + PRINT R + R = ALERT("Yes/No Dialog", "Yes/No Dialog Message", "Yes", "", "No", FALSE) + PRINT R + R = ALERT("Yes/Maybe/No Dialog", "Yes/Maybe/No Dialog Message", "Yes", "Maybe", "No", FALSE) + PRINT R + PRINT "*** Finished ***" +END SUB diff --git a/Examples/Dialogues/select.bas b/Examples/Dialogues/select.bas new file mode 100644 index 0000000..7318520 --- /dev/null +++ b/Examples/Dialogues/select.bas @@ -0,0 +1,14 @@ +SUB MAIN + DIM ITEM(5) AS STRING + DIM R AS INTEGER + ITEM(1)="A" + ITEM(2)="B" + ITEM(3)="C" + ITEM(4)="D" + ITEM(5)="E" + R = SELECT("Select One - Not Cancellable", ITEM, FALSE) + PRINT R + R = SELECT("Select One - Cancellable", ITEM, TRUE) + PRINT R + PRINT "*** Finished ***" +END SUB diff --git a/Examples/Dialogues/selectmulti.bas b/Examples/Dialogues/selectmulti.bas new file mode 100644 index 0000000..509149a --- /dev/null +++ b/Examples/Dialogues/selectmulti.bas @@ -0,0 +1,37 @@ +SUB MAIN + DIM ITEM(5) AS STRING + DIM FLAG(5) AS BOOLEAN + DIM I AS INTEGER + ITEM(1)="A" + ITEM(2)="B" + ITEM(3)="C" + ITEM(4)="D" + ITEM(5)="E" + FLAG(1)=FALSE + FLAG(2)=FALSE + FLAG(3)=FALSE + FLAG(4)=FALSE + FLAG(5)=FALSE + DIM R AS INTEGER + R = SELECTMULTI("OK Dialog", ITEM, FLAG, "OK", "", "", FALSE) + PRINT "R=" + STR$(R) + FOR I=1 TO 5 + PRINT FLAG(I) + END FOR + R = SELECTMULTI("OK Dialog", ITEM, FLAG, "OK", "", "", TRUE) + PRINT "R=" + STR$(R) + FOR I=1 TO 5 + PRINT FLAG(I) + END FOR + R = SELECTMULTI("Yes/No Dialog", ITEM, FLAG, "Yes", "", "No", FALSE) + PRINT "R=" + STR$(R) + FOR I=1 TO 5 + PRINT FLAG(I) + END FOR + R = SELECTMULTI("Yes/Maybe/No Dialog", ITEM, FLAG, "Yes", "Maybe", "No", FALSE) + PRINT "R=" + STR$(R) + FOR I=1 TO 5 + PRINT FLAG(I) + END FOR + PRINT "*** Finished ***" +END SUB diff --git a/Examples/Dialogues/selectone.bas b/Examples/Dialogues/selectone.bas new file mode 100644 index 0000000..f7b499e --- /dev/null +++ b/Examples/Dialogues/selectone.bas @@ -0,0 +1,24 @@ +SUB MAIN + DIM ITEM(5) AS STRING + DIM SELECTED AS INTEGER + DIM R AS INTEGER + ITEM(1)="A" + ITEM(2)="B" + ITEM(3)="C" + ITEM(4)="D" + ITEM(5)="E" + SELECTED=-1 + R = SELECTONE("OK Dialog", ITEM, SELECTED, "OK", "", "", FALSE) + PRINT R + PRINT SELECTED + R = SELECTONE("OK Dialog", ITEM, SELECTED, "OK", "", "", TRUE) + PRINT R + PRINT SELECTED + R = SELECTONE("Yes/No Dialog", ITEM, SELECTED, "Yes", "", "No", FALSE) + PRINT R + PRINT SELECTED + R = SELECTONE("Yes/Maybe/No Dialog", ITEM, SELECTED, "Yes", "Maybe", "No", FALSE) + PRINT R + PRINT SELECTED + PRINT "*** Finished ***" +END SUB diff --git a/Examples/FileIO/appendfile.dat b/Examples/FileIO/appendfile.dat new file mode 100644 index 0000000..e9b61b8 Binary files /dev/null and b/Examples/FileIO/appendfile.dat differ diff --git a/Examples/FileIO/fileio.bas b/Examples/FileIO/fileio.bas new file mode 100644 index 0000000..a7f3bda --- /dev/null +++ b/Examples/FileIO/fileio.bas @@ -0,0 +1,41 @@ +SUB MAIN + DIM bool AS BOOLEAN + DIM b AS BYTE + DIM w AS SHORT + DIM i AS INTEGER + DIM l AS LONG + DIM f AS FLOAT + DIM d AS DOUBLE + DIM s AS STRING + DIM c AS COMPLEX + + PRINT "Writing file" + OPEN #1,"fileio.dat","w" + PUT #1,true + PUT #1,BYTE(45) + PUT #1,SHORT(768) + PUT #1,123 + CLOSE #1 + + PRINT "Appending to file" + OPEN #1,"fileio.dat","a" + PUT #1,9876l + PUT #1,"hello" + PUT #1,COMPLEX(3.1,-2.5) + PUT #1,3.1f + PUT #1,pi + CLOSE #1 + + PRINT "Reading file" + OPEN #1,"fileio.dat","r" + GET #1,bool,b,w,i,l + GET #1,s + GET #1,c,f,d + CLOSE #1 + + PRINT bool + PRINT b,w,i,l + PRINT s + PRINT c + PRINT f,d +END SUB diff --git a/Examples/FileIO/fileio.dat b/Examples/FileIO/fileio.dat new file mode 100644 index 0000000..7c76faa Binary files /dev/null and b/Examples/FileIO/fileio.dat differ diff --git a/Examples/FileIO/run_logger.bas b/Examples/FileIO/run_logger.bas new file mode 100644 index 0000000..425c006 --- /dev/null +++ b/Examples/FileIO/run_logger.bas @@ -0,0 +1,51 @@ +SUB MAIN() + DIM TM AS DOUBLE + DIM DD,MM,CCYY AS INTEGER + DIM HRS,MINS,SECS,MILLI AS INTEGER + DIM S AS STRING + + DIM DATAFILE AS STRING + + DATAFILE = "appendfile.dat" + + TM=NOW() + DD=DAY(TM) + MM=MONTH(TM) + CCYY=YEAR(TM) + HRS=HOUR(TM) + MINS=MINUTE(TM) + SECS=SECOND(TM) + MILLI=MILLISECOND(TM) + S=STR$(DD) + "/" + STR$(MM) + "/" + STR$(CCYY) + " " + STR$(HRS) + ":" + STR$(MINS) + ":" + STR$(SECS) + "." + STR$(MILLI) + + REM + REM ================================ + REM Append Current Time to data file + REM ================================ + REM + + PRINT "Appending: " + S + OPEN #1,DATAFILE,"a" + PUT #1,S + CLOSE #1 + + REM + REM ================================================= + REM Read back and display all times in appendfile.dat + REM ================================================= + REM + + PRINT "List of times in " + CHR$(0x22) + "appendfile.dat" + CHR$(0x22) + + OPEN #1,DATAFILE,"r" + TRY + WHILE (TRUE) + GET #1,S + PRINT S + END WHILE + CATCH S + PRINT "End of File" + END TRY + CLOSE #1 +END SUB + diff --git a/Examples/Graphics/alpha.bas b/Examples/Graphics/alpha.bas new file mode 100644 index 0000000..2377fee --- /dev/null +++ b/Examples/Graphics/alpha.bas @@ -0,0 +1,23 @@ +SUB MAIN + DIM W, H AS INTEGER + DIM RW, RH AS INTEGER + DIM X, Y AS INTEGER + + GRAPHICS + + W = SCREENWIDTH() + H = SCREENHEIGHT() + RW = W / 2 + RH = H / 2 + X = RW / 2 + Y = RH / 2 + + SETCOLOR 0,0,0 + CLS + SETCOLOR 255,0,0 + FILLRECT X,Y,RW,RH + SETCOLOR 0,255,0,128 + FILLRECT X*2,Y*2,RW,RH + REPAINT + SLEEP 5000 +END SUB \ No newline at end of file diff --git a/Examples/Graphics/crossplot.bas b/Examples/Graphics/crossplot.bas new file mode 100644 index 0000000..46f11fd --- /dev/null +++ b/Examples/Graphics/crossplot.bas @@ -0,0 +1,87 @@ +SUB CROSSPLOT(NP AS INTEGER, XARRAY(1) AS DOUBLE, YARRAY(1) AS DOUBLE) + DIM LEFT, RIGHT, TOP, BOTTOM AS INTEGER + DIM NX, NY AS INTEGER + DIM W, H AS INTEGER + DIM XDELTA, YDELTA AS DOUBLE + DIM XPOS, YPOS AS DOUBLE + DIM I AS INTEGER + DIM S AS STRING + + DIM BORDER AS INTEGER + + BORDER = 40 + + TOP = BORDER + BOTTOM = SCREENHEIGHT() - BORDER * 2 + LEFT = BORDER + RIGHT = SCREENWIDTH() - BORDER * 2 + + SETCOLOR 0,0,0 + CLS + + SETCOLOR 255,255,0 + NX = 10 + NY = 10 + + XDELTA = DOUBLE(RIGHT - LEFT) / DOUBLE(NX) + YDElTA = DOUBLE(BOTTOM - TOP) / DOUBLE(NY) + + FOR I=0 TO NX + XPOS = DOUBLE(LEFT) + DOUBLE(I) * XDELTA + DRAWLINE XPOS, TOP, XPOS, BOTTOM + END FOR + + FOR I=0 TO NY + YPOS = DOUBLE(TOP) + DOUBLE(I) * YDELTA + DRAWLINE LEFT, YPOS, RIGHT, YPOS + END FOR + + S = "0.0" + W = STRINGWIDTH(S)+1 + H = STRINGHEIGHT(S)+1 + DRAWSTRING S,LEFT-W,BOTTOM + DRAWSTRING S,LEFT,BOTTOM+H + + S = "1.0" + W = STRINGWIDTH(S)+1 + H = STRINGHEIGHT(S)+1 + DRAWSTRING S,LEFT-W,TOP+H + DRAWSTRING S,RIGHT-W,BOTTOM+H + + S = "Y-Axis" + W = STRINGWIDTH(S)+1 + H = STRINGHEIGHT(S)+1 + DRAWSTRING S,LEFT-W,TOP+(BOTTOM-TOP-H)/2 + + S = "X-Axis" + W = STRINGWIDTH(S)+1 + H = STRINGHEIGHT(S)+1 + DRAWSTRING S,LEFT+(RIGHT-LEFT-W)/2,BOTTOM+H + + SETCOLOR 255,255,255 + + FOR I=1 TO NP + XPOS = DOUBLE(LEFT) + XARRAY(I) * DOUBLE(RIGHT - LEFT) + YPOS = DOUBLE(TOP) + YARRAY(I) * DOUBLE(BOTTOM - TOP) + PLOT XPOS, YPOS + END FOR +END SUB + +SUB MAIN + DIM XARRAY(500), YARRAY(500) AS DOUBLE + DIM NP AS INTEGER + DIM I AS INTEGER + + NP = 500 + + FOR I=1 TO NP + XARRAY(I) = RND(0.0) + YARRAY(I) = RND(0.0) + END FOR + + GRAPHICS + CALL CROSSPLOT(NP, XARRAY, YARRAY) + REPAINT + + SLEEP 5000 +END SUB \ No newline at end of file diff --git a/Examples/Graphics/drawarc.bas b/Examples/Graphics/drawarc.bas new file mode 100644 index 0000000..4f2eb00 --- /dev/null +++ b/Examples/Graphics/drawarc.bas @@ -0,0 +1,25 @@ +SUB MAIN + DIM W, H AS INTEGER + DIM RW, RH AS INTEGER + DIM X, Y AS INTEGER + + GRAPHICS + + W = SCREENWIDTH() + H = SCREENHEIGHT() + RW = W / 2 + RH = H / 2 + X = RW / 2 + Y = RH / 2 + + SETCOLOR 0,0,0 + CLS + SETCOLOR 255,255,255 + DRAWRECT X,Y,RW,RH + SETCOLOR 255,0,0 + DRAWARC X,Y,RW,RH,5,90 + SETCOLOR 0,255,0 + DRAWARC X,Y,RW,RH,-5,-90 + REPAINT + SLEEP 5000 +END SUB \ No newline at end of file diff --git a/Examples/Graphics/drawcircle.bas b/Examples/Graphics/drawcircle.bas new file mode 100644 index 0000000..38dd121 --- /dev/null +++ b/Examples/Graphics/drawcircle.bas @@ -0,0 +1,21 @@ +SUB MAIN + DIM CX, CY, R AS INTEGER + + GRAPHICS + + CY=SCREENHEIGHT()/2 + CX=SCREENWIDTH()/2 + + IF (CX < CY) THEN + R=CX/2 + ELSE + R=CY/2 + END IF + + SETCOLOR 0,0,0 + CLS + SETCOLOR 255,255,255 + DRAWCIRCLE CX,CY,R + REPAINT + SLEEP 5000 +END SUB diff --git a/Examples/Graphics/drawline.bas b/Examples/Graphics/drawline.bas new file mode 100644 index 0000000..86db16d --- /dev/null +++ b/Examples/Graphics/drawline.bas @@ -0,0 +1,32 @@ +SUB MAIN + DIM HEIGHT, WIDTH AS INTEGER + DIM I AS INTEGER + + GRAPHICS + + HEIGHT=SCREENHEIGHT() + WIDTH=SCREENWIDTH() + + SETCOLOR 0,0,0 // BLACK + CLS + + SETCOLOR 255,255,0 // YELLOW + FOR I=0 to WIDTH STEP 5 + PRINT "I=" + STR$(I) + DRAWLINE 0,0,I,HEIGHT + END FOR + + SETCOLOR 0,255,255 // CYAN + FOR I=0 TO WIDTH STEP 5 + DRAWLINE WIDTH,0,I,HEIGHT + END FOR + + REPAINT + + FOR I=1 TO 10 + SLEEP 1000 + TEXT + SLEEP 1000 + GRAPHICS + END FOR +END SUB \ No newline at end of file diff --git a/Examples/Graphics/drawoval.bas b/Examples/Graphics/drawoval.bas new file mode 100644 index 0000000..d8f86a7 --- /dev/null +++ b/Examples/Graphics/drawoval.bas @@ -0,0 +1,21 @@ +SUB MAIN + DIM W, H AS INTEGER + DIM RW, RH AS INTEGER + DIM X, Y AS INTEGER + + GRAPHICS + + W = SCREENWIDTH() + H = SCREENHEIGHT() + RW = W / 2 + RH = H / 2 + X = RW / 2 + Y = RH / 2 + + SETCOLOR 0,0,0 + CLS + SETCOLOR 255,255,255 + DRAWOVAL X,Y,RW,RH + REPAINT + SLEEP 5000 +END SUB \ No newline at end of file diff --git a/Examples/Graphics/drawpie.bas b/Examples/Graphics/drawpie.bas new file mode 100644 index 0000000..bfc1391 --- /dev/null +++ b/Examples/Graphics/drawpie.bas @@ -0,0 +1,25 @@ +SUB MAIN + DIM W, H AS INTEGER + DIM RW, RH AS INTEGER + DIM X, Y AS INTEGER + + GRAPHICS + + W = SCREENWIDTH() + H = SCREENHEIGHT() + RW = W / 2 + RH = H / 2 + X = RW / 2 + Y = RH / 2 + + SETCOLOR 0,0,0 + CLS + SETCOLOR 255,255,255 + DRAWRECT X,Y,RW,RH + SETCOLOR 255,0,0 + DRAWPIE X,Y,RW,RH,5,90 + SETCOLOR 0,255,0 + DRAWPIE X,Y,RW,RH,-5,-90 + REPAINT + SLEEP 5000 +END SUB \ No newline at end of file diff --git a/Examples/Graphics/drawrect.bas b/Examples/Graphics/drawrect.bas new file mode 100644 index 0000000..d00d485 --- /dev/null +++ b/Examples/Graphics/drawrect.bas @@ -0,0 +1,21 @@ +SUB MAIN + DIM W, H AS INTEGER + DIM RW, RH AS INTEGER + DIM X, Y AS INTEGER + + GRAPHICS + + W = SCREENWIDTH() + H = SCREENHEIGHT() + RW = W / 2 + RH = H / 2 + X = RW / 2 + Y = RH / 2 + + SETCOLOR 0,0,0 + CLS + SETCOLOR 255,255,255 + DRAWRECT X,Y,RW,RH + REPAINT + SLEEP 5000 +END SUB \ No newline at end of file diff --git a/Examples/Graphics/drawroundrect.bas b/Examples/Graphics/drawroundrect.bas new file mode 100644 index 0000000..05ac500 --- /dev/null +++ b/Examples/Graphics/drawroundrect.bas @@ -0,0 +1,21 @@ +SUB MAIN + DIM W, H AS INTEGER + DIM RW, RH AS INTEGER + DIM X, Y AS INTEGER + + GRAPHICS + + W = SCREENWIDTH() + H = SCREENHEIGHT() + RW = W / 2 + RH = H / 2 + X = RW / 2 + Y = RH / 2 + + SETCOLOR 0,0,0 + CLS + SETCOLOR 255,255,255 + DRAWROUNDRECT X,Y,RW,RH,50,50 + REPAINT + SLEEP 5000 +END SUB \ No newline at end of file diff --git a/Examples/Graphics/drawstring.bas b/Examples/Graphics/drawstring.bas new file mode 100644 index 0000000..20f2252 --- /dev/null +++ b/Examples/Graphics/drawstring.bas @@ -0,0 +1,11 @@ +SUB MAIN + GRAPHICS + SETCOLOR 0,0,0 + CLS + SETCOLOR 255,0,0 + DRAWSTRING "HELLO",0,SCREENHEIGHT()/4 + SETCOLOR 255,255,0 + DRAWSTRING "WORLD",0,SCREENHEIGHT()/2 + REPAINT + SLEEP 5000 +END SUB \ No newline at end of file diff --git a/Examples/Graphics/fillarc.bas b/Examples/Graphics/fillarc.bas new file mode 100644 index 0000000..aee1493 --- /dev/null +++ b/Examples/Graphics/fillarc.bas @@ -0,0 +1,25 @@ +SUB MAIN + DIM W, H AS INTEGER + DIM RW, RH AS INTEGER + DIM X, Y AS INTEGER + + GRAPHICS + + W = SCREENWIDTH() + H = SCREENHEIGHT() + RW = W / 2 + RH = H / 2 + X = RW / 2 + Y = RH / 2 + + SETCOLOR 0,0,0 + CLS + SETCOLOR 255,255,255 + DRAWRECT X,Y,RW,RH + SETCOLOR 255,0,0 + FILLARC X,Y,RW,RH,5,90 + SETCOLOR 0,255,0 + FILLARC X,Y,RW,RH,-5,-90 + REPAINT + SLEEP 5000 +END SUB \ No newline at end of file diff --git a/Examples/Graphics/fillcircle.bas b/Examples/Graphics/fillcircle.bas new file mode 100644 index 0000000..427301f --- /dev/null +++ b/Examples/Graphics/fillcircle.bas @@ -0,0 +1,21 @@ +SUB MAIN + DIM CX, CY, R AS INTEGER + + GRAPHICS + + CY=SCREENHEIGHT()/2 + CX=SCREENWIDTH()/2 + + IF (CX < CY) THEN + R=CX/2 + ELSE + R=CY/2 + END IF + + SETCOLOR 0,0,0 + CLS + SETCOLOR 255,255,255 + FILLCIRCLE CX,CY,R + REPAINT + SLEEP 5000 +END SUB diff --git a/Examples/Graphics/filloval.bas b/Examples/Graphics/filloval.bas new file mode 100644 index 0000000..777e9e8 --- /dev/null +++ b/Examples/Graphics/filloval.bas @@ -0,0 +1,21 @@ +SUB MAIN + DIM W, H AS INTEGER + DIM RW, RH AS INTEGER + DIM X, Y AS INTEGER + + GRAPHICS + + W = SCREENWIDTH() + H = SCREENHEIGHT() + RW = W / 2 + RH = H / 2 + X = RW / 2 + Y = RH / 2 + + SETCOLOR 0,0,0 + CLS + SETCOLOR 255,255,255 + FILLOVAL X,Y,RW,RH + REPAINT + SLEEP 5000 +END SUB \ No newline at end of file diff --git a/Examples/Graphics/fillpie.bas b/Examples/Graphics/fillpie.bas new file mode 100644 index 0000000..8560885 --- /dev/null +++ b/Examples/Graphics/fillpie.bas @@ -0,0 +1,25 @@ +SUB MAIN + DIM W, H AS INTEGER + DIM RW, RH AS INTEGER + DIM X, Y AS INTEGER + + GRAPHICS + + W = SCREENWIDTH() + H = SCREENHEIGHT() + RW = W / 2 + RH = H / 2 + X = RW / 2 + Y = RH / 2 + + SETCOLOR 0,0,0 + CLS + SETCOLOR 255,255,255 + DRAWRECT X,Y,RW,RH + SETCOLOR 255,0,0 + FILLPIE X,Y,RW,RH,5,90 + SETCOLOR 0,255,0 + FILLPIE X,Y,RW,RH,-5,-90 + REPAINT + SLEEP 5000 +END SUB diff --git a/Examples/Graphics/fillrect.bas b/Examples/Graphics/fillrect.bas new file mode 100644 index 0000000..4b28c67 --- /dev/null +++ b/Examples/Graphics/fillrect.bas @@ -0,0 +1,21 @@ +SUB MAIN + DIM W, H AS INTEGER + DIM RW, RH AS INTEGER + DIM X, Y AS INTEGER + + GRAPHICS + + W = SCREENWIDTH() + H = SCREENHEIGHT() + RW = W / 2 + RH = H / 2 + X = RW / 2 + Y = RH / 2 + + SETCOLOR 0,0,0 + CLS + SETCOLOR 255,255,255 + FILLRECT X,Y,RW,RH + REPAINT + SLEEP 5000 +END SUB diff --git a/Examples/Graphics/fillroundrect.bas b/Examples/Graphics/fillroundrect.bas new file mode 100644 index 0000000..28194e2 --- /dev/null +++ b/Examples/Graphics/fillroundrect.bas @@ -0,0 +1,21 @@ +SUB MAIN + DIM W, H AS INTEGER + DIM RW, RH AS INTEGER + DIM X, Y AS INTEGER + + GRAPHICS + + W = SCREENWIDTH() + H = SCREENHEIGHT() + RW = W / 2 + RH = H / 2 + X = RW / 2 + Y = RH / 2 + + SETCOLOR 0,0,0 + CLS + SETCOLOR 255,255,255 + FILLROUNDRECT X,Y,RW,RH,50,50 + REPAINT + SLEEP 5000 +END SUB diff --git a/Examples/Graphics/plot.bas b/Examples/Graphics/plot.bas new file mode 100644 index 0000000..436c92c --- /dev/null +++ b/Examples/Graphics/plot.bas @@ -0,0 +1,16 @@ +SUB MAIN + DIM WIDTH, HEIGHT AS INTEGER + + GRAPHICS + WIDTH=SCREENWIDTH() + HEIGHT=SCREENHEIGHT() + + SETCOLOR 0,0,0 + CLS + + WHILE true + SETCOLOR RND(256),RND(256),RND(256) + PLOT RND(WIDTH),RND(HEIGHT) + REPAINT + END WHILE +END SUB \ No newline at end of file diff --git a/Examples/Graphics/repaint.bas b/Examples/Graphics/repaint.bas new file mode 100644 index 0000000..8d8b3a3 --- /dev/null +++ b/Examples/Graphics/repaint.bas @@ -0,0 +1,10 @@ +SUB MAIN + DIM I AS INTEGER + GRAPHICS + FOR I=1 TO 20 + SETCOLOR RND(256),RND(256),RND(256) + CLS + REPAINT + SLEEP 500 + END FOR +END SUB diff --git a/Examples/Graphics/rotated_text.bas b/Examples/Graphics/rotated_text.bas new file mode 100644 index 0000000..1128569 --- /dev/null +++ b/Examples/Graphics/rotated_text.bas @@ -0,0 +1,32 @@ +SUB MAIN + GRAPHICS + SETCOLOR 0,0,0 // BLACK + + GSAVE + TRANSLATE 100,100 + SETCOLOR 255,0,0 + CALL ROTATEDTEXT + GRESTORE + + GSAVE + TRANSLATE 300,200 + SETCOLOR 0,255,0 + CALL ROTATEDTEXT + GRESTORE + + REPAINT + + SLEEP 5000 +END SUB + +SUB ROTATEDTEXT + DIM I AS INTEGER + DRAWLINE -10,0,10,0 + DRAWLINE 0,-10,0,10 + FOR I=0 TO 359 STEP 30 + GSAVE + ROTATE I + DRAWSTRING "Angle=" + STR$(I), 40, 0 + GRESTORE + END FOR +END SUB \ No newline at end of file diff --git a/Examples/Graphics/setfont.bas b/Examples/Graphics/setfont.bas new file mode 100644 index 0000000..3b23748 --- /dev/null +++ b/Examples/Graphics/setfont.bas @@ -0,0 +1,45 @@ +SUB MAIN + DIM ALPHABET AS STRING + DIM XPOS, YPOS AS INTEGER + + ALPHABET="ABCDEFGHIJKLMNOPQRSTUVWXYZ" + XPOS=0 + YPOS=40 + + GRAPHICS + SETCOLOR 0,0,0 // BLACK + CLS + + SETCOLOR 255,255,255 // WHITE + SETFONT "MONOSPACE", 20 + YPOS=YPOS+STRINGHEIGHT(ALPHABET) + DRAWSTRING ALPHABET,XPOS,YPOS + + SETFONT "SANS_SERIF", 20 + YPOS=YPOS+STRINGHEIGHT(ALPHABET) + DRAWSTRING ALPHABET,XPOS,YPOS + + SETFONT "SERIF", 20 + YPOS=YPOS+STRINGHEIGHT(ALPHABET) + DRAWSTRING ALPHABET,XPOS,YPOS + + SETCOLOR 255,0,0 // RED + SETFONT "MONOSPACE", 25 + YPOS=YPOS+STRINGHEIGHT(ALPHABET) + DRAWSTRING ALPHABET,XPOS,YPOS + + SETCOLOR 0,255,0 // GREEN + SETFONT "SANS_SERIF", 30 + YPOS=YPOS+STRINGHEIGHT(ALPHABET) + DRAWSTRING ALPHABET,XPOS,YPOS + + ROTATE 10 + SETCOLOR 0,0,255 // BLUE + SETFONT "SERIF", 35 + YPOS=YPOS+STRINGHEIGHT(ALPHABET) + DRAWSTRING ALPHABET,XPOS,YPOS + + REPAINT + + SLEEP 5000 +END SUB \ No newline at end of file diff --git a/Examples/Include/library.bas b/Examples/Include/library.bas new file mode 100644 index 0000000..2b31dfb --- /dev/null +++ b/Examples/Include/library.bas @@ -0,0 +1,3 @@ +FUNCTION ADD(A AS DOUBLE, B AS DOUBLE) AS DOUBLE + ADD = A + B +END FUNCTION \ No newline at end of file diff --git a/Examples/Include/main.bas b/Examples/Include/main.bas new file mode 100644 index 0000000..191d055 --- /dev/null +++ b/Examples/Include/main.bas @@ -0,0 +1,6 @@ +#include "library.bas" + +SUB MAIN + PRINT ADD(5.0, 7.0) + PRINT ADD(3.0, -5.0) +END SUB \ No newline at end of file diff --git a/Examples/Include_Files/Convert.bas b/Examples/Include_Files/Convert.bas new file mode 100644 index 0000000..69f72bb --- /dev/null +++ b/Examples/Include_Files/Convert.bas @@ -0,0 +1,13 @@ +REM +REM ================================================== +REM Please make sure the Include Files Enabled setting +REM has been enabled before trying to run this program +REM ================================================== +REM + +#include "Library.bas" + +SUB MAIN + PRINT "100 degC = " + STR$(DegF(100.0)) + " degF" + PRINT "212 degF = " + STR$(DegC(212.0)) + " degC" +END SUB \ No newline at end of file diff --git a/Examples/Include_Files/Library.bas b/Examples/Include_Files/Library.bas new file mode 100644 index 0000000..bb61718 --- /dev/null +++ b/Examples/Include_Files/Library.bas @@ -0,0 +1,7 @@ +FUNCTION DegF(DegC AS DOUBLE) AS DOUBLE + DegF = DegC * 9.0 / 5.0 + 32.0 +END FUNCTION + +FUNCTION DegC(DegF AS DOUBLE) AS DOUBLE + DegC = (DegF - 32.0) * 5.0 / 9.0 +END FUNCTION \ No newline at end of file diff --git a/Examples/Location/location.bas b/Examples/Location/location.bas new file mode 100644 index 0000000..82cfb89 --- /dev/null +++ b/Examples/Location/location.bas @@ -0,0 +1,10 @@ +SUB MAIN + IF (IsLocationAvailable()) THEN + WHILE (TRUE) + PRINT GETALTITUDE(),GETLATITUDE(),GETLONGITUDE() + SLEEP 1000 + END WHILE + ELSE + PRINT "Location is not available" + END IF +END SUB \ No newline at end of file diff --git a/Examples/Maths/atan2.bas b/Examples/Maths/atan2.bas new file mode 100644 index 0000000..91002ab --- /dev/null +++ b/Examples/Maths/atan2.bas @@ -0,0 +1,23 @@ +SUB MAIN + PRINT "---- ATAN2D (Degrees) ----" + + PRINT "ATAN2D(0.0, 0.0)=" + STR$(ATAN2D(0.0, 0.0)) + PRINT "ATAN2D(10.0, 10.0)=" + STR$(ATAN2D(10.0, 10.0)) + PRINT "ATAN2D(10.0, 0.0)=" + STR$(ATAN2D(10.0, 0.0)) + PRINT "ATAN2D(10.0, -10.0)=" + STR$(ATAN2D(10.0, -10.0)) + PRINT "ATAN2D(0.0, -10.0)=" + STR$(ATAN2D(0.0, -10.0)) + PRINT "ATAN2D(-10.0, -10.0)=" + STR$(ATAN2D(-10.0, -10.0)) + PRINT "ATAN2D(-10.0, 0.0)=" + STR$(ATAN2D(-10.0, 0.0)) + PRINT "ATAN2D(-10.0, 10.0)=" + STR$(ATAN2D(-10.0, 10.0)) + + PRINT "\n---- ATAN2 (Radians) ----" + + PRINT "ATAN2(0.0, 0.0)=" + STR$(ATAN2(0.0, 0.0)) + PRINT "ATAN2(10.0, 10.0)=" + STR$(ATAN2(10.0, 10.0)) + PRINT "ATAN2(10.0, 0.0)=" + STR$(ATAN2(10.0, 0.0)) + PRINT "ATAN2(10.0, -10.0)=" + STR$(ATAN2(10.0, -10.0)) + PRINT "ATAN2(0.0, -10.0)=" + STR$(ATAN2(0.0, -10.0)) + PRINT "ATAN2(-10.0, -10.0)=" + STR$(ATAN2(-10.0, -10.0)) + PRINT "ATAN2(-10.0, 0.0)=" + STR$(ATAN2(-10.0, 0.0)) + PRINT "ATAN2(-10.0, 10.0)=" + STR$(ATAN2(-10.0, 10.0)) +END SUB diff --git a/Examples/Maths/hyperbolic.bas b/Examples/Maths/hyperbolic.bas new file mode 100644 index 0000000..6281316 --- /dev/null +++ b/Examples/Maths/hyperbolic.bas @@ -0,0 +1,21 @@ +SUB MAIN + PRINT "---- SINE, COSINE, TANGENTS (HYPERBOLIC) ----" + + PRINT "COSH(1) = " + STRING(COSH(1)) + PRINT "SINH(1) = " + STRING(SINH(1)) + PRINT "TANH(1) = " + STRING(TANH(1)) + + PRINT "ACOSH(1.543) = " + STRING(ACOSH(1.543)) + PRINT "ASINH(1.175) = " + STRING(ASINH(1.175)) + PRINT "ATANH(0.762) = " + STRING(ATANH(0.762)) + + PRINT "\n---- SECANT, COSECANT, COTANGENT (HYPERBOLIC) ----" + + PRINT "SECH(1) = " + STRING(SECH(1)) + PRINT "CSCH(1) = " + STRING(CSCH(1)) + PRINT "COTH(1) = " + STRING(COTH(1)) + + PRINT "ASECH(0.648) = " + STRING(ASECH(0.648)) + PRINT "ACSCH(0.851) = " + STRING(ACSCH(0.851)) + PRINT "ACOTH(1.313) = " + STRING(ACOTH(1.313)) +END SUB diff --git a/Examples/Maths/maths.bas b/Examples/Maths/maths.bas new file mode 100644 index 0000000..f697331 --- /dev/null +++ b/Examples/Maths/maths.bas @@ -0,0 +1,24 @@ +SUB MAIN + DIM I AS INTEGER + + PRINT "---- Logarithm and Power Functions ----" + + PRINT "SQRT(81.0) = " + STRING(SQRT(81.0)) + PRINT "LOG(2.718) = " + STRING(LOG(2.718)) + PRINT "EXP(1.0) = " + STRING(EXP(1.0)) + PRINT "LOG10(100.0) = " + STRING(LOG10(100.0)) + PRINT "EXP10(2) = " + STRING(EXP10(2.0)) + PRINT "POW(5.0, 3.0) = " + STRING(POW(5.0, 3.0)) + + PRINT "---- Miscellaneous Functions ----" + + PRINT "ABS(-3.142) = " + STRING(ABS(-3.142)) + PRINT "ABS(3.142) = " + STRING(ABS(3.142)) + PRINT "ABS(-321L) = " + STRING(ABS(-321L)) + PRINT "ABS(321L) = " + STRING(ABS(321L)) + PRINT "ROUND(" + STRING(PI) + ",3) = " + STRING(ROUND(PI,3)) + + FOR I=1 TO 5 + PRINT "I=" + STRING(I) + ", RND(10) = " + STRING(RND(10)) + END FOR +END SUB diff --git a/Examples/Maths/trig.bas b/Examples/Maths/trig.bas new file mode 100644 index 0000000..6961796 --- /dev/null +++ b/Examples/Maths/trig.bas @@ -0,0 +1,41 @@ +SUB MAIN + PRINT "---- SINE, COSINE, TANGENTS (DEGREES) ----" + + PRINT "COSD(45)=" + STR$(COSD(45)) + PRINT "SIND(45)=" + STR$(SIND(45)) + PRINT "TAND(45)=" + STR$(TAND(45)) + + PRINT "ACOSD(0.707)=" + STR$(ACOSD(0.707)) + PRINT "ASIND(0.707)=" + STR$(ASIND(0.707)) + PRINT "ATAND(1)=" + STR$(ATAND(1)) + + PRINT "\n---- SINE, COSINE, TANGENTS (RADIANS) ----" + + PRINT "COS(0.785)=" + STR$(COS(0.785)) + PRINT "SIN(0.785)=" + STR$(SIN(0.785)) + PRINT "TAN(0.785)=" + STR$(TAN(0.785)) + + PRINT "ACOS(0.707)=" + STR$(ACOS(0.707)) + PRINT "ASIN(0.707)=" + STR$(ASIN(0.707)) + PRINT "ATAN(1)=" + STR$(ATAN(1)) + + PRINT "\n---- SECANT, COSECANT, COTANGENT (DEGREES) ----" + + PRINT "SECD(45)=" + STR$(SECD(45)) + PRINT "CSCD(45)=" + STR$(CSCD(45)) + PRINT "COTD(45)=" + STR$(COTD(45)) + + PRINT "ASECD(1.414)=" + STR$(ASECD(1.414)) + PRINT "ACSCD(1.414)=" + STR$(ACSCD(1.414)) + PRINT "ACOTD(1)=" + STR$(ACOTD(1)) + + PRINT "\n---- SECANT, COSECANT, COTANGENT (RADIANS) ----" + + PRINT "SEC(0.785)=" + STR$(SEC(0.785)) + PRINT "CSC(0.785)=" + STR$(CSC(0.785)) + PRINT "COT(0.785)=" + STR$(COT(0.785)) + + PRINT "ASEC(1.414)=" + STR$(ASEC(1.414)) + PRINT "ACSC(1.414)=" + STR$(ACSC(1.414)) + PRINT "ACOT(1)=" + STR$(ACOT(1)) +END SUB diff --git a/Examples/NetworkIO/network.bas b/Examples/NetworkIO/network.bas new file mode 100644 index 0000000..4e0d152 --- /dev/null +++ b/Examples/NetworkIO/network.bas @@ -0,0 +1,9 @@ +SUB MAIN + DIM S AS STRING + PRINT "Reading from Google" + OPEN #1,"http://www.google.com/","r" + READLINE #1,S + CLOSE #1 + + PRINT s +END SUB diff --git a/Examples/Sensors/accelerometer.bas b/Examples/Sensors/accelerometer.bas new file mode 100644 index 0000000..e23cc88 --- /dev/null +++ b/Examples/Sensors/accelerometer.bas @@ -0,0 +1,11 @@ +SUB MAIN + IF (IsAccelerometerAvailable()) THEN + WHILE (TRUE) + PRINT "--" + PRINT "X=" + STRING(getAccelerometerX()) + ", Y=" + STRING(getAccelerometerY()) + ", Z=" + STRING(getAccelerometerZ()) + SLEEP 1000 + END WHILE + ELSE + PRINT "Accelerometer Sensor is not available on this device" + END IF +END SUB diff --git a/Examples/Sensors/ambienttemperature.bas b/Examples/Sensors/ambienttemperature.bas new file mode 100644 index 0000000..548da94 --- /dev/null +++ b/Examples/Sensors/ambienttemperature.bas @@ -0,0 +1,10 @@ +SUB MAIN + IF (IsAmbientTemperatureAvailable()) THEN + WHILE (TRUE) + PRINT getAmbientTemperature() + SLEEP 1000 + END WHILE + ELSE + PRINT "Ambient Temperature Sensor is not available on this device" + END IF +END SUB \ No newline at end of file diff --git a/Examples/Sensors/gravity.bas b/Examples/Sensors/gravity.bas new file mode 100644 index 0000000..82e438d --- /dev/null +++ b/Examples/Sensors/gravity.bas @@ -0,0 +1,10 @@ +SUB MAIN + IF (IsGravityAvailable()) THEN + WHILE (TRUE) + PRINT "X=" + STRING(getGravityX()) + ", Y=" + STRING(getGravityY()) + ", Z=" + STRING(getGravityZ()) + SLEEP 1000 + END WHILE + ELSE + PRINT "Gravity Sensor is not available on this device" + END IF +END SUB \ No newline at end of file diff --git a/Examples/Sensors/gyroscope.bas b/Examples/Sensors/gyroscope.bas new file mode 100644 index 0000000..a8d0288 --- /dev/null +++ b/Examples/Sensors/gyroscope.bas @@ -0,0 +1,10 @@ +SUB MAIN + IF (IsGyroscopeAvailable()) THEN + WHILE (TRUE) + PRINT "X=" + STRING(getGyroscopeX()) + ", Y=" + STRING(getGyroscopeY()) + ", Z=" + STRING(getGyroscopeZ()) + SLEEP 1000 + END WHILE + ELSE + PRINT "Gyroscope Sensor is not available on this device" + END IF +END SUB \ No newline at end of file diff --git a/Examples/Sensors/light.bas b/Examples/Sensors/light.bas new file mode 100644 index 0000000..3b912bc --- /dev/null +++ b/Examples/Sensors/light.bas @@ -0,0 +1,10 @@ +SUB MAIN + IF (IsLightAvailable()) THEN + WHILE (TRUE) + PRINT getLight() + SLEEP 1000 + END WHILE + ELSE + PRINT "Light Sensor is not available on this device" + END IF +END SUB \ No newline at end of file diff --git a/Examples/Sensors/linearacceleration.bas b/Examples/Sensors/linearacceleration.bas new file mode 100644 index 0000000..1783ebd --- /dev/null +++ b/Examples/Sensors/linearacceleration.bas @@ -0,0 +1,10 @@ +SUB MAIN + IF (IsLinearAccelerationAvailable()) THEN + WHILE (TRUE) + PRINT "X=" + STRING(getLinearAccelerationX()) + ", Y=" + STRING(getLinearAccelerationY()) + ", Z=" + STRING(getLinearAccelerationZ()) + SLEEP 1000 + END WHILE + ELSE + PRINT "Linear Acceleration Sensor is not available on this device" + END IF +END SUB \ No newline at end of file diff --git a/Examples/Sensors/magneticfield.bas b/Examples/Sensors/magneticfield.bas new file mode 100644 index 0000000..e9f0fb1 --- /dev/null +++ b/Examples/Sensors/magneticfield.bas @@ -0,0 +1,10 @@ +SUB MAIN + IF (IsMagneticFieldAvailable()) THEN + WHILE (TRUE) + PRINT "X=" + STRING(getMagneticFieldX()) + ", Y=" + STRING(getMagneticFieldY()) + ", Z=" + STRING(getMagneticFieldZ()) + SLEEP 1000 + END WHILE + ELSE + PRINT "Magnetic Field Sensor is not available on this device" + END IF +END SUB \ No newline at end of file diff --git a/Examples/Sensors/pressure.bas b/Examples/Sensors/pressure.bas new file mode 100644 index 0000000..ea8137c --- /dev/null +++ b/Examples/Sensors/pressure.bas @@ -0,0 +1,10 @@ +SUB MAIN + IF (IsPressureAvailable()) THEN + WHILE (TRUE) + PRINT getPressure() + SLEEP 1000 + END WHILE + ELSE + PRINT "Pressure Sensor is not available on this device" + END IF +END SUB \ No newline at end of file diff --git a/Examples/Sensors/proximity.bas b/Examples/Sensors/proximity.bas new file mode 100644 index 0000000..0fc1ce2 --- /dev/null +++ b/Examples/Sensors/proximity.bas @@ -0,0 +1,10 @@ +SUB MAIN + IF (IsProximityAvailable()) THEN + WHILE (TRUE) + PRINT getProximity() + SLEEP 1000 + END WHILE + ELSE + PRINT "Proximity Sensor is not available on this device" + END IF +END SUB \ No newline at end of file diff --git a/Examples/Sensors/relativehumidity.bas b/Examples/Sensors/relativehumidity.bas new file mode 100644 index 0000000..ac467de --- /dev/null +++ b/Examples/Sensors/relativehumidity.bas @@ -0,0 +1,10 @@ +SUB MAIN + IF (IsRelativeHumidityAvailable()) THEN + WHILE (TRUE) + PRINT getRelativeHumidity() + SLEEP 1000 + END WHILE + ELSE + PRINT "Relative Humidity Sensor is not available on this device" + END IF +END SUB \ No newline at end of file diff --git a/Examples/Sensors/rotationvector.bas b/Examples/Sensors/rotationvector.bas new file mode 100644 index 0000000..c362932 --- /dev/null +++ b/Examples/Sensors/rotationvector.bas @@ -0,0 +1,10 @@ +SUB MAIN + IF (IsRotationVectorAvailable()) THEN + WHILE (TRUE) + PRINT "X=" + STRING(getRotationVectorX()) + ", Y=" + STRING(getRotationVectorY()) + ", Z=" + STRING(getRotationVectorZ()) + SLEEP 1000 + END WHILE + ELSE + PRINT "Rotation Vector Sensor is not available on this device" + END IF +END SUB \ No newline at end of file diff --git a/Examples/Sensors/temperature.bas b/Examples/Sensors/temperature.bas new file mode 100644 index 0000000..0c9e05e --- /dev/null +++ b/Examples/Sensors/temperature.bas @@ -0,0 +1,10 @@ +SUB MAIN + IF (IsTemperatureAvailable()) THEN + WHILE (TRUE) + PRINT getTemperature() + SLEEP 1000 + END WHILE + ELSE + PRINT "Temperature Sensor is not available on this device" + END IF +END SUB \ No newline at end of file diff --git a/Examples/Speech/Hello.bas b/Examples/Speech/Hello.bas new file mode 100644 index 0000000..448b543 --- /dev/null +++ b/Examples/Speech/Hello.bas @@ -0,0 +1,11 @@ +SUB MAIN + PRINT "HELLO" + SPEAK "HELLO" + + WHILE (IsSpeaking()) + SLEEP 100 + END WHILE + + PRINT "GOODBYE" + SPEAK "GOODBYE" +END SUB \ No newline at end of file diff --git a/Examples/String/strings.bas b/Examples/String/strings.bas new file mode 100644 index 0000000..257d904 --- /dev/null +++ b/Examples/String/strings.bas @@ -0,0 +1,18 @@ +SUB MAIN + DIM STR AS STRING + DIM X AS DOUBLE + + STR="Hello World" + PRINT "LEN(\"" + STR + "\")=" + STR$(LEN(STR)) + PRINT "LEFT$(\"" + STR + "\",3) = \"" + LEFT$(STR,3) + "\"" + PRINT "RIGHT$(\"" + STR + "\",3) = \"" + RIGHT$(STR,3) + "\"" + PRINT "MID$(\"" + STR + "\",5,3) = \"" + MID$(STR,5,3) + "\"" + PRINT "ASC(\"A\")=" + STR$(ASC("A")) + PRINT "CHR$(65)=" + CHR$(65) + PRINT "STR$(1.234) = \"" + STR$(1.234) + "\"" + PRINT "LOWER$(\"" + STR + "\") = \"" + LOWER$(STR) + "\"" + PRINT "UPPER$(\"" + STR + "\") = \"" + UPPER$(STR) + "\"" + STR = "1.234" + X = VAL(STR) + PRINT "VAL(\"" + STR + "\") = " + STR$(X) +END SUB \ No newline at end of file diff --git a/Examples/Time/time.bas b/Examples/Time/time.bas new file mode 100644 index 0000000..5ac3d08 --- /dev/null +++ b/Examples/Time/time.bas @@ -0,0 +1,15 @@ +SUB MAIN + DIM TM AS DOUBLE + DIM DD,MM,CCYY AS INTEGER + DIM HRS,MINS,SECS,MILLI AS INTEGER + TM=NOW() + DD=DAY(TM) + MM=MONTH(TM) + CCYY=YEAR(TM) + HRS=HOUR(TM) + MINS=MINUTE(TM) + SECS=SECOND(TM) + MILLI=MILLISECOND(TM) + PRINT "Todays Date (DD/MM/CCYY) = " + STRING(DD) + "/" + STRING(MM) + "/" + STRING(CCYY) + PRINT "Current Time = " + STRING(HRS) + ":" + STRING(MINS) + ":" + STRING(SECS) + "." + STRING(MILLI) +END SUB \ No newline at end of file diff --git a/Examples/TouchScreen/touchdown.bas b/Examples/TouchScreen/touchdown.bas new file mode 100644 index 0000000..2b83c56 --- /dev/null +++ b/Examples/TouchScreen/touchdown.bas @@ -0,0 +1,31 @@ +SUB MAIN + DIM XY, XPOS, YPOS AS INTEGER + DIM LASTX, LASTY AS INTEGER + DIM MSG AS STRING + + LASTX = 0 + LASTY = 0 + MSG = "Touch the Screen (Down)" + + GRAPHICS + SETCOLOR 0,0,0 + CLS + SETCOLOR 255,255,255 + DRAWSTRING MSG,(SCREENWIDTH()-STRINGWIDTH(MSG))/2, SCREENHEIGHT()/2 + REPAINT + + WHILE TRUE + XY = TOUCHDOWN() + IF (XY <> -1) THEN + XPOS = (XY / 65536) & 0x0000ffff + YPOS = XY & 0x0000ffff + SETCOLOR RND(256),RND(256),RND(256) + DRAWLINE LASTX,LASTY,XPOS,YPOS + LASTX = XPOS + LASTY = YPOS + REPAINT + ELSE + SLEEP 10 + END IF + END WHILE +END SUB diff --git a/Examples/TouchScreen/touchmove.bas b/Examples/TouchScreen/touchmove.bas new file mode 100644 index 0000000..8b8981b --- /dev/null +++ b/Examples/TouchScreen/touchmove.bas @@ -0,0 +1,39 @@ +SUB MAIN + DIM XY, XPOS, YPOS AS INTEGER + DIM LASTX, LASTY AS INTEGER + DIM FLAG AS BOOLEAN + DIM MSG AS STRING + + LASTX = -1 + LASTY = -1 + MSG = "Touch the Screen (Move)" + + GRAPHICS + SETCOLOR 0,0,0 + CLS + SETCOLOR 255,255,255 + DRAWSTRING MSG,(SCREENWIDTH()-STRINGWIDTH(MSG))/2, SCREENHEIGHT()/2 + REPAINT + + SETCOLOR 255,255,0 + + WHILE TRUE + XY = TOUCHDOWN() + IF (XY <> -1) THEN + LASTX = (XY / 65536) & 0x0000ffff + LASTY = XY & 0x0000ffff + ELSE + XY = TOUCHMOVE() + IF (XY <> -1) THEN + XPOS = (XY / 65536) & 0x0000ffff + YPOS = XY & 0x0000ffff + DRAWLINE LASTX, LASTY, XPOS, YPOS + REPAINT + LASTX = XPOS + LASTY = YPOS + ELSE + SLEEP 10 + END IF + END IF + END WHILE +END SUB diff --git a/Examples/TouchScreen/touchup.bas b/Examples/TouchScreen/touchup.bas new file mode 100644 index 0000000..880e85b --- /dev/null +++ b/Examples/TouchScreen/touchup.bas @@ -0,0 +1,31 @@ +SUB MAIN + DIM XY, XPOS, YPOS AS INTEGER + DIM LASTX, LASTY AS INTEGER + DIM MSG AS STRING + + LASTX = 0 + LASTY = 0 + MSG = "Touch the Screen (Up)" + + GRAPHICS + SETCOLOR 0,0,0 + CLS + SETCOLOR 255,255,255 + DRAWSTRING MSG,(SCREENWIDTH()-STRINGWIDTH(MSG))/2, SCREENHEIGHT()/2 + REPAINT + + WHILE TRUE + XY = TOUCHUP() + IF (XY <> -1) THEN + XPOS = (XY / 65536) & 0x0000ffff + YPOS = XY & 0x0000ffff + SETCOLOR RND(256),RND(256),RND(256) + DRAWLINE LASTX,LASTY,XPOS,YPOS + LASTX = XPOS + LASTY = YPOS + REPAINT + ELSE + SLEEP 10 + END IF + END WHILE +END SUB diff --git a/math/example.bas b/math/example.bas new file mode 100644 index 0000000..4a3c41f --- /dev/null +++ b/math/example.bas @@ -0,0 +1,26 @@ +#include "maplib.bas" + +SUB MAIN + + DIM C AS BOOLEAN + DIM D AS DOUBLE + DIM I AS INTEGER + + REM IF YOU WANT TO TRY FUNCTION + REM CONSTRAINT(), + REM ENABLE THIS OPTION + C = FALSE + + D = MAPINT(249,0,360,0,100,C) + I = MAPINT(249,0,360,0,100,C) + + PRINT "WITHOUT ANY DECLARING: " + STR$(MAPINT(249, 0,360, 0,100, FALSE)) +PRINT "" + + PRINT "DECLARED AS DOUBLE: " + STR$(D) +PRINT "" + + PRINT "DECLARED AS INTEGER: " + STR$(I) +PRINT "" + +END SUB diff --git a/math/maplib.bas b/math/maplib.bas new file mode 100644 index 0000000..383b261 --- /dev/null +++ b/math/maplib.bas @@ -0,0 +1,25 @@ +FUNCTION CONSTRAINT(N AS DOUBLE, MINVAL AS DOUBLE, MAXVAL AS DOUBLE) AS DOUBLE + IF N < MINVAL THEN + CONSTRAINT=MINVAL + ELSEIF N > MAXVAL THEN + CONSTRAINT=MAXVAL + ELSE + CONSTRAINT=N + END IF +END FUNCTION +FUNCTION CONSTRAINTINT(N AS INTEGER, MINVAL AS INTEGER, MAXVAL AS INTEGER) AS VARIANT + CONSTRAINTINT=CONSTRAINT(DOUBLE(N),DOUBLE(MINVAL),DOUBLE(MAXVAL)) +END FUNCTION +FUNCTION MAP(N AS DOUBLE, MINVALIN AS DOUBLE, MAXVALIN AS DOUBLE, MINVALOUT AS DOUBLE, MAXVALOUT AS DOUBLE, CONSTR AS BOOLEAN) AS DOUBLE + DIM CONV AS DOUBLE + REM CONV=N/(MAXVALIN/MAXVALOUT) + CONV=(N-MINVALIN)*(MAXVALOUT-MINVALOUT)/(MAXVALIN-MINVALIN)+MINVALOUT + IF CONSTR THEN + MAP=CONSTRAINT(CONV,MINVALOUT,MAXVALOUT) + ELSE + MAP=CONV + END IF +END FUNCTION +FUNCTION MAPINT(N AS INTEGER, MINVALIN AS INTEGER, MAXVALIN AS INTEGER, MINVALOUT AS INTEGER, MAXVALOUT AS INTEGER, CONSTR AS BOOLEAN) AS VARIANT + MAPINT=MAP(DOUBLE(N),DOUBLE(MINVALIN),DOUBLE(MAXVALIN),DOUBLE(MINVALOUT),DOUBLE(MAXVALOUT),CONSTR) +END FUNCTION diff --git a/netjson/example.bas b/netjson/example.bas new file mode 100644 index 0000000..70c0d5a --- /dev/null +++ b/netjson/example.bas @@ -0,0 +1,8 @@ +#include "json.bas" + +SUB MAIN + DIM IP AS STRING + IP = REQUEST("http://ifconfig.me/ip") + PRINT IP + PRINT REQUEST("http://ipwhois.app/json/" + IP) +END SUB diff --git a/netjson/json.bas b/netjson/json.bas new file mode 100644 index 0000000..1010e19 --- /dev/null +++ b/netjson/json.bas @@ -0,0 +1,10 @@ +REM RECEIVE DATA FROM +REM REMOTE SERVER USING +REM GET REQUEST +FUNCTION REQUEST(ADDRESS AS STRING) AS STRING + DIM RESPONSE AS STRING + OPEN #1,ADDRESS,"r" + READLINE #1,RESPONSE + CLOSE #1 + REQUEST = RESPONSE +END FUNCTION diff --git a/test/accel.bas b/test/accel.bas new file mode 100644 index 0000000..6649903 --- /dev/null +++ b/test/accel.bas @@ -0,0 +1,45 @@ +SUB MAIN + + DIM ACCX, ACCY, ACCZ AS INTEGER + DIM RACC AS INTEGER + DIM W, H, X, Y AS INTEGER + DIM SIZE AS INTEGER + + GRAPHICS + + W = SCREENWIDTH() + H = SCREENHEIGHT() + SIZE = 150 + Y = H/2-SIZE/2 + + IF ISACCELEROMETERAVAILABLE() THEN + + WHILE TRUE + + ACCX = GETACCELEROMETERX() + ACCY = GETACCELEROMETERY() + ACCZ = GETACCELEROMETERZ() + + RACC = INTEGER(ACCY*100) + + IF X < W THEN + X=5 + END IF + IF X > W THEN + X=W-SIZE-5 + END IF + + SETCOLOR 70,70,70 + CLS + + SETCOLOR 255,255,255 + FILLRECT X, Y, SIZE, SIZE + + REPAINT + SLEEP 35 + + END WHILE + + END IF + +END SUB diff --git a/test/loading.bas b/test/loading.bas new file mode 100644 index 0000000..97eec27 --- /dev/null +++ b/test/loading.bas @@ -0,0 +1,65 @@ +SUB MAIN + + DIM W, H AS INTEGER + DIM SIZE AS INTEGER + DIM ANGL AS INTEGER + DIM PCTS AS STRING + DIM BTNW AS INTEGER + DIM BTNH AS INTEGER + DIM X, Y AS INTEGER + DIM TXY, TX, TY AS INTEGER + DIM WAIT AS BOOLEAN + + GRAPHICS + + WAIT = TRUE + W = SCREENWIDTH() + H = SCREENHEIGHT() + SIZE = 300 + + FOR ANGL=0 TO 360 + + SETCOLOR 40,41,70 + CLS + + SETCOLOR 255,255,255 + DRAWARC W/2-SIZE/2, H/2-SIZE/2, SIZE, SIZE, -90, ANGL + + PCTS = STR$(INTEGER(DOUBLE(ANGL)/3.6))+"%" + + SETFONT "MONOSPACE", 35 + DRAWSTRING PCTS, W/2-STRINGWIDTH(PCTS)/2, H/2-STRINGHEIGHT(PCTS)/2 + + REPAINT + SLEEP 33 + + END FOR + + BTNW = 100 + BTNH = 50 + X = W/2-BTNW/2 + Y = H/2+SIZE/2+50 + + SETCOLOR 255,255,255 + FILLROUNDRECT X, Y, BTNW, BTNH, 5, 5 + + SETCOLOR 40, 41, 70 + SETFONT "SANS-SERIF", 30 + + DRAWSTRING "OK", X+BTNW/2-20, Y+BTNH/2+10 + + REPAINT + + WHILE WAIT + + TXY = TOUCHDOWN() + TX = (TXY / 65536) & 0x0000ffff + TY = TXY & 0x0000ffff + + IF TX > X AND TX < (X+BTNW) AND TY > Y AND TY < (Y+BTNH) THEN + WAIT = FALSE + END IF + + END WHILE + +END SUB diff --git a/test/variant.bas b/test/variant.bas new file mode 100644 index 0000000..701a59c --- /dev/null +++ b/test/variant.bas @@ -0,0 +1,14 @@ +SUB MAIN + + DIM A, B, C AS VARIANT + DIM I AS INTEGER + + A=2.3 + B=4 + C=1 + I=8 + + I=A+B-C +PRINT I + +END SUB