Help for HotPaw Basic for iPhone/iOS
  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)

  :’ MQTT publish/subscribe functions

  fn mqtt.connect(host$, portNum, clientid$)
    :' clean session
    :' device identifierForVendor is used as the clientID
  fn mqtt.connect(host$, port, clientid$, username$, passwd$)
    :' attempts to connect to an MQTT broker
  fn mqtt.connected()
    :' returns the broker connection status
  fn mqtt.publish(topic$, message$)
    :' publishes a message, QoS = "at least once"
  fn mqtt.publish(topic$, message$, 1)
    :' publishes a persistant message
  fn mqtt.subscribe(topic$)
    :' subscribes to a topic on the connected broker
  fn mqtt.message$()
    :' returns the last subscribed message received
    :' or "" for no new message available
  fn mqtt.disconnect()
    :' disconnects from the current MQTT broker

  :’ 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,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
    
  :’ LightBlue Bean BTLE communication support
  :'   fn bean functions are currently incompatible
  :'   with using any fn btle functions.
  
  fn bean.init()
  fn bean.list()
  fn bean.selected()
  fn bean.info(n,1)
  fn bean.info(n,2)
  fn bean.rssi(n)
  fn bean.connect(1,uuid$)
  
  fn bean.voltage(1)
  fn bean.temp(1)
  fn bean.led(1,r,g,b) : rem sets RGB, 0-255
  fn bean.acceleration(1,0,a%(0))
  fn bean.wrsc(1,n,s$)
    :' writes string to scratch bank 1 to 5
  fn bean.rdsc$(1,n) :rem reads bank 1 to 5
  fn bean.rdsc$(1,n,16) :rem hex string returned
  
  :' wait 1 second before using the following:
  fn.bean.serialwrite(1,s$)
  fn.bean.serialread(1,0)

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.0 (Basic 367b6)

1.7.0	Added some MQTT and Core Bluetooth functions.
        Bug fix for running under iOS 6.
	(b2606 x4)

1.6.9   Bug fixes for the det function and the 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 open/input file commands to allow 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

---
Support:
http://www.hotpaw.com/rhn/hotpaw/
Privacy Policy: 
http://www.hotpaw.com/rhn/hotpaw/app_privacy_policy/
---
---
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.
---