Ok, now you know how to type, FORMAT, and RUN program so i will now
just give examples of easy code and i will post any explanations you
need either after a REM statement or after a % 0r ! sign.
REM do-until repeats until 0 (so forever)
REM ceil rounds to the next whole number
REM rnd *5 picks 5 random numbers between 1 and 5
code:
DO
LET x=CEIL(RND()*5)
IF x=2.0
PRINT "0010"
ELSE
IF x=1.0
PRINT "0001"
ELSE
IF x=3.0
PRINT "0011"
ELSE
IF x=4.0
PRINT "0100"
ELSE
IF x=5.0
PRINT "0101"
ELSE
PRINT "error"
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
UNTIL 0
END
code end.
code:
j=1
k=5
do
j=j+1
PRINT "up yours"
UNTIL j=k
print "repeats string 4 times"
pause 3000
exit
code end.
code:
! This example shows the different effects
! available for drawing graphical text.
!
! Open Graphics Screen with a black background.
GR.OPEN 255, 0, 0, 0
GR.ORIENTATION 0
GR.SCREEN w,h
xleft = w/4
! Draw a red text alignment line
GR.COLOR 255,255,0,0,1
GR.LINE n, xleft,0, xleft,h
! Set the text color to Red with fill = false
GR.COLOR 255,255, 0, 255, 0
! Set the text size to 1/25th screen height
GR.TEXT.SIZE w/25
! Set the text align to Left = 1
GR.TEXT.ALIGN 1
GR.TEXT.DRAW P, xleft, h/3, "Left Aligned"
! Set the text align to Center = 2
GR.TEXT.ALIGN 2
GR.TEXT.DRAW P, xleft, h/2, "Center Aligned"
! Set the text align to Right = 3
GR.TEXT.ALIGN 3
GR.TEXT.DRAW P, xleft, 2*h/3, "Right Aligned"
! Demonstrate Text Sizes and Styles
! All examples will be aligned Left = 1
! and with Blue (0,0,255) text with fill = false
GR.TEXT.ALIGN 1
GR.COLOR 255, 0, 255, 0, 0
! Eight block of text will be drawn
! evenly spaced
block = h/8
xleft = w/2
GR.TEXT.SIZE block/4
GR.TEXT.DRAW P, xleft, block/2, "Tiny text"
GR.TEXT.SIZE block
GR.TEXT.DRAW blink_ptr, xleft, 2*block, "neo text"
! normal text size is block/2
hblock = block/2
bc = 3 % Block level
GR.TEXT.SIZE hblock
GR.TEXT.BOLD 1
GR.TEXT.DRAW BTP, xleft , bc*block + hblock, "Bold, unfilled text"
bc = bc +1
! Show Bold, filled text. Change the color
! fill parameter to true
GR.COLOR 255, 0, 0, 255, 1
GR.TEXT.DRAW P, xleft, bc*block + hblock, "Bold, filled text"
bc =bc + 1
! Show Underlinded text
GR.TEXT.BOLD 0
GR.TEXT.UNDERLINE 1
GR.TEXT.DRAW P, xleft, bc*block + hblock, "Underlined text"
bc =bc + 1
! Show strike through text
GR.TEXT.UNDERLINE 0
GR.TEXT.STRIKE 1
GR.TEXT.DRAW P, xleft, bc*block + hblock, "Strike through text"
bc =bc + 1
! Show skewed text
GR.TEXT.STRIKE 0
GR.TEXT.SKEW -0.25
GR.TEXT.DRAW P,xleft, bc*block + hblock, "Skewed text"
! Now render everything
GR.RENDER
! After a one second pause,
! start to blink the big text
PAUSE 1000
DO
GR.HIDE blink_ptr
GR.RENDER
PAUSE 500
GR.SHOW blink_ptr
GR.RENDER
PAUSE 750
UNTIL 0
! The program does not end until the
! BACK key is pressed. When BACK
! is pressed, there will be a graphics
! not open error. The onerror will
! it an end without an error.
ONERROR:
END
code end.
This next code demonstrates the accelerometer and GOSUB
(similar to GOTO but it returns to the same spot when finished)
code:
SENSORS.OPEN 1
DO
SENSORS.READ 1,y,x,z
IF x>1
PRINT x
PAUSE 2000
CLS
GOSUB count
ENDIF
UNTIL f>29
TTS.INIT
TTS.SPEAK "that's 30 pushups. u can stop."
PAUSE 5000
END
EXIT
count:
f=1+f
PRINT f
TTS.INIT
TTS.SPEAK "you did " + FORMAT$("#####", f) + "pushups"
RETURN
code end.
A CellPhone GPS Program