Pocket Grapher

Pocket Grapher Scripting


Index


Scripting Overview

Scripting as of now is limited. The information here will get you started with creating scripts but using scripts will be mostly limited to the restrictions of lua. For more information about the language lua. Look it up in the documentation section of lua.org.

Creating Scripts

In order to create a script you must place a script file with the extention .lua in the same directory as the pocket grapher program. When the calculator starts it will automatically detect and load all the scripts. Running scripts is detailed in the general help file. When a script is run it will run the script body then attempt to call the funciton in the body with the same name as the script passing the parameters recieved to lua and returning what the funciton returned. The parameters passed to lua will all be in a table format.

Table Formats

Parameters are passed to lua scripts by means of a table. This allows complex number, lists, and matricies to be passed to a script. These tables can also be returned back to the calculator. Every table will have the member of "type". Type identifies the type of the table format and can be on of the following values. Click on the type string for more information

The table formats that can be returned to the calculator are "number", "list", and "matrix". A regular number can also be returned to the calculator.

Example Script

An example script named example.

function example(param)
 if param.type == "number" then
  holder = param.r
  param.r = param.i
  param.i = holder
 elseif param.type == "list" then
  for i = 1,param.len do
   example(param[i])
  end
 elseif param.type == "matrix" then
  for r = 1,param.row do
   for c = 1,param.col do
    example(param[r][c])
   end
  end
 end
 return param;
end

Script Refrence

Select a topic.