Learning to Program with the Cybiko Handheld Computer Using B2C

Appendix 1 : Command Summary

{something} = optional
DIM var{[dimension]} {as type} Dimension - number of objects in array

type=char, int, long, double

dimension a variable
INPUT {"prompt",} var Var - variable to receive input

Prompt - prompt string

Receives input from the keyboard and puts it in a variable
PRINT {obj, …} Obj - a variable or expression or quoted string Puts text output on the screen.  The screen is about 23 chars x7 lines
var = exp Var - a variable

Exp - some arithmetic expression

Assignment
'comment Comment Everything after the ' is ignored
FOR var = from-exp TO to-exp {STEP exp} Var - variable

From-exp - starting value

To-exp - ending value

Step-exp - increment

Begin a loop with variable var changing value throughout
NEXT   Increment the var by to-exp and continue execution at the FROM statement
IF exp1 cond exp2 THEN Exp1,exp2 - expressions to be compared

Cond - conditional =,<,<=,>,>=, and, or

 but you cannot compare strings

Conditinal command if true, executes all statements down to the next ELSEIF, ELSE, and END IF.
ELSE   If the IF cond fails then each command until the ENDIF is executed
ELSEIF exp1 cond exp2 THEN Exp1, exp2 - expressions

Cond - conditional =, <, <=, >, >=, and, or

But you cannot compare strings

If the IF cond fails and the ELSEIF cond is true then all commands until the END IF or ELSE are executed
SUB routine-name {(parameter, …)}

Parameter={BYREF|BYVAL} var {AS type}

Routine-name is the name of the subroutine

Parameter is a dim-like statement

No arrays are allowed.  BYREF indicates passing by reference BYVAL indicates pasing by value.  Type is char, int,long, double

Creates a subroutine which includes all commands up to the END SUB command
EXIT SUB   Exit the subroutine before reaching the END SUB command
END SUB   End of the subroutine
FUNCTION routine-name {(parameter,…)} as type

Parameter={BYREF|BYVAL} var {AS type}

Routine-name is the name of the function which returns a value

Parameter is a dim-like statement

No arrays are allowed.  BYREF indicates passing by reference BYVAL indicates pasing by value.  Type is char, int,long, double

Creates a function which includes all commands up to the END SUB command. 

Declare the value of the returned function by setting the name of the function to a value

Routine-name = exp

EXIT FUNCTION   Exit the function before reaching the END FUNCTION command
END FUNCTION   End of the FUNCTION

OPEN pathname {FOR mode} AS filnumber

Mode = {READ|WRITE|APPEND}

Pathname=string of a file name

Filenumber= value from 0 to 65535

Mode=access mode

Opens a file for access.  Note that opening for read destroys old content.  File writing is constrained to 23KB

CLOSE {filenumber}

Filenunber = value from 0 to 65535

Closes a file.  Specifying no filennumber closes all files currently open

PUT filenumber, {bytepos},{var}

Bytepos - position in the file to write to

Var - variable to write

Writes a var to a file at bytepos.  If bytepos is omitted the var is written to the current pos. if the var is ommitted the file is positioned at the pos and no var is written

GET filenumber, {bytepos},{var}

Bytepos - position in the file to read from

Var - variale to read into

Reads a var from a file at bytepos. If bytepos is omitted the vari is read from the current pos.  if the var is omitted the file is positioned at the pos and no var is read.

PRINT #filemumber, (obj…)

Filenumber - the file to write to

Obj - a variable or expression or quoted string

Puts text output to the file specified by filenumber

CLS

 

Clear the screen

Paper n

N - the color of the paper (backgrond) Can be one of four values; 0=white, 1=light gray, 2=dark gray, 3=black

Paint the screen the color 'n'

Ink n

N - the color of the paper (backgrond) Can be one of four values; 0=white, 1=light gray, 2=dark gray, 3=black

Set the color of text, lines, and points

Point x,y

X - the x coordinate (-43 to +43)

Y - the y coordinate (-80 to +80)

Set a single pixe on the display

In the current ink color

Line x0,y0,x1,y1

X0- the left-most point

X1 - the right-most point

Y0 - the left most point

Y1 -the right most point

Draw a line on the display in he current ink color

Math Functions:

Sin, cos, tan,

asin,ascos,atan, actan

sinh,cosh,tanh,

asinh,acosh,atanh,actanh

sqrt, exp, log, log10,log2

pow,sqr_pow,rnd

 

 

Geometric mathemetaticl fucntion

Beep n

N = beep command

0-silence     1-bleep

2-oh no       3-laser

4-too bad     5-computing

6-carnival     7-completed task

Makes noises on the cybiko

WAIT n

N - number of 10ths of seconds to wait

Waits 10ths of seconds

KEY

 

Acts as a variable holding the most recently type keyboard variable.  See the documenation for more info

WHILE exp1 cond exp2

See IF command, above

Initiates a while loop that exectes allcommands up to the WEND command.  IF the conditional is still true, processing continues at the WHILE command

WEND

 

Terminates the while command

TYPE {decl, …}

Decl is as in DIM

Creates a structured datatype

END TYPE

 

Ends a type definition

PRINTXY x, y {,vals}

X,Y=the coordinate where the text will display

Vals are values as in print to be displayed

Positions the cursor on the screen and prints the values

RIGHT dest, src, len

Src = source string

Dest = destination string

Len = the number of bytes from the end of the src string to copy to the dest string

Copies bytes from the right-hand side of the src string to the left hand side of the dest string

MID dest, src, start{, len}

Src = source string

Dest= destination String

Start = where in the src string to start copying

Len = number of bytes to copy

Copies from the middle of the soruce string to the destination string. If the length is left out it copied all bytes from the source string start point to the end