HotPaw Productions
Chipmunk Basic
Support
HotPaw Basic is a Classic BASIC language
interpreter. Line numbers are required to
enter and edit programs.
You type in Basic language programs with line
numbers and then type "run" (without quotes)
to run your program.
Example:
10 for i = 1 to 2
20 print "Hello World!"
30 next i
40 end
run
Supported Commands and Statement Keywords:
run new list edit save load removefile
let if then else endif dim data read restore
for to step next while wend goto gosub return
? print input open close end stop
def fn mat randomize cls : rem
Functions:
int() abs() sgn() rnd()
sqr() exp() log() log10() sin() cos() tan() atn()
len() val() asc() str$() chr$() hex$() mid$()
ucase$() lcase$() right$() left$() field$() instr()
eval() varptr() peek() timer() date$ time$ pi
Operators:
+ - * / mod ^
= <> > >= < <= and or xor not
Other special functions and commands:
edit { line_number }
dir
removefile { filename$ }
fn emailfile(address$, subject$, filename$)
fn web(url$)
fn fontsize(x) :' changes console font size
Graphics:
moveto x,y
lineto x,y :' draws a line to x,y
fn color(r,g,b)
fn linewidth(w)
cls :' clears display
fn plot1() :' see chipmunk basic documentation
fn touch(1) :' x location in graphics display
fn touch(2) :' y location in graphics display
graphics cls :' clears graphics display
cls :' clears both text and graphics
Sound:
fn vibrate()
sound f,d,v :' f=frequency, d=duration_seconds, v=volume(0..100)
morse "cq cq" :' produces morsecode sounds
On iOS AirPrint enabled devices, you can print by using:
open "lpt1:" for output as #1
close #1 : rem print starts after file close
Hints, Notes and Limitations:
String variable names must end with a
$ character.
Arrays must be dimensioned before use.
Function subroutines with return values are
not supported.
Input is line input. Only one variable
is allowed per input statement.
New commands (version 1.5.5):
edit .
:' Allows multi-line program editing.
graphics circle r
:' Draws circle at previous moveto location
New functions:
dim a(8) :' create an array for GPS data
fn location(1,a(0))
:' Reads location in array a ( time, lat, long, alt, err )
:' Returns time stamp (it's old data if unchanged)
fn location(0)
:' Stops GPS polling
dim a(8) :' create an array for motion data
fn accelerometer(1,a(0))
:' Reads accelerometer into array a (time, x, y , z)
:' Returns time stamp (it's old data if unchanged)
fn accelerometer(0)
:' Stops Accelerometer polling
dim b%(65536) :' required array size
fn recordaudio(64,b%(0))
:' Continues filling array b% with audio samples.
:' Returns index of latest sample
fn recordaudio(0)
:' Stops audio recording
Answering
iOS/iPhone programming and DSP questions on
StackOverflow
as
hotpaw2
HotPaw news from @hotpaw on twitter.