HotPaw Productions
Chipmunk Basic
Support
HotPaw Basic is a Classic BASIC language interpreter. Line numbers are required to enter and edit programs. You can edit a numbered line by using the "edit" command. (Please scroll this Help text to see more.) Type "help website" for more complete info. Commands and Statement Keywords: run new list del 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 : rem directory listing of .bas files removefile { filename$ } fn emailfile(address$, subject$, filename$) fn web(url$) : rem launches Safari fn vibrate() fn solve1() : rem Newton-Raphson equation solver sound f,d,v : rem frequency, seconds duration, volume(0..99) morse m$ : rem plays morse code sounds : rem morse string{,wpm{,vol{,dot_wpm{,freq_Hz}}}} fn fontsize(x) :' changes console font size Graphics: moveto x,y lineto x,y :' draws a line to x,y fn linewidth(w) graphics color r,g,b graphics fillrect x1,y1,x2,y2 graphics circle r :' circle with radius r fn plot1() fn touch(0) :' touch detect 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 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. Input is line input. Only one variable is allowed per input statement. Function subroutines with return values are not supported. New commands: edit . :' Allows multi-line program editing. graphics circle r :' Draws circle at previous moveto location graphics oval x1,y1,x2,y2 :' Draws an oval within the bounding rectangle graphics text s$ :' Draws string at previous moveto location New special functions and commands: dim a(8) :' create an array for GPS data fn location(1,a(0)) :' Reads location in array a ( time, long, lat, 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 recording array size fn recordaudio(64,b%(0)) :' Continues filling array b% with PCM samples. :' Returns index of latest sample fn recordaudio(0) :' Stops audio recording sound -1, a%(), n, 44100 :' plays n 16-bit PCM samples of sound from array a% :' Only the 44.1kHz sample rate is supported. fn say(a$) :' speaks the contents of a$ using voice synthesis :' Example for fetching text or HTML from a web URL :' using HTTP: open "http://..." for input as #3 fn lof(3) :' poll this function to wait for data rem --- when lof becomes non-zero: input #3, a$ :' input strings from HTTP result rem --- until eof(3) :’ Core Bluetooth LE/4.0 device access functions :' It may be necessary to wait 1 or 2 seconds :' between any 2 blte calls, : or to repeat them to receive data. fn btle.init() :’ initializes Bluetooth LE/4.0 access :’ starts a BLE scan :’ returns 0 if the scan has started fn btle.list() :’ presents a list of discovered BLE peripherals fn btle.selected() :’ returns the UUID string for the selected device fn btle.info(n,1) :’ returns the UUID of the nth listed device fn btle.info(n,2) :’ returns the name of the nth listed device fn btle.rssi(n) :’ returns the RSSI of the nth listed device fn btle.connect(1,uuid$) :’ connects to a BLE device fn btle.connect(1,uuid$,service$,chctrstc$) :’ connects and requests a notification fn btle.request(1,service$,chctrstc$) :’ read request for a BLE characteristic fn btle.response$(1,a%(0)) :’ the read data (if any yet) as a string :’ set to "" after the first read fn btle.responsedata(1,a%(0)) :’ the byte count of the read data (if any yet) :' the bytes are return in integer array :' with 2 bytes per array element :’ set to 0 after the first read fn btle.write(1,service$,chctrstc$,data$) :’ request a write to a BLE characteristic fn btle(9) :’ disconnects from BLE device Other special functions and commands: :' Built-in DSP functions fn fft1( 1, x(0), y(0), n ) :' fft arrays x,y (real & imaginary vectors, length n) :' n must be a power of 2, array sizes must be >= n fn fft1(-1, x(0), y(0), n ) :' inverse fft Hints: Use quotes around filenames with load/save. If you quit without saving a modified program, it's saved automatically in the file "tmp.bas". You can use fn emailfile() to email programs and files to yourself to save them on your PC. Use 2 fingers to swipe sideways to toggle between full screen view and keyboard view. There are a few other, more advanced commands documented on the HotPaw website: http://www.hotpaw.com/basic/iphone or type "help website" into the console. ---- Disclaimer: These versions of HotPaw Basic are distributed in the hope that they might be useful, but WITHOUT ANY WARRANTY OF ANY KIND; not even the implied warranty of MERCHANTABILITY or FITNESS for ANY PARTICULAR PURPOSE. (There will be many bugs!) ---- HotPaw Basic version 1.7.7 Release Notes: 1.7.7 Updated for iOS 11 and the iPhone X. (b2112.1) Improved support for Accessibility Larger Text. Basic programs can now be downloaded using iTunes File Sharing, or via the iOS 11 Files app. Graphics drawing area is now limited to 80% of full screen. Bug fix for an occasionally missing "stop" button. Bug fixes for Core Bluetooth background mode. 1.7.5 Fix for a problem with utf8 quoted strings. 1.7.4 Bug fixes for the iPad Pro and some of the built-in audio functions. 1.7.2 Bug fix for printing on iOS 8. (b22605) Bug fixes for new Core Bluetooth built-in functions. 1.7.1 Added Core Bluetooth functions. Bug fix for running under iOS 6. (b2606 x4) 1.6.9 Bug fixes for the det function and graphics text command. 1.6.8 Improvements for iPhone 6 and 6+. added fn touch(3) for touch time - Removed Inter-App Audio synthesizer support. 1.6.7 Bug fixes for iOS 8 and 64-bit processor (arm64) devices. - Removed Audiobus support. 1.6.6 Fixed missing numeric input issue. 1.6.4 Edit fix, dir fix, added MIDI input support. 1.6.3 Keyboard cursor keys fix. 1.6.2 Updated for iOS7. Graphics bug fixes. Added a Keyboard toolbar. 1.6.1 Added the fn say() command to produce synthesized speech. Added HTTP to file commands for accessing web site data. 1.5.9 Enhanced support for iPhone 5 display. Added Bluetooth keyboard full screen support. Improved support for International/unicode strings. Increased graphics window size. Added half-pixel width line drawing for Retina devices. Added graphics text and graphics oval commands. 1.5.6 fixed built-in ipad fn location() documentation 1.5.5 added functions for reading accelerometer and location added a function to read mic input into an array added a new edit mode added the graphics circle command fixed a matrix scaling bug 1.5.3 added mat read command fixed mat command matrix multiply fixed a print tab() bug 1.5.1 Universal/iPad iOS 4.x update Version 1.0.8(365b0i0) - original release --- Copyright 2008,2010,2012,2013,2014,2015 HotPaw Productions Portions Copyright 1994,2000 Ronald H Nicholson Jr. No warranty of functionality, fitness or usefulness for any purpose whatsoever is implied. ---
Answering
iOS/iPhone programming and DSP questions on
StackOverflow
as
hotpaw2
HotPaw news from @hotpaw on twitter.