Sie sind auf Seite 1von 177

Zeus Manual

ZeusPro ZeusLite PocketZeus PocketZeusLite

Zeus Manual
Version 3.0

Updates Software and updated manuals can be obtained from the KRMicros web site located at www.krmicros.com. Forums A web-based discussions board is located at KRMicros or one one of its affiliate sites. These forums cover everything from the Dios product line to motor controller basics and robotics. KRMicros Return Policy All KRMicros Software is downloadable and free to try for a period of 15 days. After this 15 day period the software will no longer function and you must purchase the software or remove it. Because we offer you a free 15 day trial period we offer no refunds for the software once a registration key has been purchased. Disclaimer of Liability KRMicros cannot be held responsible for any incidental, or consequential damages resulting from the use of any KRMicros products. Shipping Responsibility Most of our products are delivered electronicaly so shipping is not an issue however in the event you purchase a manual or software on CD KRMicros ships all packages Priority Air Mail via the United States Postal Service with delivery confirmation. We have found this combination gives the fastest and most reliable delivery at a very reasonable cost. Once a package has been delivered we are no longer responsible for the package. More specifically, if some one steals the package from your doorstep we will not be held responsible and no refund will be provided. If your package has not been delivered and sufficient time has passed please email us and we will verify delivery. If delivery has been made you will be given the confirmation number and delivery details. Thereafter you must contact your local Post Office for further information.

Contacts email: support@krmicros.com phone: 703 779-9752 fax: 703 779-9753 web: www.krmicros.com

Copyright 2006 by Michael G Simpson. All rights reserved

This manual will provide a basic understanding of the Zeus Language to those beginners interested in programming the Zeus family of products. It is important that you read this document in the order that it is presented the first time through. The information is presented in a way to work you up to more complex explanations and examples.

Zeus Language . . . . . . . . . . . . . . . . . . . . . . . .Page 5 Zeus Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . .Page 125 Zeus Form Builder . . . . . . . . . . . . . . . . . . . . . .Page 163

Page 4

Zeus www.krmicros.com

Section 1 Zeus Language

Zeus Language Table of Contents


Language Overview . . . . . . . . . . . . . . . . . . . . . .6 Command Table of Contents . . . . . . . . . . . . . . .16 Base Commands . . . . . . . . . . . . . . . . . . . . . . . . .18 Conversion Commands . . . . . . . . . . . . . . . . . . . .42 File Commands . . . . . . . . . . . . . . . . . . . . . . . . . .44 Form Commands . . . . . . . . . . . . . . . . . . . . . . . .54 Advanced Form . . . . . . . . . . . . . . . . . . . . . . . . . .70 GPS Commands . . . . . . . . . . . . . . . . . . . . . . . . .74 KRDB Commands . . . . . . . . . . . . . . . . . . . . . . . .80 Math Commands . . . . . . . . . . . . . . . . . . . . . . . . .84 Serial Commands . . . . . . . . . . . . . . . . . . . . . . . .92 Socket Commands . . . . . . . . . . . . . . . . . . . . . . .104 Zeus Extensions . . . . . . . . . . . . . . . . . . . . . . . . .121

This section will give you 10,000 foot overview of the Zeus Language. Be sure to visit the KRMicros website for code examples. We also have a wide range of interface boards for actual real world interfaces. The Zeus forums are very active and contain the most recent information regarding the Zeus language. The language tutorial at the end of this manual will take you step by step through the Zues language.

Zeus www.krmicros.com

Page 5

Language Overview
Functions
The core of the Zeus language is its ability to use functions. A function is a self-contained area in the program. It has its own variable space and when no longer needed it will free up this space. Functions can have any number of parameters passed to them. You can pass integer, floating point and string values to a function as a parameter. To pass a floating point value you must declare the argument as a single parameter. In example 1.1 the data1 parameter will expect a floating point value to be passed. If the value passed is not a floating point value it will be converted. The next 2 parameters, data2 and data3, will expect integer values passed to them. Again, if the value passed is not an integer values it will be converted. Notice that data3 does not have a declaration type. When the declaration type is omitted an integer value is assumed.

Example 1.1
'example 1.1 func collect(data1 as single,data2 as integer, data3) endfunc

In addition to local variables all functions have access to global variables. This allows you to easily manage several hundred variables in very little space. Functions are totally self-contained with their own labels, gotos, gosubs and local constants. In example 1.2 the function mymult will take a number and multiply it by its self and return the result.

Example 1.2
'example 1.2 func main() dim x as integer for x = 1 to 10 print x,"*",x,"=",mymult(x) next endfunc func mymult(tt as integer) as integer exit(tt * tt) endfunc

Page 6

Zeus www.krmicros.com

Language Overview
Setting a Functions Return Type
By default, when a function returns a value it returns a 32-bit integer. To return a floating point value you need to define the function as a single value as shown in example 1.3.

Example 1.3
'example 1.3 func getpie() as single exit(3.17) endfunc

Note: If a function is set to return a float and it is used in an integer expression the floating point value will be converted to integer. This will allow you to write generic libraries.

Passing String Data


When passing string or text data to a function you need to define the parameter as string as shown in example 1.4

Example 1.4
'example 1.4 func main() disptext("hello") endfunc func disptext(tstr as string) print tstr goto again endfunc

Important The use of parentheses are NOT optional when using functions. Even when calling them with out returning values requires the use of parentheses.

Zeus www.krmicros.com

Page 7

Language Overview
Variables
There are three types of variables in the Zeus language: 32-bit signed integer variables, 32-bit signed floating point variables, and string variables. All variables may be assigned as local or global variables. Local Variables When a variable is local, the space it takes will be freed up once the function in which it was declared has exited. This not only saves memory but also helps you encapsulate your functions. In example 2.1 the three variable slots taken up by the x,y,z variables in function displaystuff will be freed up for use by other functions once the displaystuff function has exited.

Example 2.1
'example 2.1 func main() dim myvarb1 as integer displaystuff() endfunc func displaystuff() dim x as integer dim y as integer dim z as integer print x,y,z endfunc

To declare a local variable use the dim statement. To create an integer variable use: dim x as integer or dim x To create a floating point variable use: dim x as single To create a string variable use: dim x as string

Global Variables When a variable has been defined as a global variable it can be accessed by all functions. Global variables never go away. To declare a global variable use the statement global. Global variables may be declared anywhere, even outside functions. To create a global integer variable use:

Page 8

Zeus www.krmicros.com

Language Overview
global x as integer or global x To create a global floating point variable use: global x as single To create a global stringt variable use: global x as string Variable Scope It is possible to have a global variable called zzz and a local variable called zzz. In this case the local variable will take precedence while in the function that created the local variable. The same is true for constants.

Variable/Constant/Function/Label names
Name length There is no limit to the size of the names. Valid Characters The first digit in a name must be a letter or underscore. After the first digit is defined you may use numbers in the name. How many The amount of available RAM determines the actual number of variables that can be active. That is to say you can have several local variables defined but if the function is not currently being called the variable does not take any space. You may have up to 1,000,000 string variables, 1,000,000 integer variables, and 1,000,000 floating point variables. These limits only apply to local variables so each function may have this many variables.

Constants
Constants are numbers that are referenced by a useable name. For example, const CLK 5 would allow us to use the word CLK to represent the number 5. That way you can have several references to the CLK port. To change the port from 5 to 6 means only having to change 1 line of code as shown in example 2.2.

Example 2.2
'example 2.2 func main() const CLK 5 print CLK print int(CLK *5) endfunc

Once a constant has been defined the value cannot be changed. In other words you can't have the statement CLK = 25. Constant statements are local to the functions that they were declared, just like local variables.

Zeus www.krmicros.com

Page 9

Language Overview
Global Constants
You can also define global constants, i.e constants that are available to all functions. To define a global constant use the gconst statement just like you would use the const as shown above. Global constants can be defined anywhere in the program file. Note: Constants may hold both floating point and integer values. They cannot hold string values.

MATH
The Zeus language supports two types of math: 32-bit integer math and 32-bit floating point math. In many cases the two are interchangeable but there are some subtle differences. Integer Math The following operations are supported: * Multiplication \ Division Truncate Result with remainder / Division Rounded result with remainder + Addition - Subtraction & And | Or ^ Xor // Return the Remainder after a Division You can use math anywhere an expression is used or in variable assignments. Example: dim res as integer res = 10 + 5 Floating Point Math Floating point math is very similar to integer math. The following operations are supported * Multiplication \ Division result is truncated to integer. Decimal is chopped off. / Normal floating point division + Addition - Subtraction & And | Or ^ Xor // Return the Remainder after a Division

You can use math anywhere an expression is expected.

Page 10

Zeus www.krmicros.com

Language Overview
String Math There are a couple operators that are supported when working with strings. + Add strings - Subtract the contents of the string on the right side if it exists on the left side.

Math and Expression Conversion


By its nature Zeus will automatically convert one data type to another. This is fairly strait forward when working with integers and floating point numbers. However Zeus will also attempt to convert to and from strings as well.

dim tstr as string dim x as integer x = 25 tstr = x print tstr

In the above example the integer variable will be converted to the string as 25 so will print 25.

dim tstr as string dim x as integer dim y as integer x = 25 y = 75 tstr = x+y print tstr In this example the x value will be placed in the string as 25 and the y value will be added to the string as 75 with the result being 2575. This is because string math is being used. If you actually wanted to add x and y you need to force the compiler to use integer math when adding x and y as shown here. x = 25 y = 75 tstr = int(x+y) print tstr What affects the type of expression math to be used? When doing assignment to a variable the variable type will determine the type of expression math used. If using an expression in a function or command parameter then the expected type will determine the math used.

Zeus www.krmicros.com

Page 11

Language Overview
Conversion Options
You can set how the Zeus language handles conversions by setting various conversion options. option cvtstringtoint xxx option cvtstringtosingle xxx option cvtsingletoint xxx option cvtsingletostring xxx option cvtinttosingle xxx option cvtinttostring xxx Where xxx is the type of conversion to allow. auto Will cause an automatic conversion from one type variable to another. You can always override this with the cint/csng/cstr/val commands warn Will do the same as auto but will cause warnings to be generated. error Will stop the compiler with an error There are also three global settings option cvtauto places the compiler in automode (The default mode) option cvtwarn Causes a warning. option cvterror Causes an error

Constant Conversion
The compiler supports three types of number or constant conversion.

Binary Conversion You can assign a binary number to a variable or as part of an expression by preceding the number with a %. Example: res = %100 res will contain 4. Note that the MSB is on the left side.

Hex Conversion You can assign a hexadecimal number to a variable or as part of an expression by preceding the number with a $. Example: res = $41

Page 12

Zeus www.krmicros.com

Language Overview
res will contain 65.

ASCII conversion You can convert an ASCII character to a byte by enclosing the character in single quotes. Example: res = 'A' res will contain 65

Error Handling
There are 4 modes for handling runtime errors. These are errors that are not handled by the compiler. onerror goto label Will case the engine to jump to the label after the error has completed. The label must be located in the function where the error is expected. onerror console (default) Will display an error message in the console window. onerror resume No action is take the program just keeps running ignoring the error. onerror none No action is taken at the command level. The current function will exit and a message will be displayed.

While every attempt has been made to catch all runtime errors. There are always a few that may slip through the cracks if you encounter any unhandled errors please make a note of the circumstances that caused the error and drop us a line at www.kronosrobotics.com. The same goes for conversion warnings. If you notice any that don't seem to fit the settings you have placed in your code send us a short example showing the anomaly.

Arrays
You can create floating point, integer and string arrays. An array is a block of the same kind of variable that can be accessed with an index. This effectively allows you to cycle through a list of variables. Both single dimension Z(x) and double dimension arrays are supported Z(x,y) Integer Arrays Creating an integer array works just line creating normal integers. You simply need to add a bit more information so we can tell the compiler how many we want to define. dim myvarb(10) as integer Will create a block of 10 32-bit integer variables. You can access each individual element by using the index. Note that the first array element is 0 so in this case we will use 0-9 to represent the elements. myvarb(0) = 5000 'The first element in the array myvarb(9) = 400 'The last element in the array

Zeus www.krmicros.com

Page 13

Language Overview
Floating Point Arrays Float arrays work just like integer arrays. The only difference is that we will use the float declaration instead of integer. dim myvarb(10) as float This will create a block of 10 floating point variables. Again you can access each element by using an index. myvarb(0)= 2.76 '1st element myvarb(2)=300.54 '3 rd element String Arrays As with integer and floating point arrays you may create string arrays. dim mystring(10) as string This will create 10 strings that you can access via an index number.

Array exceptions and rules You can use arrays in any expression. Automatic conversion will take place between each type. You can not pass the whole array to a function. Only a single element can be passed. You can use global variable arrays to manipulate array data in different functions You can not return whole arrays with the exit command. You can only return a single element. When a command requires a variable for data return you my not use an array. You can not access individual bits and bytes of array elements. For example myvarb(1).bit(7) is not currently allowed.. There is no bounds checking on arrays so if you index outside the allocated block you will access data in other variables.

_ Continuation Operator This character can be placed at the end of a line. This tells the compiler that the current line continues to the next line. This is useful when doing tables as well as lookup and lookdown commands. The continuation operator can not be contained in quotes.

Page 14

Zeus www.krmicros.com

Command Syntax
In the following section the actual syntax of each command will be shown. Each command name will be followed by a syntax example and a syntax parameter type. Commands may be upper, lower or mixed case. Some commands can be used as standalone or in expressions. When used in expression the command may take on a different action and it will be noted in the explanation. The paramater types will be indicated as follows: exp: Any variable type, literal mathematical expression. The parameter is expected to be numberic as a floating point or integer. If a string is passed it will be converted to a numberic before being added to the expression. A Iexp or Fexp may also be used to indicate that the type of numeric data prefered. Sexp: This is a string expression. The parameter is expected to be a string . If numeric data is passed it will be converted to a string before being addded to the expresion. So 5+5 in a string expression will be 55 not 10. varb: Variable accepted only. No arrays, bit or byte extensions. The command may also specify the type of variable using Fvarb, Ivarb or Svarb. label: Valid location label. number: Can contain only a number or constant. operator: Valid operator as in > < >= <= <> != ==

Compiler Indicators Not all commands are compatible with all languages. Each commend will have a indicator showing compilers supported.

Zp Pz PzL Zl ZW5 ZC5 ZC ZCLCE

ZeusPro

Zpe ZeusPro Extensions All PocketZeus


All Target Platforms

PocketZeusLite

ZeusLite

!!Important!!
Zeus Windows Mobile 5

Zeus CE 5

The following targets are only avaialble with ZeusPro with the ZPE option. Zeus Zeus Zeus Zeus Windows Mobile 5 CE 5 Desktop Console CE 5 Console

Zeus DeskTop Console

Zeus CE 5 Console

Zeus www.krmicros.com

Page 15

Command Table of Contents

Abs() . . . . . . . . . . . . . . . . . . . . .84 Acos() . . . . . . . . . . . . . . . . . . . .84 AppInfo() . . . . . . . . . . . . . . . . . .121 Args() . . . . . . . . . . . . . . . . . . . . .121 Asc() . . . . . . . . . . . . . . . . . . . . .42 Asin() . . . . . . . . . . . . . . . . . . . . .84 Atan() . . . . . . . . . . . . . . . . . . . . .84 Atan2() . . . . . . . . . . . . . . . . . . . .85 BeginsWith() . . . . . . . . . . . . . . .110 BitGet() . . . . . . . . . . . . . . . . . . .18 BitMapDrawBitmap() . . . . . . . . .70 BitMapDrawFillPoly() . . . . . . . . .70 BitMapDrawPoly() . . . . . . . . . . .70 BitMapDrawText() . . . . . . . . . . .71 BitMapEllipse() . . . . . . . . . . . . .71 BitMapFillEllipse() . . . . . . . . . . .71 BitMapFillRectangle() . . . . . . . .72 BitMapLine() . . . . . . . . . . . . . . .72 BitMapRectangle() . . . . . . . . . . .72 BitSet() . . . . . . . . . . . . . . . . . . .18 Break() . . . . . . . . . . . . . . . . . . . .18 CalcRPN() . . . . . . . . . . . . . . . . .18 Case . . . . . . . . . . . . . . . . . . . . .19 CaseElse . . . . . . . . . . . . . . . . . .19 Ceiling() . . . . . . . . . . . . . . . . . . .85 Chr() . . . . . . . . . . . . . . . . . . . . .42 Cint() . . . . . . . . . . . . . . . . . . . . .43 ClearAll() . . . . . . . . . . . . . . . . . .19 ClearGlobal() . . . . . . . . . . . . . . .20 ClearLocal() . . . . . . . . . . . . . . . .20 Clipget() . . . . . . . . . . . . . . . . . . .20 Clipset() . . . . . . . . . . . . . . . . . . .20 ColorBox() . . . . . . . . . . . . . . . . .121 ComBGSuspend() . . . . . . . . . . .101 ComBreak() . . . . . . . . . . . . . . . .96 ComBuff() . . . . . . . . . . . . . . . . .92 ComClose() . . . . . . . . . . . . . . . .92 ComCTS() . . . . . . . . . . . . . . . . .92 ComDSR() . . . . . . . . . . . . . . . . .92 ComDTR() . . . . . . . . . . . . . . . . .93 ComErrors() . . . . . . . . . . . . . . . .96 ComGetByte() . . . . . . . . . . . . . .93 ComGetIDPacket() . . . . . . . . . .95 ComGetPacket() . . . . . . . . . . . .93 ComGetVPacket() . . . . . . . . . . .94 ComInput() . . . . . . . . . . . . . . . .96 ComOpen() . . . . . . . . . . . . . . . .97 ComOutput() . . . . . . . . . . . . . . .98 ComPurge() . . . . . . . . . . . . . . . .98 ComRTS() . . . . . . . . . . . . . . . . .99

ComSendnWaitByte() . . . . . . . .99 ComSendnWaitWord() . . . . . . .99 ComSettings() . . . . . . . . . . . . . .100 ComStatus() . . . . . . . . . . . . . . .101 ComWaitForByte() . . . . . . . . . . .102 ComWaitForWord() . . . . . . . . . .102 Console() . . . . . . . . . . . . . . . . . .20 ConsoleCls() . . . . . . . . . . . . . . .21 Convert() . . . . . . . . . . . . . . . . . .110 Cos() . . . . . . . . . . . . . . . . . . . . .85 Cosh() . . . . . . . . . . . . . . . . . . . .86 Csng() . . . . . . . . . . . . . . . . . . . .42 Cstr() . . . . . . . . . . . . . . . . . . . . .42 Cursor() . . . . . . . . . . . . . . . . . . .21 Dec() . . . . . . . . . . . . . . . . . . . . .86 Dec() . . . . . . . . . . . . . . . . . . . . .86 Dim . . . . . . . . . . . . . . . . . . . . . .21 DoEvents() . . . . . . . . . . . . . . . .22 End . . . . . . . . . . . . . . . . . . . . . .22 Endfunc . . . . . . . . . . . . . . . . . . .22 EndSelect . . . . . . . . . . . . . . . . .23 EndsWith() . . . . . . . . . . . . . . . . .110 Exit() . . . . . . . . . . . . . . . . . . . . .22 Exp() . . . . . . . . . . . . . . . . . . . . .86 FileClose() . . . . . . . . . . . . . . . . .44 FileCopy() . . . . . . . . . . . . . . . . .44 FileDelete() . . . . . . . . . . . . . . . .45 FileDialog() . . . . . . . . . . . . . . . .44 FileEOF() . . . . . . . . . . . . . . . . . .45 FileFolderChange . . . . . . . . . . .45 FileFolderCreate . . . . . . . . . . . .45 FileFolderCurrent . . . . . . . . . . .46 FileFolderDelete . . . . . . . . . . . .46 FileFolderInfo . . . . . . . . . . . . . .46 FileInfo() . . . . . . . . . . . . . . . . . .47 FileLoadResource() . . . . . . . . . .122 FileMove() . . . . . . . . . . . . . . . . .48 FileOpen() . . . . . . . . . . . . . . . . .48 FilePeek() . . . . . . . . . . . . . . . . .48 FilePos() . . . . . . . . . . . . . . . . . .49 FileQuickAdd() . . . . . . . . . . . . . .52 FileQuickLoad() . . . . . . . . . . . . .52 FileQuickLoadAll() . . . . . . . . . . .52 FileQuickSave() . . . . . . . . . . . . .53 FileQuickSaveAll() . . . . . . . . . . .53 FileRead() . . . . . . . . . . . . . . . . .49 FileReadFile() . . . . . . . . . . . . . .49 FileReadLine() . . . . . . . . . . . . . .50 FileSeek() . . . . . . . . . . . . . . . . .50 FileWrite() . . . . . . . . . . . . . . . . .50

FileWriteFile() . . . . . . . . . . . . . .51 FileWriteLine() . . . . . . . . . . . . . .51 Fix() . . . . . . . . . . . . . . . . . . . . . .87 Float() . . . . . . . . . . . . . . . . . . . .43 Floor() . . . . . . . . . . . . . . . . . . . .87 For/Next . . . . . . . . . . . . . . . . . . .23 FormAddPoint() . . . . . . . . . . . . .54 FormAllButtons() . . . . . . . . . . . .57 Format() . . . . . . . . . . . . . . . . . . .111 FormBGColor() . . . . . . . . . . . . .54 FormBitmapColor() . . . . . . . . . .54 FormBitmapColorClear() . . . . . .54 FormBitmapFill() . . . . . . . . . . . .73 FormBitmapSave() . . . . . . . . . .55 FormBitmapSource() . . . . . . . . .55 FormBitmapTarget() . . . . . . . . .55 FormBrush() . . . . . . . . . . . . . . .56 FormButton() . . . . . . . . . . . . . . .57 FormButton() . . . . . . . . . . . . . . .56 FormCls() . . . . . . . . . . . . . . . . .58 FormCreateBitmap() . . . . . . . . .73 FormCreateBitmap() . . . . . . . . .73 FormCreatePoly() . . . . . . . . . . .57 FormCurMouseX() . . . . . . . . . . .58 FormCurMouseY() . . . . . . . . . . .58 FormDrawBitmap() . . . . . . . . . .58 FormDrawFillPoly() . . . . . . . . . .59 FormDrawPoly() . . . . . . . . . . . .59 FormDrawText() . . . . . . . . . . . . .59 FormEllipse() . . . . . . . . . . . . . . .60 FormFillEllipse() . . . . . . . . . . . .60 FormFillRectangle() . . . . . . . . . .66 FormFont() . . . . . . . . . . . . . . . .60 FormLabel() . . . . . . . . . . . . . . . .61 FormLine() . . . . . . . . . . . . . . . . .61 FormLoadBitmap() . . . . . . . . . .62 FormLoadBitmapResource() . . .123 FormLoadBitmapResource() . . .122 FormMenu() . . . . . . . . . . . . . . . .62 FormMenu() . . . . . . . . . . . . . . . .62 FormMouseDown() . . . . . . . . . .63 FormMouseMove() . . . . . . . . . .63 FormMouseUp() . . . . . . . . . . . .63 FormMouseX() . . . . . . . . . . . . .63 FormMouseY() . . . . . . . . . . . . .63 FormNew() . . . . . . . . . . . . . . . .64 FormPen() . . . . . . . . . . . . . . . . .64 FormPolyBrush() . . . . . . . . . . . .64 FormPolyPen() . . . . . . . . . . . . .64 FormPos() . . . . . . . . . . . . . . . . .65

Page 16

Zeus www.krmicros.com

Command Table of Contents

FormPosition() . . . . . . . . . . . . . .65 FormPrint() . . . . . . . . . . . . . . . .65 FormRectangle() . . . . . . . . . . . .66 FormRes() . . . . . . . . . . . . . . . . .66 FormResolution() . . . . . . . . . . . .66 FormSettings() . . . . . . . . . . . . . .67 FormTextBox() . . . . . . . . . . . . . .68 FormTextBox() . . . . . . . . . . . . . .67 FormTextBoxSelection() . . . . . .68 FormTextColor() . . . . . . . . . . . .68 FormTextHeight() . . . . . . . . . . . .69 FormTextWidth() . . . . . . . . . . . .69 FormUpdate() . . . . . . . . . . . . . .68 FormUpdateAutoOff() . . . . . . . .69 FormUpdateAutoOn() . . . . . . . .69 FromFloat . . . . . . . . . . . . . . . . .23 Func . . . . . . . . . . . . . . . . . . . . .24 Fuzzy() . . . . . . . . . . . . . . . . . . .123 GetArgs() . . . . . . . . . . . . . . . . . .25 GetArgsFloat() . . . . . . . . . . . . . .25 GetArgsInt() . . . . . . . . . . . . . . . .25 GetArgsString() . . . . . . . . . . . . .25 GetDate() . . . . . . . . . . . . . . . . . .26 Getms() . . . . . . . . . . . . . . . . . . .27 GetOwner() . . . . . . . . . . . . . . . .26 GetTime() . . . . . . . . . . . . . . . . .27 GetWord() . . . . . . . . . . . . . . . . .115 Global . . . . . . . . . . . . . . . . . . . .27 Gosub . . . . . . . . . . . . . . . . . . . .28 Goto . . . . . . . . . . . . . . . . . . . . . .28 GPSAltitude() . . . . . . . . . . . . . .74 GPSCalcDist() . . . . . . . . . . . . . .74 GPSCourse() . . . . . . . . . . . . . . .74 GPSCVTLatitudeDec() . . . . . . .75 GPSCVTLongitudeDec() . . . . . .75 GPSDate() . . . . . . . . . . . . . . . . .76 GPSDone() . . . . . . . . . . . . . . . .77 GPSLatitude() . . . . . . . . . . . . . .77 GPSLatitudeDec() . . . . . . . . . . .77 GPSLatitudeHem() . . . . . . . . . .77 GPSLoad() . . . . . . . . . . . . . . . .78 GPSLongitude() . . . . . . . . . . . . .78 GPSLongitudeDec() . . . . . . . . .78 GPSLongitudeHem() . . . . . . . . .78 GPSSatellites() . . . . . . . . . . . . .78 GPSSpeed() . . . . . . . . . . . . . . .79 GPSTime() . . . . . . . . . . . . . . . .79 GPSUDate() . . . . . . . . . . . . . . .79 GPSUTime() . . . . . . . . . . . . . . .79 ICaps() . . . . . . . . . . . . . . . . . . . .115

If/Then/Else . . . . . . . . . . . . . . . .28 Inc() . . . . . . . . . . . . . . . . . . . . . .87 Inc() . . . . . . . . . . . . . . . . . . . . . .87 Include . . . . . . . . . . . . . . . . . . . .28 InputBox() . . . . . . . . . . . . . . . . .29 Insert() . . . . . . . . . . . . . . . . . . . .115 Instr() . . . . . . . . . . . . . . . . . . . . .116 Instructions() . . . . . . . . . . . . . . .122 Int() . . . . . . . . . . . . . . . . . . . . . .43 KeyDown() . . . . . . . . . . . . . . . . .29 KRDBAddField() . . . . . . . . . . . .80 KRDBAddRecord() . . . . . . . . . .80 KRDBClose() . . . . . . . . . . . . . . .80 KRDBGetField() . . . . . . . . . . . .81 KRDBOpen() . . . . . . . . . . . . . . .81 KRDBReadRecord() . . . . . . . . .81 KRDBRecords() . . . . . . . . . . . . .82 KRDBResetFields . . . . . . . . . . .82 KRDBSetField() . . . . . . . . . . . . .82 KRDBStringMode . . . . . . . . . . .83 KRDBWriteRecord() . . . . . . . . .83 Left() . . . . . . . . . . . . . . . . . . . . .116 Len() . . . . . . . . . . . . . . . . . . . . .116 Log() . . . . . . . . . . . . . . . . . . . . .87 Log10() . . . . . . . . . . . . . . . . . . .88 LookDown() . . . . . . . . . . . . . . . .29 LookUp() . . . . . . . . . . . . . . . . . .29 Lower() . . . . . . . . . . . . . . . . . . .116 Max() . . . . . . . . . . . . . . . . . . . . .88 Mid() . . . . . . . . . . . . . . . . . . . . .117 Min() . . . . . . . . . . . . . . . . . . . . .88 MsgBox() . . . . . . . . . . . . . . . . . .30 Nop() . . . . . . . . . . . . . . . . . . . . .30 OnGosub . . . . . . . . . . . . . . . . . .31 OnGoto . . . . . . . . . . . . . . . . . . .31 Overlay() . . . . . . . . . . . . . . . . . .117 ParseValue() . . . . . . . . . . . . . . .117 Pause() . . . . . . . . . . . . . . . . . . .31 Platform() . . . . . . . . . . . . . . . . . .31 PlaySound() . . . . . . . . . . . . . . . .32 Pow() . . . . . . . . . . . . . . . . . . . . .88 Print . . . . . . . . . . . . . . . . . . . . .32 Priority() . . . . . . . . . . . . . . . . . . .32 Random() . . . . . . . . . . . . . . . . .89 ReadBit() . . . . . . . . . . . . . . . . . .32 RegCreateKey() . . . . . . . . . . . .33 RegDeleteKey() . . . . . . . . . . . . .33 RegDeleteValue() . . . . . . . . . . .34 RegGetValue() . . . . . . . . . . . . . .34 RegSetValue() . . . . . . . . . . . . . .35

Replace() . . . . . . . . . . . . . . . . . .118 Return . . . . . . . . . . . . . . . . . . . .35 Right() . . . . . . . . . . . . . . . . . . . .118 Round() . . . . . . . . . . . . . . . . . . .89 RunApp() . . . . . . . . . . . . . . . . . .35 Select Case . . . . . . . . . . . . . . . .36 Select Float . . . . . . . . . . . . . . . .36 Select Integer . . . . . . . . . . . . . .36 Select String . . . . . . . . . . . . . . .36 Set . . . . . . . . . . . . . . . . . . . . . . .36 SetDate() . . . . . . . . . . . . . . . . . .37 SetTime() . . . . . . . . . . . . . . . . . .37 Sin() . . . . . . . . . . . . . . . . . . . . . .89 Sinh() . . . . . . . . . . . . . . . . . . . . .89 Sleep() . . . . . . . . . . . . . . . . . . . .37 SocketBuffer() . . . . . . . . . . . . . .104 SocketClearError() . . . . . . . . . .105 SocketClose() . . . . . . . . . . . . . .105 SocketConnect() . . . . . . . . . . . .104 SocketData() . . . . . . . . . . . . . . .105 SocketError() . . . . . . . . . . . . . . .106 SocketInput() . . . . . . . . . . . . . . .106 SocketListen() . . . . . . . . . . . . . .107 SocketOutput() . . . . . . . . . . . . .107 SocketQuickCheck() . . . . . . . . .108 SocketState() . . . . . . . . . . . . . . .108 Sqrt() . . . . . . . . . . . . . . . . . . . . .90 StrIf/Then/Else . . . . . . . . . . . . . .38 StrLookDown() . . . . . . . . . . . . .38 StrLookUp() . . . . . . . . . . . . . . . .38 Tan() . . . . . . . . . . . . . . . . . . . . .90 Tanh() . . . . . . . . . . . . . . . . . . . .90 Timer() . . . . . . . . . . . . . . . . . . . .39 TimerClear() . . . . . . . . . . . . . . .39 ToFloat . . . . . . . . . . . . . . . . . . . .39 Trim() . . . . . . . . . . . . . . . . . . . . .118 TrimEnd() . . . . . . . . . . . . . . . . .119 TrimStart() . . . . . . . . . . . . . . . . .119 Upper() . . . . . . . . . . . . . . . . . . .119 val() . . . . . . . . . . . . . . . . . . . . . .43 Version() . . . . . . . . . . . . . . . . . .40 Wild() . . . . . . . . . . . . . . . . . . . . .120 WriteBit() . . . . . . . . . . . . . . . . . .41

Zeus www.krmicros.com

Page 17

BitGet
BitGet()
BitGet(Value,Bit) BitGet(Iexp,Iexp) Integer Description Returns the state of a bit from a given value. Will return 1 or 0. Value - This integer expression to test. Bit - The bit to test. Only bits 0-23 may be tested.

Base Commands
All

func main() dim x as integer dim value as integer value = 255 for x = 30 to 0 step -1 print bitget(value,x); next print endfunc

BitSet()
BitSet(Value,Bit,Value) BitSet(Iexp,Iexp,Iexp) Integer

All
func main() dim x as integer dim bit as integer

Description Returns the final result of setting or resetting a bit. If you want to change the bit of a variable use it in a expression such as Myvarb=BitSet(Myvarb,13,1) Value - The regional value. IE the variable or expression. Bit - The bit to change. Only bits 0-23 may be changed. Value - If 0 will set the given bit to 0. Any thing else sets it to 1.

for bit = 0 to 30 x=0 bitset(x,bit,1) print bit,x next endfunc

Break()
Break() Break()

ZW5

ZC5

ZC

ZCLCE Zp Pz

Description This command stops execution and places the program in single step mode. Only valid when used with Edit Environment. On Console targets will pause the program.

CalcRPN()
CalcRPN(Name,RPN) CalcRPN(Sexp,Sexp) String Description

ZW5

ZC5 Zp Pz

func main() dim treg as string treg = CalcRPN("Michael Simpson","i 0 == 111 * key + c 2 * +") print treg endfunc

This command will generate and return a registry key based on a Name and RPN string. This command is compatible with Handango and Pocket Gear. Name - This is the name string to work against with the RPN string. Normally it is the Owner Name. RPN - This is the RPN string to calculate against the name. Typical RPN Formulas "i 0 == 111 % key + c 12 * +" Zeus www.krmicros.com

Page 18

Base Commands
"i 0 == 210 - key + c 2 * 4 / +" "i 0 == c + 5 - key + c 77 * +" Currently the following operators are supported Logical: ==, !=, <=, >=, >, < Bitwise: | (or) , & (and) Arithmetic: +, -, *, / , %(mod)

ClearAll

You may use the following variables: i = Index of character being processed. It will be 0-9 c= The ASCII value of the character being processed. 0-255 key = The current key value. This value is calculated at each character. If you create a new formula make sure you test it at Handango with there RPN tester.

Case
Case Value Case Exp

ZW5

ZC5

ZC

ZCLCE Zp Pz

Select Case 25 Case 10 print "Its 10" Case 25 print "Its 25" CasElse print Unknown EndSelect

Description The Case statement is used in the Select Case command to match up a given value or expression.

Value - An attempt is made to match this value to a value given at the start of the Select Case command. If it matches then all the commands following the Case statement will be executed.

CaseElse
CaseElse CaseElse

ZW5

ZC5

ZC

ZCLCE Zp Pz

Description This command is used with the Select Case command. If none of the included Case commands match a value then the CaseElse can be used to as a last chance to catch the result. It must be the last statement in a Select Case command.

ClearAll()
func main() dim x as string x = "Hello" Print "x=",x ClearAll() Print "x=",x endfunc

All

ClearAll() ClearAll() Description Clears all global variables. Clears all local variables in the function that is is called.

Zeus www.krmicros.com

Page 19

ClearGlobal
ClearGlobal()
ClearGlobal() ClearGlobal() Description Clears all global variables.

Base Commands
All
func main() global x as string dim y as string x = "Hello" y = "Goodby" Print "x="+x,"y="+y ClearGlobal() Print "x="+x,"y="+y

ClearLocal()
ClearLocal() ClearLocal() Description Clears all local variables in the function that is is called.

All

ClearLocal() Print "x="+x,"y="+y endfunc

Clipget()
Clipget() Clipget() string Description Returns the data on the clipboard as a string

ZW5

ZC5 Zp Pz

Clipset()
Clipget(Data) Clipget(exp) Description Places a string of data on the clipboard Data - The Data to place on the clipboard.

ZW5

ZC5 Zp Pz

func main() dim dat as string ClipSet("Hello World") dat = ClipGet() print dat endfunc

Console()
Console(Mode) Console(exp)

ZW5

ZC5 Zp Pz

Description By default the Console is in auto mode. It will appear full form if no window commands are used. If window commands are used it will appear at the bottom of the form. With this command you can override the auto mode. Mode - Sets the various console modes. 0 - Auto mode 1 - Suppress Auto Mode (Turn off Console) 2 - Suppress all print and error messages 3 - Force Full form Console 4 - Force Graphic from Only - Shuts down console 5 - Force Small Console on bottom of form. 6 - Removes Console Menu Items from compiled application File Menu.

func main() FormCls() Console(1) 'Turn off Console(6) 'Remove Menu Loop: sleep(1) pause(1) goto Loop endfunc

Page 20

Zeus www.krmicros.com

Base Commands
ZW5

Dim
Cursor()
Cursor(Type) Cursor(exp)

ZC5 Zp Pz

func main() Cursor(1) DoEvents() 'Need to do this pause(5000) Cursor(0) endfunc

Description You can change the default cursor for the graphics form to one of the following. Type - Sets the various cursors 0 1 2 3 4 5 6 7 8 9 - Default Cursor * - Wait Cursor * - Arrow Cursor - Cross Cursor - Hand Cursor - Help Cursor - HSplit Cursor - IBeam Cursor - No Cursor - UpArrow Cursor

* Only 0 and 1 are available on the Pocket PC.

ConsoleCls()
ConsoleCls() ConsoleCls()
func main() dim x as integer For x = 1 to 100 ConsoleCls() print " num=",x Pause(10) Sleep(1) Next Print Print "Done" endfunc

All

Description Clears the console.

Dim
Dim Varb as Type Dim Variable as [string][integer][single]

All

Description Creates a local variable that will exist only as long as the function does. Note that local variables are set to 0 for integer and single and empty for string. Note that you can define multiple integers as in: Dim x,y,z You can not do this for strings or singles. Varb - The name of the variable you wish to create. Must begin with a character. Type - The type of variable you wish to create. Must be integer, single or string. If no type is provided the variable will be created as an integer.

Zeus www.krmicros.com

Page 21

DoEvents
DoEvents()
DoEvents() DoEvents() Description Allows other events to be processed. This is a good command to execute it you are running a real tight loop and you want Zeus to process button or other control events. By default the Zeus engine will handle these for you automatically even in tight loops. However if you set the the priority high you will make it harder for Zeus to handle these events. Use this command to overcome these issues.

Base Commands
All
func main() Cursor(1) DoEvents() 'Need to do this pause(5000) Cursor(0) endfunc

End
End End

All
func main() Dim x as integer For x = 1 to 1000 print x if x = 10 then end endif Next endfunc

Description This command tells Zeus to stop processing commands and to exit the engine. In a runtime environment this command would exit the program. In the development environment it just stops the engine.

Exit()
Exit(Data) Exit(exp) Description This command ends a user function and returns a value. Data - The expression you wish to return

All

func main() print greet() endfunc

Endfunc
endfunc endfunc Description Ends a user function

All

func greet() as string exit("Hello") endfunc

Page 22

Zeus www.krmicros.com

Base Commands
Select Case 25 Case 10 print "Its 10" Case 25 print "Its 25" CasElse print Unknown EndSelect

FromFloat
EndSelect
EndSelect EndSelect Description Ends the Select command.

ZW5

ZC5

ZC

ZCLCE Zp Pz

For/Next
For Varb = StartValue to EndValue [Step StepValue] For Nexp = exp to exp [Step exp] Next Description Takes a variable and counts between StartValue and EndValue. All code between the for command and the next command is executed until the EndValue is reached.

All

func main() dim x as integer For x = 2 to 10 Step 2 print x Next endfunc

Varb - A variable to use for counting. Must be a floating point or integer variable. StartValue - An expression that sets the start counting point for the variable. EndValue - An expression that indicates the stopping point for the count of the Varb. StepValue - If this expression is given it indicates the amount to increment or decrement the variable by. If omitted the step value is +1 by default. Note that if you are counting backwards you must provide a Step -1 option.

FromFloat
func main() dim b1 as integer dim b2 as integer dim b3 as integer dim b4 as integer dim fval as float fval = -1234.1 print fromfloat(fval,b1,b2,b3,b4) print print b1,b2,b3,b4 print tofloat(b1,b2,b3,b4) endfunc

ZW5

ZC5

ZC

ZCLCE Zp Pz

FromFloat(fval,varb1,varb2,varb3,varb4) FromFloat(fexp,ivarb,ivarb,ivarb,ivarb) Description This command takes a floating point expression and breaks it down into 4 byte componetes and places the values into 4 integer variables that you pass. This command is used to break values down so that they can be transmited via sockets or comport. Use the ToFloat command to rebuild. fval - The floating point value or expression to convert. varb1=varb4 - The variables to place the seperate byte componets into.

Zeus www.krmicros.com

Page 23

Func
Func
Func Name(Parms...) Func FuncName(Parm1, Parm2,...) exp Description Starts a new function. You must supply the function with a name. Parameters are optional as is the return type. You may also optionally set up a return type for use with the exit command. Name - The name of the function. This will be used when you call the function Parms - You may declare parameters that can be passed to this function. They will be treated as local variables.

Base Commands
All
func main() print greet() endfunc func greet() as string exit("Hello") endfunc

Page 24

Zeus www.krmicros.com

Base Commands

GetArgs
GetArgs() All

func main() print sayhello("Mike") print sayhello() endfunc func sayhello(name as string) as string if GetArgs() > 0 then exit("Hello "+name) else exit("Who are you.") endif endfunc

GetArgs() GetArgs() Integer Description Returns the total number of arguments sent to the current function.

GetArgsInt()
GetArgsInt() GetArgsInt() Integer Description Returns the number of integer arguments sent to the current function.

All

GetArgsFloat()
GetArgsFloat() GetArgsFloat() Integer Description Returns the number of float arguments sent to the current function.

All

GetArgsString()
GetArgsString() GetArgsString() Integer Description Returns the number of string rguments sent to the current function.

All

Zeus www.krmicros.com

Page 25

GetOwner
GetOwner()
GetOwner() GetOwner) String

Base Commands
ZW5 ZC5 Pz
func main() print "Owner = "+GetOwner() endfunc

Description Returns the Pocket PC Owner Name.

GetDate()
GetDate(Format) Getms(iexp) String Description Returns the current date in various formats.

ZW5

ZC5

Zl

Zp Pz

func main() print GetDate(9) endfunc

Format - An integer that indicates to format to return. 0 1 2 3 4 5 6 7 8 = YYYY-M-D = YYYY-MM-DD = MM/DD/YY = MM/DD/YYYY = Year (Numeric Value) = Month (Numeric Value) = Day (Numeric Value) = DayofWeek (Text Value) = DayofYear (Numeric Value)

Any other value will return current Date and Time in Systems format

Page 26

Zeus www.krmicros.com

Base Commands

Global
Getms() All

func main() dim x as integer loop: x=getms() print x pause(1000) consoleCLS() goto loop

Getms() Getms() Integer Description Returns the number of milliseconds that have elapsed since the program has started.

endfunc

GetTime()
GetTime(Format) GetTime(iexp) String Description Returns the current time in various formats.

ZW5

ZC5 Zp Pz

func main() print GetTime(1) endfunc

Format - An integer that indicates to format to return. -1 = Returns system now.ticks as a string -2 = Returns system now.ticks as a string and resets getms() 0 = H:M:S 1 = HH:MM:SS 2 = UTC Format 3 = Number of Seconds since midnight 4 = Hour (Numeric Value) 5 = Minute (Numeric Value) 6 = Second (Numeric Value) 7 = Milliseconds (Numeric Value) Any other value will return current Time in Systems format

func main() Global X as string X = "Mike" testfunc() print X endfunc func testfunc() X = "Fred" endfunc

Global
Global Varb as Type Global Variable as [string][integer][single]

All

Description Creates a global variable that will exist for all functions. Global variables are not initilized so you need to set them. Note that you can define multiple integers as in: Global x,y,z You can not do this for strings or singles. Varb - The name of the variable you wish to create. Must begin with a character. Type - The type of variable you wish to create. Must be integer, single or string. If no type is provided the variable will be created as an integer.

Zeus www.krmicros.com

Page 27

Gosub
Gosub
Gosub Label Gosub Label Description Makes a call to a subroutine within the current function. Calling subroutines inside the function is several times faster than calling a user function and uses less memory. You return from the subroutine using the Return command. Label - The label to call

Base Commands
All
func main() dim X as String X = "Mike" : Gosub printdat X = "Fred" : Gosub printdat X = "Jhon" : Gosub printdat End printdat: print X Return endfunc

Goto
Goto Label Goto Label Description Jumps to a location in the program with in the current function. Label - The label to jump to.

All
func main() dim X as Integer X=1 Loop: Print X Pause(100) X=X+1 Goto Loop endfunc

If/Then/Else
If OPER1 = Oper2 Then if exp = exp then

All

Description Will compare two numeric expressions. If the compare is true all code between the then and Endif or Else is executed. You may also use the and/or operators to compare more than one expression. Important: If you want to compare strings values you need to use the StrIf command. The If command always converts the string to integers first. You may not mix string and numeric operations using and and and or operators. OPER1 - A numeric operation to compare OPER2 - A numeric operation to compare

func main() Dim x as integer For x = 1 to 1000 print x if x = 10 then end endif Next endfunc

func main()

Include
Include FileName Include Literal Text

All

ZPInitInterface(1,1) endfunc include "+Lib\ZPServo1.Lib"

Description Includes a file as part of the program to run. All include files is read just before the engine is started to create one large continuous virtual file. This allows you to break your code up into useable functions or libraries. FileName - The name of the file to load. Zeus www.krmicros.com

Page 28

Base Commands
InputBox()
func main() dim svarb as string svarb = inputbox("Enter Name","Title","pig",10,10,21) print "Hello "+svarb endfunc

LookDown
All

InputBox(Prompt, [Title], [Default Value]) InputBox(Sexp,[Sexp],[Sexp]) string Description This function will popup a box and prompt the user for a string of data. Prompt - The prompt text displayed to the user. Title - An optional value that will be displayed in the title. Default Value - The default text that will be placed in the input field.

KeyDown()
func main() Loop: if KeyDown(37) =1 then print "Left Arrow" endif if KeyDown(38) =1 then print "Up Arrow" endif if KeyDown(39) =1 then print "Right Arrow" endif if KeyDown(40) =1 then print "Down Arrow" endif goto Loop endfunc

ZW5

ZC5 Zp Pz

KeyDown(KeyCode) KeyDown(exp) integer Description Returns a 1 of the key is currently down. Returns a 0 if not. This function can also be used to determine mouse and stylus events as well. KeyCode - The code of the key you wish to test. 0-255. Note there is a sample program included called KeyScan.txt which can be used to determine the key codes.

LookDown()
LookDown(FailValue,SearchValue,Value0,Value1,Value2) LookDown(exp,exp,exp,exp,exp) integer

All

func main() dim x as integer x=lookdown(1000,90,10,20,30,40,50,60,70,80,90) print x endfunc

Description Search a list of values then return an index to that value. This function is zero based and will return FailValue if it can not find the SearchValue. FailValue - The value to return if the Search value is not located in any of the Values given. SearchValue - The Value used to search for. Value0-ValueN - The values to search against.

LookUp()
LookUp(FailValue,Index,Value0,Value1,Value2) LookUp(exp,exp,exp,exp,exp) integer Description Return a value based on an Index. This is 0 based.

All

FailValue - The value to return if the Index is less then 0 or greater then the number of items. Index - The value used to index and retrieve the value list. Value0-ValueN - The value to return based on the Index. If the index is 0 then Value0 is returned. If the index is 1 then Value1 and so on.

Zeus www.krmicros.com

Page 29

MsgBox
MsgBox()
MsgBox(Prompt,Buttons,[Title]) MsgBox(Sexp,Iexp,[Sexp]) integer Description This function will popup a message box. You can set the button types by setting the Buttons argument. The function will return a integer representing the button hit. This command can be used in a expression or standalone. Prompt - The prompt text displayed to the user. Buttons - An integer representing the types of buttons to display. 0 Displays OK button only. 1 Displays OK and Cancel buttons. 2 Displays Abort, Retry, and Ignore buttons. 3 Displays Yes, No, and Cancel buttons. 4 Displays Yes and No buttons. 5 Displays Retry and Cancel buttons. 16 Displays Critical Message icon. 32 Displays Warning Query icon. 48 Displays Warning Message icon. 64 Displays Information Message icon. 0 First button is default. 256 Second button is default. 512 Third button is default. Title - An optional value that will be displayed in the title. Returns the following depending on which button is hit. OK 1 Cancel 2 Abort 3 Retry 4 Ignore 5 Yes 6 No 7

Base Commands
All
func main() dim ivarb as integer ivarb = msgbox("!!!! Warning !!!!",16,"Ooops") print "Result="+ivarb endfunc

Nop()
Nop() Nop()

All

Description This command does nothing. It is provided to aid in debugging during the single step process. It can also be used to create very small delays in the microseconds.

Page 30

Zeus www.krmicros.com

Base Commands

Platform
OnGosub All

func main() dim x as integer print "Platform = "+Platform() for x = -2 to 4 print x;" "; ongosub x,do0,do1,do2 pause(500) next end do0: print "do0" return do1: print "do1" return do2: print "do2" return

OnGosub Index ,Label0,Label1,... OnGosub Iexp,Label,Label,... Description Call a subroutine based on an index. Index is zero based. The return command will return to the next command following this command. Index - A value used to calculate the label to locate for the jump. Label0-LableN - The labels for possible jumps.

OnGoto
OnGoto Index ,Label0,Label1,... OnGoto Iexp,Label,Label,... Description Jump to a label based on an index. Index is zero based. Index - A value used to calculate the label to locate for the jump. Label0-LableN - The labels for possible jumps.

All

endfunc

Pause()
Pause(ms) Pause(Iexp)

All

Description Cause Zeus to wait for the number of milliseconds indicated. Note that Zeus will process events and allow outside process to run during the wait. ms - The number of milliseconds to wait.

Platform()
Platform() Platform() integer Description Returns a number indicating the current platform. 1 2 3 4 - Desktop Compiled Application - Desktop Development - Pocket PC Compiled Application - Pocket PC Development

Zp Pz

Zeus www.krmicros.com

Page 31

PlaySound
PlaySound()
PlaySound(File) PlaySound(Sexp) Description Plays a wave file located in the Zeus directory. File - The file to play. This must be a wave file. If you begin with a . then the current Zeus directory will be used for the file.

Base Commands
Zl Zp Pz PzL
func main() 'Play Built-in Default Sound (beep) playsound("xx") endfunc

Print
Print Value1,Value2 Print Sexp,Sexp or Print Sexp;Sexp

All
func main() dim ivarb as integer ivarb = msgbox("!!!! Warning !!!!",16,"Ooops") print "Result="+ivarb endfunc

Description Prints data to the console. Data separated by commas will be separated with a tab. Those with a semicolon will be placed right next to one another. Note that any type of expression can be used but all will be converted to strings before printing.

Priority()
Priority(Cycles) Priority(Iexp)

All

Description This command allows you change the amount of time slices the Zeus engine gets over the rest of the operating system. The default is a setting of 25. The value can be between 1 and 1000. With 1000 the highest priority going to the Zeus engine Cycles - The number of engine cycles to run before freeing a time slice to an outside process.

func main() Priority(1) Loop: nop goto Loop endfunc

Note that unless you are running on a slow machine or have several threads running this command will have little effect.

ReadBit()
ReadBit(Array,Bit) ReadBit(ArrayName,exp) integer

ZW5

ZC5

ZC

ZCLCE Zp Pz

Description Returns the value 0 or 1 of a bit across an integer array. Note that only the lower 8bits are used in each array element. Array - The name of the array to read a bit from. Bit - The bit across the array to access

Page 32

Zeus www.krmicros.com

Base Commands

RegDeleteKey
RegCreateKey()
RegCreateKey(Type,KeyName) RegCreateKey(exp,Sexp) integer Description Creates a registry Key. The command can be called standalone or as a value. Will return 1 if success and 0 if failure. Type - Sets the registry tree 0 1 2 3 = HKEY_CLASSES_ROOT = HKEY_CURRENT_USER = HKEY_LOCAL_MACHINE = HKEY_USERS

ZW5

ZC5

Zp Pz

KeyName - The name of the key to create.


func main() dim x as string x = RegCreateKey(1,"Software\KRMicros\RegTest") print "Create Status = ",x x = RegSetValue(1,"Software\KRMicros\RegTest","Name","Fred") print "Set Status = ",x x = RegGetValue(1,"Software\KRMicros\RegTest","name") print "Get Value= ",x x = RegDeleteKey(1,"Software\KRMicros\RegTest") print "Delete Status = ",x endfunc

RegDeleteKey()
RegDeleteKey(Type,KeyName) RegDeleteKey(exp,Sexp) integer

ZW5

ZC5 Zp Pz

Description Deletes a registry Key. The command can be called standalone or as a value. Will return 1 if success and 0 if failure. Type - Sets the registry tree 0 1 2 3 = HKEY_CLASSES_ROOT = HKEY_CURRENT_USER = HKEY_LOCAL_MACHINE = HKEY_USERS

KeyName - The name of the key to delete

Zeus www.krmicros.com

Page 33

RegDeleteValue
RegDeleteValue()
RegDeleteValue(Type,KeyName,ValueName) RegDeleteValue(exp,Sexp,Sexp) integer Description Deletes a registry Key value. The command can be called standalone or as a value. Will return 1 if success and 0 if failure. Type - Sets the registry tree 0 1 2 3 = HKEY_CLASSES_ROOT = HKEY_CURRENT_USER = HKEY_LOCAL_MACHINE = HKEY_USERS

Base Commands
ZW5 ZC5 Zp Pz

KeyName - The name of the key to delete ValueName - The name of the Value to delete

RegGetValue()
RegGetValue(Type,KeyName,ValueName) RegGetValue(exp,Sexp,Sexp) integer

ZW5

ZC5 Zp Pz
func main() dim x as string x = RegCreateKey(1,"Software\KRMicros\RegTest") print "Create Status = ",x x = RegSetValue(1,"Software\KRMicros\RegTest","Name","Fred") print "Set Status = ",x x = RegGetValue(1,"Software\KRMicros\RegTest","name") print "Get Value= ",x x = RegDeleteKey(1,"Software\KRMicros\RegTest") print "Delete Status = ",x endfunc

Description Returns a registry Key value. The command can be called standalone or as a value.

Type - Sets the registry tree 0 1 2 3 = HKEY_CLASSES_ROOT = HKEY_CURRENT_USER = HKEY_LOCAL_MACHINE = HKEY_USERS

KeyName - The name of the key to delete ValueName - The name of the Value to delete

Page 34

Zeus www.krmicros.com

Base Commands
ZW5

RunApp
RegSetValue()
RegSetValue(Type,KeyName,ValueName,Value) RegSetValuee(exp,Sexp,Sexp,exp) integer Description Sets a registry Key value. The command can be called standalone or as a value. Will return 1 if success and 0 if failure. Type - Sets the registry tree 0 1 2 3 = HKEY_CLASSES_ROOT = HKEY_CURRENT_USER = HKEY_LOCAL_MACHINE = HKEY_USERS

ZC5 Zp Pz

KeyName - The name of the key to delete ValueName - The name of the Value to delete Value - The value to write.
func main() dim X as String X = "Mike" : Gosub printdat X = "Fred" : Gosub printdat X = "Jhon" : Gosub printdat End printdat: print X Return endfunc

Return
Return Return

All

Description This command returns from a gosub call. Note that returning without a gosub will cause stack errors.

RunApp()
RunApp(Application,Arguments) RunApp(Sexp,Sexp)
func main() RunApp(".RunApp.txt","") endfunc

ZW5

ZC5 Zp Pz

Description This command will let you start another application. Application - The path and name of the application to run. You may use the + and . to add the source or application path to the expression. Arguments - The arguments you want to add. If you don't want any arguments you must use an empty string. Here you may also add the application or source path but because you may also pass non file arguments you have to preface the + or . with a ~. The ~. and ~+ are only valid on the first argument.

Zeus www.krmicros.com

Page 35

Select Case
Select Case
Select Case value Select Case exp

Base Commands
ZW5 ZC5 ZC ZCLCE Zp Pz
Select Case 25 Case 10

Select Integer
Select Integer value Select Integer exp

ZW5

ZC5

ZC

ZCLCE Zp Pz

print "Its 10" Case 25 print "Its 25" CasElse

Select Float
Select Float value Select Float exp

ZW5

ZC5

ZC

ZCLCE Zp Pz

print Unknown EndSelect

Select String
Select String value Select String exp

ZW5

ZC5

ZC

ZCLCE Zp Pz

Description The Select command is a multi part command. You start the command with a Select and Selection type. IE Select Integer. If you use the Select Case it defaults to a Selection type of string that will work with all values. If you are using Integers then a Select Integer will run much faster than the other types. You need to also keep this in mind if you are going to use math in the expression.

Value - This is a expression that will represent the value that we will try to match up with a Case command. Again note that the default type of string uses string math when calculating this expression. It may be necessary to use a Int() or Float() function to encapsulate your math. You can always use the raw Select Integer or Select Float for better and faster number comparisons.

Set
Set Varb = x,y,z,.... Set Variable = exp,exp,exp,....

ZW5

ZC5 Zp Pz
dim tvarb(5) as integer set tvarb = 10,20,30,40,50

Description Lets you quickly load a array variable starting at its first position. This command works with string, integer and floating point variables. Varb - The name of the variable you wish to load. Note that no bounds checking is done and if you load more than the variable was defined or you load a non array variable the next entry will be loaded into the next defined variable. x,y,z - The data to load into the variable. This expression is calculated at runtime so any valid expression will work. Even functions.

Page 36

Zeus www.krmicros.com

Base Commands
SetDate()
SetDate(Month,Day,Year) SetDate(exp,exp,exp)

Sleep
ZW5 ZC5 Zp Pz

Description This command will set the system date of your PC or Pocket PC. Note that this date is expressed in Coordinated Universal Time (UTC). That is to say that your local time in your PC or Pocket PC will automatically be calculated to the correct time and date based on the UTC you provide. This command works with string, integer and floating point variables. Month - The number of the month you wish to set. 1-12 Day - The number of the day you wish to set. 1-31 Year - The number of the year you wish to set. This is the full year. IE 2000
func main() SetTime(04,25,00) endfunc

SetTime()
SetTime(Hour,Minute,Second) SetTime(exp,exp,exp)

ZW5

ZC5

Zp Pz

Description This command will set the system time of your PC or Pocket PC. Note that this date is expressed in Coordinated Universal Time (UTC). That is to say that your local time in your PC or Pocket PC will automatically be calculated to the correct time and date based on the UTC you provide. This command works with string, integer and floating point variables. Hour - The number of the hour you wish to set. 0-24 Minute - The number of the minutes you wish to set. 0-59 Second - The number of the seconds you wish to set. 0-59

Sleep()
func main() Priority(1000) Loop: Sleep(1) goto Loop endfunc

All

Sleep(ms) Sleep(Iexp) Description This command allows you to put the Zeus engine to sleep. ms - The number of milliseconds to sleep

Zeus www.krmicros.com

Page 37

StrIf
StrIf/Then/Else
StrIf OPER1 = Oper2 Then Strif Sexp = Sexp then Description Will compare two string expressions. If the compare is true all code between the then and Endif or Else is executed. Important: The StrIf command does a string comparison not a number comparison therefore "01" is not the same as "1". Use the If command if you want to compare numeric values. OPER1 - A string operation to compare OPER2 - A string operation to compare

Base Commands
All
func main() dim X as string X = "Mike" StrIf X = "Mike" then print "Hello Mike" endif endfunc

StrLookDown()
StrLookDown(FailValue,Mode,SearchValue,Value0,Value1,Value2) StrLookDown(exp,Iexp,exp,exp,exp,exp) integer Description Search a list of strings then return an index to that value. This function is zero based and will return FailValue if it can not find the SearchValue. FailValue - The value to return if the Search value is not located in any of the Values given. Mode - Sets the type of compare when doing the search. SearchValue - The string to search for. Value0-ValueN - The strubgs to search against. Valid Modes 0=Standard compare 1=Case Insensitive 2=Look for ValueN inside SearchValue 3=Look for ValueN inside SearchValue but Case Insensitive 4=Look for SearchValue inside ValueN 5=Look for SearchValue inside ValueN but Case Insensitive

All

func main() dim x as integer

x=strlookdown(1000,0,"Mike","Jow","Fred","Bill","Mike","Tom","Button") print x endfunc

StrLookUp()
StrLookUp(FailValue,Index,Value0,Value1,...) StrLookUp(Sexp,Iexp,Sexp,Sexp,...) string

All

func main() dim tstr as string dim x as integer x = 1000 tstr=strlookup("NoName",2,"Mike","Joe","Bill","Fred") print tstr endfunc

Description Retrieve a string based on Index. Returns FailValue if Index is out of range. FailValue - The string to return if the Index is less than 0 or is greater than the number of items. Index - Used to look up a particular Value. Value0-ValueN - The string to return based on the Index. If the Index is 0 then Value 0 is returned. If its 1 then Value1 is returned and so on.

Page 38

Zeus www.krmicros.com

Base Commands
ZW5 ZC5 ZC

ToFloat
TimerClear() ZCLCE Zp Pz

func main() dim x as integer TimerClear(1) Loop: x = Timer(1) print x if x > 10000 then TimerClear(1) endif pause(1000) goto Loop endfunc

TimerClear(IDX) TimerClear(exp) Description Resets one of the System Timers to 0 IDX - The number of the timer to reset (1-50)

Timer()
Timer(IDX) Timer(exp) as integer

ZW5

ZC5

ZC

ZCLCE Zp Pz

Description Returns the current timer value in milliseconds. IDX - The number of the timer to reset (1-50)

ToFloat
func main() dim b1 as integer dim b2 as integer dim b3 as integer dim b4 as integer dim fval as float fval = -1234.1 print fromfloat(fval,b1,b2,b3,b4) print print b1,b2,b3,b4 print tofloat(b1,b2,b3,b4) endfunc

ZW5

ZC5

ZC

ZCLCE Zp Pz

ToFloat(varb1,varb2,varb3,varb4) ToFloat(exp,exp,exp,exp) as float Description This command takes 4 byte componets and rebuilds a float value. Use the FromFloat command to rebuild. varb1=varb4 - The individual byte componets used to rebuild the float value.

Zeus www.krmicros.com

Page 39

Version
Version()
Version(Text) Version(Sexp)

Base Commands
ZW5 ZC5 Zp Pz
func main() Version("Test Application V1.1") loop: sleep(1) goto loop endfunc

Description This command allows you to set the first 50 characters of the about box of the compiled exe. This will allow you to display application and version information. Note that two line breaks are added and all others are stripped out.

Page 40

Zeus www.krmicros.com

Base Commands
ZW5 ZC5 ZC

WriteBit
WriteBit()
WriteBit(Array,Bit,Value) WriteBit(ArrayName,exp,exp) Description Sets a bit in an integer array. Note that only the lower 8bits are used in each array element. Array - The name of the array to write to. Bit - The bit across the array to access Value - The value 0 or 1 to write.

ZCLCE Zp Pz

Zeus www.krmicros.com

Page 41

Asc
Asc()
asc(Value) asc(Sexp) integer Description Returns an Integer value representing the character code corresponding to the first character in a string. Value - A String

Conversion Commands
All

func main() dim X as integer X = Asc("A") print X

endfunc

Chr()
chr(Value) chr(exp) string Description Returns the character associated with the specified character code.

All

func main() print "A="+chr(65) endfunc

Value - An integer representing a character code. Note that only the first 8 bits of this code is used.

Csng()
csng(Value) csng(exp) single Description Converts any expression to a floating point. Value - An expression string or numeric.

All

func main() print 5.2 + 2.2 print Csng(5.2 + 2.2) endfunc

Cstr()
cstr(Value) cstr(exp) string Description Converts a numeric expression to a string. Value - A number Normaly this command is not needed

All

func main() dim X as integer X = Cstr(5+2) print X

endfu

Page 42

Zeus www.krmicros.com

Conversion Commands

Val
Cint() All

func main() print 5 + 2 print Cint(5 + 2) endfunc

cint(Value) cint(exp) integer Description Converts any expression to a integer Value - An expression string or numeric.

Float()
func main() print 5.2 + 2.2 print float(5.2 + 2.2) endfunc

All

Float(Value) Float(exp) single Description Converts any expression to a floating point. Value - An expression string or numeric.

Int()
func main() print 5 + 2 print int(5 + 2) endfunc

All

Int(Value) Int(exp) integer Description Converts any expression to a integer point. Value - An expression string or numeric.

val()
func main() dim myStr as string dim X as integer myStr = "75" X = Val(myStr) print X

All

val(Value) val(Sexp) integer/single Description Converts a string expression to a number. Value - A string

endfun

Zeus www.krmicros.com

Page 43

FileClose
Zeus File commands have the ability to specify the source path by beginning the file name with a '+' , '.' or -. If the file begins with a '+' the location of the Zeus application exe will be the starting path. If the file begins with a '.' then the location of the source code will be used. Note that once you create an exe the '+' and '.' are the same and point to the directory of the compiled exe. Note this applies when you are running that exe file. If a - is used the current directory is used. The current directory can be changed with the FileFolderChange command.
func main()

File Commands

FileClose()
FileClose(Channel) FileClose(number) integer

All

FileOpen(1,".filetest",Create) FileWriteLine(1,"Now is the Time") FileClose(1) endfunc

Description Closes and open file. If the file is already closed no action is taken. Returns 1 if successful or 0 if file is already closed. Channel - The file channel to close. (1-5) This must be a number. This command can be called standalone if you don't care about the result.
func main()

FileCopy()
FileCopy(SourceFile,DestFile) FileClose(Sexp,Sexp) integer

All

dim stat as integer stat = FileCopy(".FileTest.txt",".FileDup.txt") print "Copy status=",stat stat = FileMove(".FileDup.txt",".FileDup2.txt") print "Move status=",stat stat = FileDelete(".FileDup2.txt") print "Delete status=",stat endfunc

Description Make a copy of a file. Returns 1 of successful and 0 if an error. This command can be used standalone if you don't care about the result. SourceFile - The file to copy. DestFile - The name to copy it to.

FileDialog()

ZW5

ZC5

ZC

ZCLCE Zp Pz

FileDialog(Mode,Path,Title,DefFile) FileDialog(Iexp,Sexp,Sexp,Sexp) string Description Creates a Open or Save Dialog box. Will return the full path of the selected or entered file or directory. Returns an empty string if cancel is hit. Mode - This sets the mode. 1 = Open, 2 = Save, 3 = Open with Directory Selection, 4 = Save with Directory Selection. Path - The starting directory. Title - This will be the title or message to display to the user. DefFile - The startup file name. Note that modes 3 and 4 are only valid on the Pocket PC.
func main() dim tfile as string tfile = FileDialog(1,".","Select File","") print "Got File "+tfile endfunc

Page 44

Zeus www.krmicros.com

File Commands

FileInfo
FileDelete()
FileDelete(File) FileDelete(Sexp) integer Description Delete a file. Returns 1 of successful and 0 if an error. This command can be used standalone if you don't care about the result. File - The name of the file to delete.

All

func main() dim stat as integer stat = FileCopy(".FileTest.txt",".FileDup.txt") print "Copy status=",stat stat = FileMove(".FileDup.txt",".FileDup2.txt") print "Move status=",stat stat = FileDelete(".FileDup2.txt") print "Delete status=",stat endfunc

FileEOF()
func main() FileOpen(1,".FileTest.txt",Open) Loop: if FileEOF(1) = 0 then print FileRead(1) goto Loop endif FileClose(1) print "All Done" endfunc

All

FileEOF(Channel) FileEOF(number) integer Description Returns the EOF status of an opened file. Returns 1 if at the end of the file and 0 if not. Channel - The file channel to test. (1-5) This must be a number.

FileFolderChange
func main()

Zp

FileFolderChange(Folder) FileFolderChange(Sexp) integer Description Change the applications current directory. If passed in a expression will return 0 if error and 1 if success. Folder - The path of the folder to change to.

print " Start in "+FileFolderCurrent() FileFolderChange("-lib") print " Change to "+FileFolderCurrent() print print "Files located in current directory" print "--------------" print Replace(FileFolderInfo("-",21),",",chr(13)+chr(10)) endfunc

FileFolderCreate
FileFolderCreate(Folder) FileFolderCreate(Sexp) integer

Zp Pz

Description Creates a folder. If passed in a expression will return 0 if error and 1 if success. Folder - The path of the folder to create

Zeus www.krmicros.com

Page 45

FileFolderCurrent
FileFolderCurrent
FileFolderCurrent() FileFolderCurrent() string Description Returns the name of the current folder. Note that when the application starts this the application starting directory. You can change this with the FileFolderChange command.

Zp

FileFolderDelete
FileFolderDelete(Folder) FileFolderDelete(Sexp) integer

ZW5

ZC5

ZC

ZCLCE Zp Pz

Description Deletes a folder. If passed in a expression will return 0 if error and 1 if success. Folder - The path of the folder to delete

FileFolderInfo
FileFolderInfo(Folder,Mode) FileFolderInfo(Sexp,Iexp) string

ZW5

ZC5 Zp Pz

func main()

Description Depending on the mode returns information about a folder. File - The path to the file you want information on. Mode - Determines the information you wish to return. 1 = Root Path 2 = Exists Returns the string True or False 3 = Parent Path 4 = Full Path 5 = Creation Year 6 = Creation Month 7 = Creation Day 8 = Creation Hour 9 = Creation Minute 10 = Creation Second 11 = Full Creation Date as String 12 = Access Year 13 = Access Month 14 = Access Day 15 = Access Hour 16 = Access Minute 17 = Access Second 18 = Full Access Date as String 19 = Directory Name 20 = Number of files in folder 21 = Returns all file names in folder separated by comma 22 = Number of directories in folder 23 = Returns all directory names in folder separated by comma

print " Start in "+FileFolderCurrent() FileFolderChange("-lib") print " Change to "+FileFolderCurrent() print print "Files located in current directory" print "--------------" print Replace(FileFolderInfo("-",21),",",chr(13)+chr(10)) endfunc

Page 46

Zeus www.krmicros.com

FileInfo
FileInfo()
FileInfo(File,Mode) FileInfo(Sexp,Iexp) string Description Depending on the mode returns information about a file. File - The path to the file you want information on. Mode - Determines the information you wish to return. 1 = File Size 2 = Exists Returns the string True or False 3 = Extension 4 = Directory 5 = Creation Year 6 = Creation Month 7 = Creation Day 8 = Creation Hour 9 = Creation Minute 10 = Creation Second 11 = Full Creation Date as String 12 = Access Year 13 = Access Month 14 = Access Day 15 = Access Hour 16 = Access Minute 17 = Access Second 18 = Full Access Date as String 19 = File Name

ZW5

ZC5

Zl Zp Pz PzL

print print print print

"This file 'FileInfo.txt'" "Directory="+FileInfo(".FileInfo.txt",4) "Size="+FileInfo(".FileInfo.txt",1) "Created="+FileInfo(".FileInfo.txt",11)

Displays: This file 'FileInfo.txt' Directory=D:\cursource\mobile\Zeus\Examples Size=213 Created=6/7/2006 9:59:17 PM

Zeus www.krmicros.com

Page 47

FileMove
FileMove()
FileMove(SourceFile,DestFile) FileMove(Sexp,Sexp) integer

File Commands
All
func main() dim stat as integer stat = FileCopy(".FileTest.txt",".FileDup.txt") print "Copy status=",stat

Description Move a file from one location to another. Returns 1 of successful and 0 if an error. This command can be used standalone if you don't care about the result. SourceFile - The file to copy. DestFile - The name and destination of the new file.

stat = FileMove(".FileDup.txt",".FileDup2.txt") print "Move status=",stat stat = FileDelete(".FileDup2.txt") print "Delete status=",stat endfunc

FileOpen()
FileOpen(Channel,File,Mode) FileOpen(number,strexp,token) Integer Description Opens a file in various modes. Returns 1 if success and 0 if not.

All

func main() FileOpen(1,".filetest",Create) FileWriteLine(1,"Now is the Time") FileClose(1) endfunc

Channel - The file channel to test. (1-5) This must be a number. File - The file name to open. If you begin with a . then the current Zeus directory will be used for the file. Mode - The mode of operation. Open will open a file for read. Create will create a new file or overwrite an existing file. Append will add to the end of an existing file. You may also open the file in binary mode. BinaryOpen will open an existing file. BinaryCreate will Create a new file. When a file is opened as Binary you my perform both reading and writing on the file. This command can be called standalone if you don't care about the result.

FilePeek()
FilePeek(Channel) FilePeek(number) Integer Description Returns the next character without incrementing the file pointer. If at the end of the file a -1 is returned.. Channel - The file channel to test. (1-5) This must be a number.
func main()

All

FileOpen(1,".FileTest.txt",Open) Loop: if FileEOF(1) = 0 then print "Current character is "+FileRead(1)+" The next character is "+FilePeek(1) goto Loop endif FileClose(1) print "All Done" endfunc

Page 48

Zeus www.krmicros.com

File Commands

FileReadFile
FilePos() All

func main() FileOpen(1,".FileTest.txt",BinaryOpen) Loop: if FileEOF(1) = 0 then print "Current character is "+FileRead(1)+" at pos "+FilePos(1) goto Loop endif FileClose(1) print "All Done" endfunc

FilePos(Channel) FilePos(number) Integer Description Returns the current file position. Only works with file that were opened as binary. Returns -1 if error Channel - The file channel to test. (1-5) This must be a number.

FileRead()
func main() FileOpen(1,".FileTest.txt",Open) Loop: if FileEOF(1) = 0 then print FileRead(1) goto Loop endif FileClose(1) print "All Done" endfunc

All

FileRead(Channel) FileRead(number) Integer Description Returns the next character. This command will return a -1 if the end of file is reached. This is much faster than using the FileSeek of FilePeek commands. Channel - The file channel to test. (1-5) This must be a number.

FileReadFile()
func main() dim fdat as string dim x as integer FileOpen(1,".FileTest.txt",BinaryOpen) fdat = FileReadFile(1) FileClose(1) for x = 0 to Len(fdat) print mid(fdat,x,1); next endfunc

All

FileReadFile(Channel) FileReadFile(number) String Description Returns the the complete file from the current position. If the file is opened in binary mode this will be raw byte data. Channel - The file channel to test. (1-5) This must be a number.

Zeus www.krmicros.com

Page 49

FileReadLine
FileReadLine()
FileReadLine(Channel) FileReadLine(number) Integer Description Returns the next line of data from the file. *Not available in Binary Mode Channel - The file channel to test. (1-5) This must be a number.

File Commands
All
func main() dim ldat as string dim x as integer FileOpen(1,".FileTest.txt",Open) Loop: if FileEOF(1) = 1 then FileClose(1) End endif ldat = FileReadLine(1) print ldat goto Loop

FileSeek()
FileSeek(Channel,Offset) FileSeek(number,Iexp) integer

All

endfunc

main()

Description Moves the file pointer on a file opened for read. Returns 1 of successful and 0 if an error. This command can be used standalone if you don't care about the result. Channel - The file channel to close. (1-5) This must be a number. Offset - The position to move the pointer.

dim fdat as string FileOpen(1,".FileTest.txt",Open) FileSeek(1,20) fdat=FileReadLine(1) print fdat FileClose(1) endfunc

FileWrite()
FileWrite(Channel,String) FileWrite(number,Sexp) integer Description Writes a character to the current file. Returns 1 of successful and 0 if an error. This command can be used standalone if you don't care about the result. Channel - The file channel to test. (1-5) This must be a number. String - A string containing the character/s to write.

All
func main() dim fdat as string FileOpen(1,".writetest",Create) FileWrite(1,"Hello") FileWrite(1,"Goodby") FileWrite(1,"ItWorks") FileClose(1) FileOpen(1,".writetest",Open) fdat=FileReadFile(1) FileClose(1) print fdat endfunc

Page 50

Zeus www.krmicros.com

File Commands

FileWriteLine
FileWriteFile()
FileWriteFile(Channel,String) FileWriteFile(number,sexp) integer Description Writes a raw data string to the current file from the current position. Returns 1 of successful and 0 if an error. This command can be used standalone if you don't care about the result. Channel - The file channel to test. (1-5) This must be a number. String - A string containing the data to write.

All

func main() dim fdat as string fdat = "Now is the time for all good men to come to the aid of their country."+chr(13)+chr(10) FileOpen(1,".data",Create) FileWriteFile(1,fdat) FileClose(1) endfunc

FileWriteLine()
FileWriteLine(Channel,String) FileWriteLine(number,Sexp) integer
func main() FileOpen(1,".filetest",Create) FileWriteLine(1,"Now is the Time") FileClose(1) endfunc

All

Description Writes a string of characters and newline character to the current file. *Not available in Binary Mode. This command can be called standalone if you don't care about the result. Channel - The file channel to test. (1-5) This must be a number. String - A string containing the data to write.

Zeus www.krmicros.com

Page 51

FileQuickAdd
FileQuickAdd()
FileQuickAdd(File,Data) FileQuickAdd(Sexp,exp) integer Description Opens a file in and adds a line of data to that file. The File is closed after the write. Note that no channel number is needed for this command. Returns 1 of successful and 0 if an error. This command can be used standalone if you don't care about the result. File - The file name to open. If you begin with a . then the current Zeus directory will be used for the file. Data - The Data to write.

File Commands
All
func main() FileQuickAdd(".testit.txt","Line1") FileQuickAdd(".testit.txt","Line2") FileQuickAdd(".testit.txt","Line3") endfunc

FileQuickLoad()
FileQuickLoad(File) FileQuickLoad(Sexp) String Description Opens a file and reads in the first line of data and returns it. The file is closed after the read. Note that no channel number is needed for this command.

All
func main() dim num as integer num = FileQuickLoad(".gennumber") print num num = num + 1 FileQuickSave(".gennumber",num) num = FileQuickLoad(".gennumber") print num num = num + 1 FileQuickSave(".gennumber",num) num = FileQuickLoad(".gennumber") print num

File - The file name to open. If you begin with a . then the current Zeus directory will be used for the file.

endfunc

FileQuickLoadAll()
FileQuickLoadAll(File) FileQuickLoadAll(Sexp) String

ZW5

ZC5

ZC

ZCLCE Zp Pz

Description Opens a file and reads in all of the file and returns it. The file is closed after the read. Note that no channel number is needed for this command. File - The file name to open. If you begin with a . then the current Zeus directory will be used for the file.
func main() dim ostr as string dim istr as string ostr = "Now is the time"+chr(13)+chr(10)+"for all good men" FileQuickSaveAll(".fqsa",ostr) istr = FileQuickLoadAll(".fqsa") print istr

endfunc

Page 52

Zeus www.krmicros.com

File Commands

FileQuickSave
FileQuickSave() All

func main() dim num as integer num = FileQuickLoad(".gennumber") print num num = num + 1 FileQuickSave(".gennumber",num) num = FileQuickLoad(".gennumber") print num num = num + 1 FileQuickSave(".gennumber",num) num = FileQuickLoad(".gennumber") print num

FileQuickSave(File,Data) FileQuickSave(Sexp,exp) integer Description Creates a new file in and writes a line of data to that file. The File is closed after the write. Note that no channel number is needed for this command. Returns 1 of successful and 0 if an error. This command can be used standalone if you don't care about the result. File - The file name to open. If you begin with a . then the current Zeus directory will be used for the file. Data - The Data to write.

endfunc

FileQuickSaveAll()

ZW5

ZC5

ZC

ZCLCE Zp Pz

FileQuickSaveAll(File,Data) FileQuickSaveAll(Sexp,exp) integer Description Creates a new file in and writes the passed expression of data to that file. The File is closed after the write. Note that no channel number is needed for this command. Returns 1 of successful and 0 if an error. This command can be used standalone if you don't care about the result. File - The file name to open. If you begin with a . then the current Zeus directory will be used for the file. Data - The Data to write. This data may contain multiple lines.
func main() dim ostr as string dim istr as string ostr = "Now is the time"+chr(13)+chr(10)+"for all good men" FileQuickSaveAll(".fqsa",ostr) istr = FileQuickLoadAll(".fqsa") print istr

endfunc

Zeus www.krmicros.com

Page 53

FormAddPoint
FormAddPoint()
FormAddPoint(ID [,XPoint,YPoint,Xpoint,YPoint.....]) FormAddPoint(Iexp [,Iexp,Iexp,Iexp,Iexp...]) Description Adds points to a polygon shape. ID - The ID of the Polygon. XPoint,YPoint - These are the point pairs. They are optional but must be provided in pairs.

Form Commands
ZW5 ZC5 Zp Pz
func main() FormCLS() FormCreatePoly(0) FormAddPoint(0,10,10,20,10,20,20,10,20,10,10) FormPolyBrush(0,255,0,0) dim x as integer dim y as integer for y = 1 to 120 step 12 for x = 1 to 120 step 12 FormDrawFillPoly(0,x,y) FormDrawPoly(0,x,y) next next endfunc

FormBGColor()
FormBGColor(Red,Green,Blue) FormBGColor(Iexp,Iexp,Iexp)

ZW5

ZC5 Zp Pz

Description Sets the Background color of the form. This will affect the FormPrint, FormLabel, FormTextBox and FormCls commands. Red - The color of the Red element. 0-255 Green - The color of the Green element. 0-255 Blue - The color of the Blue element. 0-255

FormBitmapColor()
FormBitmapColor(Image,Red,Green,Blue) FormBitmapColor(lexp,lexp,Iexp,Iexp)

ZW5

ZC5 Zp Pz
func main() dim mflag,mx,my formloadbitmap(0,".ball4.bmp") formbitmapcolor(0,255,255,255) formdrawbitmap(0,10,10) endfunc

Description Sets the color that will become transparent for the indicated bitmap image. Image - The image number that you want to set. Red - The color of the Red element. 0-255 Green - The color of the Green element. 0-255 Blue - The color of the Blue element. 0-255

FormBitmapColorClear()
FormBitmapColorClear(Image) FormBitmapColorClear(Iexp)

ZW5

ZC5 Zp Pz

Description Clears the transparent color mask so that no color is transparent. Image - The image number that you want to set.

Page 54

Zeus www.krmicros.com

Form Commands

FormBitmapTarget
FormBitmapSave() ZW5 ZC5 Zp Pz

func main() FormBitmapSave(-1,".tfile.bmp",0) endfunc

FormBitmapSave(Image,FileName,Type) FormBitmapSave(Iexp,Sexp,Iexp) Description Saves the form graphics or a bitmap to a file. Image - The image number that you want to set. If set to -1 the form graphics will be saved as a bitmap. Note that this does not include Buttons, Labels or Textboxes. FileName - The name of the file to save the bitmap to. By using a "." in the first field of the name forces the file to be saved in the same dir as the application. Type - This the type of file to save. 0=Bitmap, 1=Gif, 2=Icon, 3=Jpeg, 4=Tiff, 5=Wmf *Bitmap is the only format available on the Pocket PC

FormBitmapSource()
FormBitmapSource(Image,Xpos,Ypos,Width,Height) FormBitmapSource(Iexp,Iexp,Iexp,Iexp,Iexp)

ZW5

ZC5 Zp Pz

Description Sets the source values for the bitmap draw. You can select any portion of the loaded bitmap to display. Image - The image number that you want to set. Xpos - The X position on the source image to use. Ypos - The Y position on the source image to use. Width - The width of the source image to use. Height - The height of the source image to use. Note that if the source and target Height and Width parameters are not the same the image will be stretched or shrunk automatically when displayed.

FormBitmapTarget()
FormBitmapTarget(Image,Xpos,Ypos,Width,Height) FormBitmapTarget(Iexp,Iexp,Iexp,Iexp,Iexp) Description Sets the target values for the bitmap draw.

ZW5

ZC5 Zp Pz

Image - The image number that you want to set. Xpos - The X position on the target image to use. Ypos - The Y position on the target image to use. Width - The width of the target image to use. Height - The height of the target image to use. Note that if the source and target Height and Width parameters are not the same the image will be stretched or shrunk automatically when displayed.

Zeus www.krmicros.com

Page 55

FormBrush
FormBrush()
FormBrush(Red,Green,Blue) FormBrush(lexp,Iexp,Iexp) Description Sets the Fill color for the FormFillRectangle and FormFillEllipse commands. Red - The color of the Red element. 0-255 Green - The color of the Green element. 0-255 Blue - The color of the Blue element. 0-255

Form Commands
ZW5 ZC5 Zl Zp Pz PzL
'Simple Progress Bar Demo func main() dim x,maxval maxval = 55 for x =0 to maxval ProgressBar(10,200,220,10,x,maxval) pause(5) next endfunc '-- simple progress bar -----------------' xpos,ypos sets location ' width,height sets size ' curval = current state of bar ' maxval is the maximum value '----------------------------------------func ProgressBar(x,y,width,height,curval,maxval) formbrush(0,255,0) formfillrectangle(x,y,float(curval* (width/maxval)),height) formrectangle(x,y,width,height) formupdate() endfunc

FormButton()

ZW5

ZC5

Zl Zp Pz PzL

FormButton(ID,XPos,YPos,Width,Height,Text) FormButton(Iexp,Iexp,Iexp,Iexp,Iexp,Sexp) Description Creates a working button on the Zeus form. ID - This is used to identify the button, Don't use large numbers for ID's at button is created for all unused ID's. For instance An ID of 10 will create 10 buttons. It is best to use consecutive numbers. They don't need to be created in order. Xpos - The X coordinate on the form for the upper left hand position of the control. YPos - The Y coordinate on the form for the upper left hand position of the control. Width - The width of the control in pixels. Height - The height of the control in pixels. The Height parameter has a couple options overrides. If the value is any of the following all other parameters will be ignored and the following will take place -1=Ignore parameter -10=Disable Button -11=Enable Button -20=Make Button Invisible -21=Make Button Visible -31=Force Focus Text - the text to appears in the control. If you place a chr(0) in this field the original text will not be altered by the command. Note that after the first to this control you can pass a -1 to the Xpos,Ypos,Width, and Height parameters and they will regain there original location. This way you can update only the text if you wish.

Page 56

Zeus www.krmicros.com

Form Commands

FormCreatePoly
FormButton()
FormButton(ID,ResetValue) FormButton(Iexp,Iexp) Integer Description The function version of this command allows you to poll the button. The function will return the number of times the button was pressed since the last call. You use this command by assigning it to a value or as a parameter. ID - The ID of the Button to poll. ResetValue - The value to place in the counter after this call completes.

ZW5

ZC5 Zp Pz PzL

FormAllButtons()
FormAllButtons() FormAllButtons() Integer Description

ZW5

ZC5 Zp Pz PzL

This is a specialized version of the FormButton command. It will return a 1 if any button has been hit and a 0 if none. It is particularly useful when processing many buttons. Its primary design was for use in FormBuilder

Note that if you are using FormBuilder you should not use this command as it is reserved for FormBuilder.

FormCreatePoly()

ZW5

ZC5 Zp Pz

FormCreatePoly(ID [,XPoint,YPoint,Xpoint,YPoint.....]) FormCreatePoly(Iexp [,Iexp,Iexp,Iexp,Iexp...]) Description Creates a multi-point polygon. The point pairs are optional. If you do not provide them you must use the FormAddPoint command to add points to the polygon.
func main() FormCLS() FormCreatePoly(0) FormAddPoint(0,10,10,20,10,20,20,10,20,10,10) FormPolyBrush(0,255,0,0) dim x as integer dim y as integer for y = 1 to 120 step 12 for x = 1 to 120 step 12 FormDrawFillPoly(0,x,y) FormDrawPoly(0,x,y) next next endfunc

ID - The ID Polygon. XPoint,YPoint - These are the point pairs. They are optional but must be provided in pairs.

Zeus www.krmicros.com

Page 57

FormCls
FormCls()
FormCls() FormCls() Description Clears the form to the current background color. Note that this command does not clear the FormLabels, FormTextBoxs or FormButtons. This command is often used to redraw the background after the FormBGColor has been used.

Form Commands
ZW5 ZC5 Zl Zp Pz PzL
func main() FormCLS() FormCreatePoly(0) FormAddPoint(0,10,10,20,10,20,20,10,20,10,10) FormPolyBrush(0,255,0,0) dim x as integer dim y as integer for y = 1 to 120 step 12 for x = 1 to 120 step 12 FormDrawFillPoly(0,x,y) FormDrawPoly(0,x,y) next next endfunc

FormCurMouseX()
FormMouseX() FormMouseX() Integer

ZW5

ZC5

Zl Zp Pz PzL
func main() console(5) Loop: if FormMouseDown()> 0 then print "Mouse Down" endif if FormMouseUp() > 0 then print "Mouse Up" endif if FormMouseMove() > 0 then print "Mouse Move", FormCurMouseX(), FormCurMouseY() endif Goto Loop endfunc

Description Returns the last X position of the current mouse over the form.

FormCurMouseY()
FormMouseY() FormMouseY() Integer

ZW5

ZC5

Zl Zp Pz PzL

Description Returns the last Y position of the current mouse over the form.

FormDrawBitmap()
FormDrawBitmap(Image, Xpos, Ypos) FormDrawBitmap(Iexp, Iexp, Iexp)

ZW5

ZC5

Zl Zp Pz

Description This command draws the bitmap image on the form. The image will display immediately unless the FormAutoUpdate has been turned off. In which case it will be drawn when the FormUpdate command is issued. Image - The image number that you want to draw Xpos - The X position to draw the image. Ypos - The Y position to draw the image.

func main() dim mflag,mx,my formloadbitmap(0,".ball4.bmp") formbitmapcolor(0,255,255,255) formdrawbitmap(0,10,10) endfunc

Page 58

Zeus www.krmicros.com

Form Commands

FormDrawText
FormDrawFillPoly()
FormDrawFillPoly(ID [, Xpos, Ypos]) FormDrawFillPoly(Iexp[ , Iexp, Iexp]) Description Draws a filled polygon. You must have added at least two points to the polygon with the FormAddPoint or the FormCreatePoly commands. The points are absolute unless you provide the Xpos and Ypos optional parameters. ID - The image number of the polygon to draw. Xpos,Ypos - The optional X and Y offset pos to draw the polygon.

ZW5

ZC5 Zp Pz

func main() FormCLS() FormCreatePoly(0) FormAddPoint(0,10,10,20,10,20,20,10,20,10,10) FormPolyBrush(0,255,0,0) dim x as integer dim y as integer for y = 1 to 120 step 12 for x = 1 to 120 step 12 FormDrawFillPoly(0,x,y) FormDrawPoly(0,x,y) next next endfunc

FormDrawPoly()
func main() FormCLS() FormCreatePoly(0) FormAddPoint(0,10,10,20,10,20,20,10,20,10,10) FormPolyBrush(0,255,0,0) dim x as integer dim y as integer for y = 1 to 120 step 12 for x = 1 to 120 step 12 FormDrawFillPoly(0,x,y) FormDrawPoly(0,x,y) next next endfunc

ZW5

ZC5 Zp Pz

FormDrawPoly(ID [, Xpos, Ypos]) FormDrawPoly(Iexp[ , Iexp, Iexp]) Description Draws a polygon. You must have added at least two points to the polygon with the FormAddPoint or the FormCreatePoly commands. The points are absolute unless you provide the Xpos and Ypos optional parameters. ID - The image number of the polygon to draw. Xpos,Ypos - The optional X and Y offset pos to draw the polygon.

FormDrawText()
FormDrawText(XPos,YPos,Text) FormDrawText(Iexp,Iexp,Sexp)

ZW5

ZC5

Zl Zp Pz PzL

Description Draws a string of text on the form using the current font. Unlike the FormPrint command this command does not clear the background behind the string. Xpos - The X coordinate on the form for the upper left hand position of the Text. YPos - The Y coordinate on the form for the upper left hand position of the Text. Text - The text to draw on the form.

Zeus www.krmicros.com

Page 59

FormEllipse
FormEllipse()
FormElilipse(Xpos,Ypos,Width,Height) FormElilipse(lexp,lexp,lexp,lexp) Description Draw an ellipse on the form in the current pen color. Xpos - The X coordinate on the form for the upper left hand position of the ellipse. YPos - The Y coordinate on the form for the upper left hand position of the ellipse. Width - The width of the ellipse in pixels. Height - The height of the ellipse in pixels.

Form Commands
ZW5 ZC5 Zl Zp Pz PzL

FormFillEllipse()
FormFillEllipse(Xpos,Ypos,Width,Height) FormFillEllipse(lexp,lexp,lexp,lexp)

ZW5

ZC5

Zl Zp Pz PzL

Description Draw a filled ellipse on the form in the current brush color. Xpos - The X coordinate on the form for the upper left hand position of the ellipse. YPos - The Y coordinate on the form for the upper left hand position of the ellipse. Width - The width of the ellipse in pixels. Height - The height of the ellipse in pixels.

FormFont()
FormFont(Font,Size,Style) FormFont(Sexp,Fexp,Iexp)

ZW5

ZC5

Zl Zp Pz PzL

Description Sets the text font used with the FormPrint, FormDrawText, FormLabel, FormTextBox and FormButton Commands. Font - The name of the font to use. Note that only "Tahoma" and "Courier New" are valid on the Pockt PC. If you supply a "-" the monospaced fornt Courier New will be used. Using "+" will use the variable pitch font Tahoma. You may also use the names of the fonts as future OS versions may offer other fonts. Size - This is the size in points for the font. 1.0 - 14 are supported. Style - Sets the type face to one of the following: 0 1 2 3 4 - Normal - Bold - Italic - Strikeout - Underline

Page 60

Zeus www.krmicros.com

Form Commands
ZW5 ZC5 Zl Zp Pz PzL

FormLabel()

FormLabel(ID,XPos,YPos,Width,Height,Text) FormLabel(Iexp,Iexp,Iexp,Iexp,Iexp,Sexp) Description Creates a label control on the Zeus form. ID - This is used to identify the button, Don't use large numbers for ID's at button is created for all unused ID's. For instance An ID of 10 will create 10 buttons. It is best to use consecutive numbers. They don't need to be created in order. Xpos - The X coordinate on the form for the upper left hand position of the control. YPos - The Y coordinate on the form for the upper left hand position of the control. Width - The width of the control in pixels. Height - The height of the control in pixels. The Height parameter has a couple options overrides. If the value is any of the following all other parameters will be ignored and the following will take place -1=Ignore parameter -3=Add text to end of current text -20=Make Label Invisible -21=Make Label Visible Text - the text to appears in the control. If you place a chr(0) in this field the original text will not be altered by the command. Note that after the first to this control you can pass a -1 to the Xpos,Ypos,Width, and Height parameters and they will regain there original location. This way you can update only the text if you wish.

FormLine()
FormLine(XStart,YStart,XEnd,YEnd) FormLine(lexp,lexp,lexp,lexp)

ZW5

ZC5

Zl Zp Pz PzL

Description Draws a line from the staring coordinates to the ending coordinates. XStart - The starting X coordinate. YStart - The starting Y coordinate. XEnd - The ending X coordinate. YEnd - The ending Y coordinat.

Zeus www.krmicros.com

Page 61

FormLoadBitmap
FormLoadBitmap()
FormLoadBitmap(Image,File) FormLoadBitmap(Iexp,Sexp) Description This command will load an image from the Zeus install directory. Image - The image number that you want to load. File - The File name to load. Files must be located in the Zeus install directory. Note that this command may be called within an expression with the syntax X=FormLoadBitMap(File) The command will return the next available image number that may be used with other commands.

Form Commands
ZW5 ZC5 Zl Zp Pz
func main() dim mflag,mx,my formloadbitmap(0,".ball4.bmp") formbitmapcolor(0,255,255,255) formdrawbitmap(0,10,10) endfunc

'Menu Example func main() dim stat as integer dim mitem as integer FormMenu(0,0,1,"Main Menu") FormMenu(1,0,1,"Item1") FormMenu(2,0,1,"Item2") FormMenu(3,0,1,"Item3") FormMenu(4,0,1,"Item4") FormMenu(5,0,1,"Item5") FormMenu(6,0,1,"Item6") FormMenu(7,0,1,"Item7") FormMenu(8,0,1,"Item8") FormMenu(9,0,1,"Item9") FormMenu(10,0,1,"Item10") FormMenu(11,0,1,"Item11") FormMenu(12,0,1,"Item12") FormMenu(13,0,1,"Item13") FormMenu(14,0,1,"Item14") FormMenu(15,0,1,"Item15") FormMenu(16,0,1,"Item16") FormMenu(17,0,1,"Item17") FormMenu(18,0,1,"Item18") FormMenu(19,0,1,"Item19") FormMenu(20,0,1,"Item20") Loop: mitem = FormMenu(0,0) if mitem > 0 then print "Menu Item "+mitem stat = FormMenu(mitem,0) 'Clear the status endif sleep(1) doevents() goto loop endfunc

FormMenu()
FormMenu(ID,Checked,Eanbled,Text) FormTextBox(Iexp,Iexp,Iexp,Sexp) Description Sets up a menu with up to 20 menu items.

ZW5

ZC5

Zl Zp Pz

ID - Identifies the menu items 1-20. If you use 0 it indicates the menu name. ID values of 21,22,23,24 lets you create New, Open, Save and Save As menu items under the File menu. An ID of 25 lets you override the File/Quit Menu. You can set the text and capture the close event of the form. Items 21-25 are only available on the Desktop. Checked - A value of 1 will place a check mark on the menu item. 0 will uncheck it. -1 will ignore it. Enabled - A value of 1 will enable the menu item or menu name. 0 will disable it and -1 will ignore it. Text - The is the text for the menu item or name. If it is an empty string then it will be ignored. Note an ID of 25 lets you overide the File/Quit Menu. You can set the text and capture the close event of the form.

FormMenu()
FormMenu( ID,ResetValue) FormMenu(Iexp,Iexp) Integer

ZW5

ZC5

Zl Zp Pz
func main() FormMenu(25,0,1,"Dude") Loop: if FormMenu(25,0) > 0 then msgbox("Quit the program") End endif goto Loop endfunc

Description This version of this command allows you to poll the menu item. The function will return the number of times the menu was pressed since the last call. It must be used to assign a number to a variable or as a parameter. ID - The ID of the menu to poll. 1-20 only. If ID 0 is used then all menus are checked and the number of the menu that was hit will be returned. ResetValue - The value to place in the counter after this call completes.

Page 62

Zeus www.krmicros.com

Form Commands
ZW5

FormMouseY
FormMouseDown()
FormMouseDown() FormMouseDown() Integer

ZC5

Zl Zp Pz PzL

func main() console(5) Loop: if FormMouseDown()> 0 then print "Mouse Down" endif if FormMouseUp() > 0 then print "Mouse Up" endif if FormMouseMove() > 0 then print "Mouse Move", FormCurMouseX(), FormCurMouseY() endif Goto Loop endfunc

Description Returns the number of times the mouse/stylus has clicked down on the form.

FormMouseMove()
FormMouseMove() FormMouseMove() Integer

ZW5

ZC5

Zl Zp Pz PzL

Description Returns the number of times the mouse/stylus has moved over the form. Note that on the Pocket PC the stylus must be down to cause a Move event.

FormMouseUp()
FormMouseUp() FormMouseUp() Integer

ZW5

ZC5

Zl Zp Pz PzL

Description Returns the number of times the mouse/stylus has returned from the down position on the form.

FormMouseX()
FormMouseX() FormMouseX() Integer

ZW5

ZC5

Zl

Zp Pz PzL

Description Returns the last X position of the mouse when a mouse down event was created.

FormMouseY()
FormMouseY() FormMouseY() Integer

ZW5

ZC5

Zl Zp Pz PzL

Description Returns the last Y position of the mouse when a mouse down event was created.

Zeus www.krmicros.com

Page 63

FormNew
FormNew()
FormNew() FormNew() Description Erases the Form and destroys all controls. Note that the bitmaps are not affected.

Form Commands
ZW5 ZC5 Zl Zp Pz PzL

FormPen()
FormPen(Red,Green,Blue) FormPen(lexp,Iexp,Iexp)

ZW5

ZC5

Zl Zp Pz PzL

Description Sets the draw color for the FormLine, FormRectangle and FormEllipse commands. Red - The color of the Red element. 0-255 Green - The color of the Green element. 0-255 Blue - The color of the Blue element. 0-255

FormPolyPen()
FormPolyPen(ID,Red,Green,Blue) FormPolyPen(Iexp,Iexp,Iexp,Iexp)

ZW5

ZC5 Zp Pz

Description Sets the Pen color for the FormDrawPoly and BitmapDrawPoly commands. You can change the pen color for each poly inidvidualy. ID - The Polygon to set Red - The color of the Red element. 0-255 Green - The color of the Green element. 0-255 Blue - The color of the Blue element. 0-255

FormPolyBrush()
FormPolyBrush(ID,Red,Green,Blue) FormPolyBrush(Iexp,Iexp,Iexp,Iexp)

ZW5

ZC5 Zp Pz
func main() FormCLS() FormCreatePoly(0) FormAddPoint(0,10,10,20,10,20,20,10,20,10,10) FormPolyBrush(0,255,0,0) dim x as integer dim y as integer for y = 1 to 120 step 12 for x = 1 to 120 step 12 FormDrawFillPoly(0,x,y) FormDrawPoly(0,x,y) next next endfunc

Description Sets the Pen color for the FormDrawFillPoly and BitmapDrawFillPoly commands. You can change the brush color for each poly individually. ID - The Polygon to set Red - The color of the Red element. 0-255 Green - The color of the Green element. 0-255 Blue - The color of the Blue element. 0-255

Page 64

Zeus www.krmicros.com

Form Commands
ZW5

FormPrint
FormPos()
FormPos(Xpos, Ypos) FormPos(Iexp, Iexp) Description This command allows you to set the position of the form on the window. Note that while it can be used on the Pocket PC it will not change the position on the current versions. Xpos - The X position on the desktop to draw the form. Ypos - The Y position on the desktop to draw the form.

ZC5 Zp Pz

FormPosition()
FormPosition(Xpos, Ypos) FormPosition(Iexp, Iexp)

ZW5

ZC5 Zp Pz

Description This command allows you to set the position of the form on the window. Note that while it can be used on the Pocket PC it will not change the position on the current versions. Xpos - The X position on the desktop to draw the form. Ypos - The Y position on the desktop to draw the form.

FormPrint()
FormPrint(XPos,YPos,Text) FormPrint(Iexp,Iexp,Sexp)

ZW5

ZC5

Zl Zp Pz PzL

Description Draws a string of text on the form using the current font. This command will clear the background behind the text to the current form background color. Xpos - The X coordinate on the form for the upper left hand position of the Text. YPos - The Y coordinate on the form for the upper left hand position of the Text. Text - The text to draw on the form.

Zeus www.krmicros.com

Page 65

FormRectangle
FormRectangle() ZW5 ZC5 Zl Zp Pz PzL

Form Commands

FormRectangle(Xpos,Ypos,Width,Height) FormRectangle(lexp,lexp,lexp,lexp) Description Draw a rectangle on the form in the current pen color. Xpos - The X coordinate on the form for the upper left hand position of the rectangle. YPos - The Y coordinate on the form for the upper left hand position of the rectangle. Width - The width of the rectangle in pixels. Height - The height of the rectangle in pixels.

'Simple Progress Bar Demo func main() dim x,maxval maxval = 55 for x =0 to maxval ProgressBar(10,200,220,10,x,maxval) pause(5) next endfunc '-- simple progress bar -----------------' xpos,ypos sets location ' width,height sets size ' curval = current state of bar ' maxval is the maximum value '----------------------------------------func ProgressBar(x,y,width,height,curval,maxval) formbrush(0,255,0) formfillrectangle(x,y,float(curval* (width/maxval)),height) formrectangle(x,y,width,height) formupdate() endfunc

FormFillRectangle()

ZW5

ZC5

Zl Zp Pz PzL

FormFillRectangle(Xpos,Ypos,Width,Height) FormFillRectangle(lexp,lexp,lexp,lexp) Description Draw a filled rectangle on the form in the current brush color. Xpos - The X coordinate on the form for the upper left hand position of the rectangle. YPos - The Y coordinate on the form for the upper left hand position of the rectangle. Width - The width of the rectangle in pixels. Height - The height of the rectangle in pixels.

FormRes()
FormRes(Width, Height) FormRes(Iexp, Iexp)

ZW5

ZC5

Zl Zp Pz

Description This command allows you to set the size of the window at runtime. Note that it only affects will vary on the Pocket PC depending on the OS and resolution. Width - The width of the form. Height - The height of the form.

FormResolution()
FormResolution(Width, Height) FormResolution(Iexp, Iexp)

ZW5

ZC5

Zl Zp Pz

Description This command allows you to set the size of the window at runtime. Note that it only affects will vary on the Pocket PC depending on the OS and resolution. Width - The width of the form. Height - The height of the form.

Page 66

Zeus www.krmicros.com

Form Commands
ZW5

FormSettings
FormSettings() ZC5 Zl Zp Pz PzL

FormSettings(setting1,setting2,setting3,....) FormSettings(Token,Token,Token,....) Description Sets various settings that will take effect on labels and textbox's. Valid Settings: MultiLineOn WordWrapOff AlignCenter ScrollVert
func main() FormSettings(WordWrapOn,MultiLineOn) FormTextBox(0,10,10,100,100,"") endfunc

MultiLineOff AlignLeft ScrollNone ScrollHoriz

WordWrapOn AlignRight ScrollBoth

FormTextBox()

ZW5

ZC5

Zl Zp Pz PzL

FormTextBox(ID,XPos,YPos,Width,Height,Text) FormTextBox(Iexp,Iexp,Iexp,Iexp,Iexp,Sexp) Description Creates a textbox control on the Zeus form. ID - This is used to identify the button, Don't use large numbers for ID's at button is created for all unused ID's. For instance An ID of 10 will create 10 buttons. It is best to use consecutive numbers. They don't need to be created in order. Xpos - The X coordinate on the form for the upper left hand position of the control. YPos - The Y coordinate on the form for the upper left hand position of the control. Width - The width of the control in pixels. Height - The height of the control in pixels. The Height parameter has a couple options overrides. If the value is any of the following all other parameters will be ignored and the following will take place -1=Ignore parameter -2=The selected text will be replaced with the text provided. -3=Add text to end of current text -10=Disable Text Box -11=Enable Text Box -20=Make Text Box Invisible -21=Make Text Box Visible -31=Focus the TextBox Text the text to appears in the control. If you place a chr(0) in this field the original text will not be altered by the command. Note that after the first to this control you can pass a -1 to the Xpos,Ypos,Width, and Height parameters and they will regain there original location. This way you can update only the text if you wish.

Zeus www.krmicros.com

Page 67

FormTextBox
FormTextBox()
FormTextBox(ID) FormTextBox(Iexp) String Description This version of the FormTextBox command will return the text contained in the form. This command must be used to assign a value to a variable or as a parameter in a expression. ID - The ID of the textbox to read.

Form Commands
ZW5 ZC5 Zl Zp Pz PzL

FormTextBoxSelection()
FormTextBoxSelection(ID) FormTextBoxSelection(Iexp) String

ZW5

ZC5

Zl Zp Pz PzL

Description The function returns the selected text from the form. ID - The ID of the textbox to read.

FormTextColor()
FormTextColor(Red,Green,Blue) FormTextColor(lexp,Iexp,Iexp)

ZW5

ZC5

Zl Zp Pz PzL

Description Sets the forecolor for the FormTextBox, FromLabel, FormButton, FormPrint and FormDrawText commands. Red - The color of the Red element. 0-255 Green - The color of the Green element. 0-255 Blue - The color of the Blue element. 0-255

FormUpdate()
FormUpdate() FormUpdate()

ZW5

ZC5

Zl Zp Pz
'Simple Progress Bar Demo func main() dim x,maxval maxval = 55 for x =0 to maxval ProgressBar(10,200,220,10,x,maxval) pause(5) next endfunc '-- simple progress bar -----------------' xpos,ypos sets location ' width,height sets size ' curval = current state of bar ' maxval is the maximum value '----------------------------------------func ProgressBar(x,y,width,height,curval,maxval) formbrush(0,255,0) formfillrectangle(x,y,float(curval* (width/maxval)),height) formrectangle(x,y,width,height) formupdate() endfunc

Description Forces the graphics to update or blit to the string. This is normally only used when you place the form in manual update mode.

Page 68

Zeus www.krmicros.com

Form Commands

FormUpdateAutoOn
FormUpdateAutoOff()
FormUpdateAutoOff() FormUpdateAutoOff() Description This command turns off the auto update feature and turns on blit buffer updates. To use blit buffering you issue this command once. The normal cycle of displaying data is to clear the buffer then issue all your graphic commands and then blit all the data to the screen using the FormUpdate command.

ZW5

ZC5

Zl Zp Pz

FormUpdateAutoOn()
FormUpdateAutoOn() FormUpdateAutoOn()

ZW5

ZC5

Zl Zp Pz

Description This command turns off the blit buffering and turns on auto draw.

FormTextHeight()
FormTextHeightText) FormTextHeight(sexp) integer

ZW5

ZC5 Zp Pz

Description Returns the height in pixels that the text will create in the current font style. Text the text to measure

FormTextWidth()
FormTextWidth(Text) FormTextWidth(sexp) integer

ZW5

ZC5 Zp Pz

Description Returns the width in pixels that the text will create in the current font style. Text the text to measure

Zeus www.krmicros.com

Page 69

BitmapDrawBitmap
BitMapDrawBitmap() ZW5 ZC5 Zp Pz

Advanced Form

BitMapDrawBitmap(Image, TargetImage, Xpos, Ypos) BitMapDrawBitmap(Iexp, Iexp, Iexp, Iexp) Description This command draws the bitmap image on to another bitmap. TargetImage - The image number that you want to target. Image - The image number that you want to draw Xpos - The X position to draw the image. Ypos - The Y position to draw the image.

BitMapDrawFillPoly()
BitMapDrawFillPoly(Image,ID [, Xpos, Ypos]) BitMapDrawFillPoly(Iexp,Iexp[ , Iexp, Iexp])

ZW5

ZC5 Zp Pz

Description Draws a filled polygon on a bitmap. You must have added at least two points to the polygon with the FormAddPoint or the FormCreatePoly commands. The points are absolute unless you provide the Xpos and Ypos optional parameters. Image - The image number that you want to target. ID - The image number of the polygon to draw. Xpos,Ypos - The optional X and Y offset pos to draw the polygon.

BitMapDrawPoly()
BitMapDrawPoly(Image,ID [, Xpos, Ypos]) BitMapDrawPoly(Iexp,Iexp[ , Iexp, Iexp])

ZW5

ZC5 Zp Pz

Description Draws a polygon on a bitmap. You must have added at least two points to the polygon with the FormAddPoint or the FormCreatePoly commands. The points are absolute unless you provide the Xpos and Ypos optional parameters. Image - The image number that you want to target. ID - The image number of the polygon to draw. Xpos,Ypos - The optional X and Y offset pos to draw the polygon.

Page 70

Zeus www.krmicros.com

Advanced Form

BitMapFillEllipse
BitMapDrawText()
BitMapDrawText(Image,XPos,YPos,Text) BitMapDrawText(Iexp,Iexp,Iexp,Sexp) Description Draws a string of text on the form using the current font to the target bitmap. This command does not clear the background behind the string. Image - The image number that you want to target. Xpos - The X coordinate on the form for the upper left hand position of the Text. YPos - The Y coordinate on the form for the upper left hand position of the Text. Text - The text to draw on the form.

ZW5

ZC5 Zp Pz

BitMapEllipse()
BitMapEllipse(Image, Xpos,Ypos,Width,Height) BitMapEllipse(Iexp, lexp,lexp,lexp,lexp)

ZW5

ZC5 Zp Pz

Description Draw an ellipse on to a bitmap in the current pen color. Image - The image number that you want to target. Xpos - The X coordinate on the form for the upper left hand position of the ellipse. YPos - The Y coordinate on the form for the upper left hand position of the ellipse. Width - The width of the ellipse in pixels. Height - The height of the ellipse in pixels.

BitMapFillEllipse()
BitMapFillEllipse(Image, Xpos,Ypos,Width, Height) BitMapFillEllipse(Iexp, lexp, lexp, lexp, lexp)

ZW5

ZC5 Zp Pz

Description Draw a filled ellipse on to a bitmap in the current brush color. Image - The image number that you want to target. Xpos - The X coordinate on the form for the upper left hand position of the ellipse. YPos - The Y coordinate on the form for the upper left hand position of the ellipse. Width - The width of the ellipse in pixels. Height - The height of the ellipse in pixels.

Zeus www.krmicros.com

Page 71

BitMapFillRectangle
BitMapFillRectangle() ZW5 ZC5 Zp Pz

Advanced Form

BitMapFillRectangle(Image, Xpos,Ypos,Width,Height) BitMapFillRectangle(Iexp, lexp,lexp,lexp,lexp) Description Draw a filled rectangle on to a bitmap in the current brush color. Image - The image number that you want to target. Xpos - The X coordinate on the form for the upper left hand position of the rectangle. YPos - The Y coordinate on the form for the upper left hand position of the rectangle. Width - The width of the rectangle in pixels. Height - The height of the rectangle in pixels.

BitMapLine()
BitMapLine(Image,XStart,YStart,XEnd,YEnd) BitMapLine(Iexp,lexp,lexp,lexp,lexp)

ZW5

ZC5 Zp Pz

Description Draws a line from the staring coordinates to the ending coordinates to the target bitmap. Image - The image number that you want to target. XStart - The starting X coordinate. YStart - The starting Y coordinate. XEnd - The ending X coordinate. YEnd - The ending Y coordinate.

BitMapRectangle()
BitMapRectangle(Image,Xpos,Ypos,Width,Height) BitMapRectangle(Iexp,lexp,lexp,lexp,lexp)

ZW5

ZC5 Zp Pz

Description Draw a rectangle on the target bitmap in the current pen color. Image - The image number that you want to target. Xpos - The X coordinate on the form for the upper left hand position of the rectangle. YPos - The Y coordinate on the form for the upper left hand position of the rectangle. Width - The width of the rectangle in pixels. Height - The height of the rectangle in pixels.

Page 72

Zeus www.krmicros.com

Advanced Form

FormFillBitmap
FormCreateBitmap()
FormCreateBitmap(Image,SizeX,SizeY) FormCreateBitmap(Iexp,exp,exp) Description This command will create a blank bitmap. Image - The image number that you want to load. SizeX - The width in pixels of the bitmap you want to create. SizeY - The height in pixels of the bitmap you want to create. Note that if you create a new bitmap with the same Image index the memory from the first will be freed up.

ZW5

ZC5 Zp Pz

FormCreateBitmap()
FormCreateBitmap(SizeX,SizeY) FormCreateBitmap(exp,exp) integer

ZW5

ZC5 Zp Pz

Description This command when used in a expression will create a blank bitmap. and return the number of the image created. SizeX - The width in pixels of the bitmap you want to create. SizeY - The height in pixels of the bitmap you want to create. Note that if you create a new bitmap with the same Image index the memory from the first will be freed up.

FormBitmapFill()
FormFillBitMap(Image,Red,Green,Blue) FormFillBitMap(Iexp,lexp,lexp,lexp) Description Fills a given bitmap with a color. Image - The bitmap image number to fill.. Red - The color of the Red element. 0-255 Green - The color of the Green element. 0-255 Blue - The color of the Blue element. 0-255

ZW5

ZC5 Zp Pz

Zeus www.krmicros.com

Page 73

GPSAltitude
GPSAltitude()
GPSAltitude() GPSAltitude() string Description Returns the decoded GPS altitude string in meters. To get feet multiply by 3.28084.

GPS Commands
ZW5 ZC5 ZC ZCLCE Zp Pz
print "Altitude : ",float(GPSAltitude() * 3.28084)+" Feet" print "Altitude : ",GPSAltitude() +" Meters"

GPSCalcDist()

ZW5

ZC5

ZC

ZCLCE Zp Pz

GPSCalcDist(LatDec1,LongDec1,LatDec2,LongDec2) GPSCalcDist(iexp,iexp,iexp,iexp) integer Description Returns the distance in feet between two GPS points. The latitude and longitude points are in whole decimal format as returned by the GPSLatitudeDec and GPSLongitudeDec commands.

LatDec1 - This is the latitude for point 1 in whole decimal format. LongDec1 - This is the longitude for point 1 in whole decimal format. LatDec2 - This is the latitude for point 2 in whole decimal format. LongDec2 - This is the longitude for point 2 in whole decimal format.

GPSCourse()
GPSCourse() GPSCourse() string

ZW5

ZC5

ZC

ZCLCE Zp Pz

print "Course : ",GPSCourse()

Description Returns the decoded GPS course string in degrees.

print GPSdate(),GPStime()

Page 74

Zeus www.krmicros.com

GPSCVTLongitudeDec
GPSCVTLatitudeDec() ZW5 ZC5 ZC ZCLCE Zp Pz

GPSCVTLatitudeDec(GPSString) GPSCVTLatitudeDec(strexp) integer Description Returns the decoded GPS latitude in decimal format in degrees * 100000. In other words it returns a whole number. This value can be used for plotting and the GPSCalcDist command. Used to convert collected GPS string data to a decimal value. A degree of latitude is 60 nautical miles. GPSString - String containing GPS Latitude information.

GPSCVTLongitudeDec()

ZW5

ZC5

ZC

ZCLCE Zp Pz

GPSCVTLongitudeDec(GPSString) GPSCVTLongitudeDec(strexp) integer Description Returns the decoded GPS longitude in decimal format in degrees * 100000. In other words it returns a whole number. This value can be used for plotting and the GPSCalcDist command. Used to convert collected GPS string data to a decimal value. GPSString - String containing GPS Longitude information.

Zeus www.krmicros.com

Page 75

GPSDate
GPSDate()
GPSDate() GPSDate() string Description Returns the decoded GPS Local date string

GPS Commands
ZW5 ZC5 Zp Pz

Page 76

Zeus www.krmicros.com

GPS Commands
ZW5

GPSLatitudeHem
GPSDone()
GPSDone() GPSDone() Integer Description Returns 1 if a the GPS data can be accessed after the last GPSLoad. If a 0 is returned this indicates that the new values have not been updated.

ZC5

ZC

ZCLCE Zp Pz

GPSLatitude()
GPSLatitude() GPSLatitude() string

ZW5

ZC5

ZC

ZCLCE Zp Pz

Description Returns the decoded GPS latitude string in the format ddmm.mmm where d is degrees and m is minutes. A degree of latitude is 60 nautical miles and a minute is equal to 1 nautical miles.

GPSLatitudeDec()
GPSLatitudeDec() GPSLatitudeDec() integer

ZW5

ZC5

ZC

ZCLCE Zp Pz

Description Returns the decoded GPS latitude in decimal format in degrees * 100000. In other words it returns a whole number. This value can be used for plotting and the GPSCalcDist command. A degree of latitude is 60 nautical miles.

GPSLatitudeHem()
GPSLatitudeHem() GPSLatitudeHem() string

ZW5

ZC5

ZC

ZCLCE Zp Pz

Description Returns the decoded GPS latitude hemisphere string. Will return a N or S.

Zeus www.krmicros.com

Page 77

GPSLoad
GPSLoad()
GPSLoad(sexp) GPSLoad(ComData) Description This command is used to load the GPS object with NEMA data received from a com port. ComData - The received GPS data string

GPS Commands
ZW5 ZC5 ZC ZCLCE Zp Pz

if ComBuff(Channel1) > 0 then GPSload ComInput(Channel1) print GPSdate(),GPStime() print "Longitude : ",GPSlongitude()+" "+GPSlongitudehem() endif

GPSLongitude()
GPSLongitude() GPSLongitude() string

ZW5

ZC5

ZC

ZCLCE Zp Pz

Description Returns the decoded GPS longitude string.

GPSLongitudeDec()
GPSLongitudeDec() GPSLongitudeDec() integer

ZW5

ZC5

ZC

ZCLCE Zp Pz

Description Returns the decoded GPS longitude in decimal format in degrees * 100000. In other words it returns a whole number. This value can be used for plotting and the GPSCalcDist command.

func main() dim y as integer const Channel1 1 ComOpen(Channel1,baud=38400,port=6)

GPSLongitudeHem()
GPSLongitudeHem() GPSLongitudeHem() string

ZW5

ZC5 Zp Pz ZC ZCLCE

Description Returns the decoded GPS longitude hemisphere string. Will return a E or W.

loop: if ComBuff(Channel1) > 0 then GPSload(ComInput(Channel1)) consolecls() print GPSdate(),GPStime() print print "Longitude : ",GPSlongitude()+" "+GPSlongitudehem() print "Latitude : ",GPSlatitude()+" "+GPSlatitudehem() print "Satellites : ",GPSSatellites() print "Altitude : ",GPSAltitude() print "Course : ",GPSCourse() print "Speed : ",GPSSpeed() endif goto loop endfunc

GPSSatellites()
GPSSatellites() GPSSatellites() string

ZW5

ZC5 Zp Pz ZC ZCLCE

Description Returns the decoded GPS satellites string. This is the number of satellites that have been acquired.

Page 78

Zeus www.krmicros.com

GPS Commands
ZW5 ZC5 ZC ZCLCE Zp Pz

GPSSpeed()
GPSSpeed() GPSSpeed() string
print "Speed : ",float(GPSSpeed() * 1.1508)+" mph"

Description Returns the decoded GPS speed string. This is in Knots. To convert to Mile per Hour multiply by 1.1508. To convert to Kilometers per Hour multiply by 1.852

GPSTime()
print GPSdate(),GPStime()

ZW5

ZC5 Zp Pz

GPSTime() GPSTime() string Description Returns the decoded GPS local time string

GPSUDate()
GPSUDate() GPSUDate() String

ZW5

ZC5

ZC

ZCLCE Zp Pz

Description Returns the decoded GPS date string in universal format of ddmmyy.

GPSUTime()
GPSUTime() GPSUTime() String

ZW5

ZC5

ZC

ZCLCE Zp Pz

Description Returns the decoded GPS time string in universal format of hhmmss. Note that hh is in 24 hour mode.

Zeus www.krmicros.com

Page 79

KRDBAddField
The KRDB database is a very simple and very fast database system built into Zeus. While it does not allow you to sort records it does provide you a very fast and easy way of storing and retrieving large amounts of data. The database is record based. You populate fields the write the record or retrieve a record and access its field data. The database has total random access so you my collect any record at any time.

KRDB Commands

KRDBAddField()
KRDBAddField(Channel,Type) KRDBAddField(number,token)

ZW5

ZC5

ZC

ZCLCE Zp Pz
func main() dim x as integer x=KRDBopen(1,".tdb",create) print x KRDBAddField(1,integer) KRDBAddField(1,string,25) KRDBAddField(1,integer) KRDBSetField(1,0,10) KRDBSetField(1,1,"Mike Simpson") KRDBSetField(1,2,11) KRDBAddRecord(1) KRDBSetField(1,0,20) KRDBSetField(1,1,"Fred Smith") KRDBSetField(1,2,21) KRDBAddRecord(1) KRDBReadRecord(1,1) print KRDBGetField(1,0) print KRDBGetField(1,1) KRDBReadRecord(1,2) print KRDBGetField(1,0) print KRDBGetField(1,1) print KRDBRecords(1) KRDBClose()

Description This command sets up the structure of the current database. You may setup the fields for a channel without opening the database. Use the KRDBResetFields if you want to set the fields again. Channel - The database channel to access. (1-5) This must be a number. Type - This tells the database what type of field to add. You may currently add a integer, single or string type. If you define a string type you must also let the database know the length as in KRDBAddField 1,sting,25 Note that you currently are limited to 40 fields per database.

KRDBAddRecord()
KRDBAddRecord(Channel) KRDBAddRecord(number)

ZW5

ZC5

ZC

ZCLCE Zp Pz

Description This command takes the current field data and adds a new record to the database. Channel - The database channel to access. (1-5) This must be a number.

endfunc

KRDBClose()
KRDBClose(Channel) KRDBClose(number)

ZW5

ZC5

ZC

ZCLCE Zp Pz

Description Closes an open KRDB file. If the file is already closed no action is taken. Channel - The database channel to access. (1-5) This must be a number.

Page 80

Zeus www.krmicros.com

KRDB Commands
ZW5

KRDBReadRecord
KRDBGetField() ZC5 ZC ZCLCE Zp Pz

KRDBGetField(Channel,Field) KRDBGetField(number,Iexp) Integer,Float,String Description Returns the field value for a retrieved record. You must use the KRDBReadRecord to retrieve the data before accessing the field data.
func main() dim x as integer x=KRDBopen(1,".tdb",create) print x KRDBAddField(1,integer) KRDBAddField(1,string,25) KRDBAddField(1,integer) KRDBSetField(1,0,10) KRDBSetField(1,1,"Mike Simpson") KRDBSetField(1,2,11) KRDBAddRecord(1) KRDBSetField(1,0,20) KRDBSetField(1,1,"Fred Smith") KRDBSetField(1,2,21) KRDBAddRecord(1) KRDBReadRecord(1,1) print KRDBGetField(1,0) print KRDBGetField(1,1) KRDBReadRecord(1,2) print KRDBGetField(1,0) print KRDBGetField(1,1) print KRDBRecords(1) KRDBClose() endfunc

Channel - The database channel to access. (1-5) This must be a number. Field - The Field number you want to access. The field numbers are zero based so 0 is the first field defined.

KRDBOpen()

ZW5

ZC5

ZC

ZCLCE Zp Pz

KRDBOpen(Channel,File,Mode) KRDBOpen(number,strexp,token) Integer Description Opens a KRDB file in various modes. Returns 1 if success and 0 if not. Channel - The database channel to access. (1-5) This must be a number. File - The file name to open. If you begin with a . then the current Zeus directory will be used for the file. Mode - The mode of operation. Open will open a file for read. Create will create a new file or overwrite an existing file. OpenorCreate open an existing file and create one if it does not already exist.

KRDBReadRecord()

ZW5

ZC5

ZC

ZCLCE Zp Pz

KRDBReadRecord(Channel,Record) KRDBReadRecord(number,Iexp) Description Reads a record from the database and populates the field data. You use the GetField function to access the data once the record has been read. Channel - The database channel to access. (1-5) This must be a number. Record - The number of the record to read. (1-N)

Zeus www.krmicros.com

Page 81

KRDBResetFields
KRDBResetFields
KRDBResetFields(Channel) KRDBResetFields(number) Description Resets all field data to nothing. If database is open it closes it. Channel - The database channel to access. (1-5) This must be a number.
func main()

KRDB Commands
ZW5 ZC5 ZC ZCLCE Zp Pz

dim x as integer x=KRDBopen(1,".tdb",create) print x KRDBAddField(1,integer) KRDBAddField(1,string,25) KRDBAddField(1,integer) KRDBSetField(1,0,10) KRDBSetField(1,1,"Mike Simpson") KRDBSetField(1,2,11) KRDBAddRecord(1) KRDBSetField(1,0,20) KRDBSetField(1,1,"Fred Smith") KRDBSetField(1,2,21) KRDBAddRecord(1) KRDBReadRecord(1,1) print KRDBGetField(1,0) print KRDBGetField(1,1) KRDBReadRecord(1,2) print KRDBGetField(1,0) print KRDBGetField(1,1) print KRDBRecords(1)

KRDBRecords()
KRDBRecords(Channel) KRDBREcords(number) Integer

ZW5

ZC5

ZC

ZCLCE Zp Pz

Description Returns the number of records in the current database. Channel - The database channel to access. (1-5) This must be a number.

KRDBSetField()

ZW5

ZC5

ZC

ZCLCE Zp Pz

KRDBSetField(Channel,Field,Data) KRDBSetField(number,Iexp,exp) Description Sets the current records field data. Note that you must use the KRDBWriteRecord once all the fields have set. Channel - The database channel to access. (1-5) This must be a number. Field - The Field number to update. (0-N) Data - The Data to write to the field. Note that the data is converted to the correct data type as defined with the AddField command.

KRDBClose() endfunc

Page 82

Zeus www.krmicros.com

KRDB Commands
ZW5 ZC5 ZC ZCLCE Zp Pz

KRDBWriteRecord()

KRDBWriteREcord(Channel,Record) KRDBWriteREcord(number,Iexp) Description Use this command to write field data to the database. Channel - The database channel to access. (1-5) This must be a number. Record - The Record number to update.

KRDBStringMode

ZW5

ZC5

ZC

ZCLCE Zp Pz

KRDBStringMode(Channel,Mode) KRDBStringMode(number,number) Description Sets the String Write Mode Channel - The database channel to access. (1-5) This must be a number. Mode - String Mode 1 = Normal Orignal Mode (Does not Support Unicode) 2 = New Mode The Original Mode did not support special characters. The new mode does. Please note that the the Zeus and CE consoles default to mode 2. All others default to mode 1. Please note that the modes are not compatible with one another. If you create a data base in a particular mode it must stay in that mode.

Zeus www.krmicros.com

Page 83

Abs
Abs()
Abs(value) Abs(exp) single/integer Description Returns the absolute value removing the sign if it exists. value - The mathematical expression to convert.

Math Commands
All
func main() dim x as integer x = Abs(-21) print x endfunc

Acos()
Acos(Value) Acos(exp) single/integer

All

Description Returns the angle whose cosine is the specified Value measured in radians. Multiply the return value by 180/p to convert from radians to degrees. value - A number representing a cosine.

Asin()
Asin(Value) Asin(exp) single/integer

All

Description Returns the angle whose sine is the specified value measured in radians. A positive return value represents a counterclockwise angle from the x-axis; a negative return value represents a clockwise angle. Multiply the return value by 180/p to convert from radians to degrees. value - A number representing a sine.

Atan()
Atan(Value) Atan(exp) single/integer

All

Description Returns the angle whose tangent is the specified value measured in radians. A positive return value represents a counterclockwise angle from the x-axis; a negative return value represents a clockwise angle. Multiply the return value by 180/p to convert from radians to degrees. value - A number representing a tangent .

Page 84

Zeus www.krmicros.com

Math Commands

Cos
Atan2()
Atan2(Y,X) Atan2(exp,exp) single/integer Description Returns the angle whose tangent is the quotient of two specified numbers An angle measured in radians. where (x, y) is a point in the Cartesian plane. Observe the following: For (x, y) For (x, y) For (x, y) For (x, y) in in in in quadrant 1 quadrant 2 quadrant 3 quadrant 4

All

The return value is the angle in the Cartesian plane formed by the x-axis, and a vector starting from the origin, (0,0), and terminating at the point, (x,y). Y - The y coordinate of a point. X - The x coordinate of a point.

Ceiling()
Ceiling(Value) Ceiling(exp) single/integer

All

Description Returns the smallest whole number greater than or equal to the specified number. The behavior of this method follows IEEE Standard 754, section 4. This kind of rounding is sometimes called rounding toward positive infinity. Value - A number

Cos()
Cos(Value) Cos(exp) single/integer Description Returns the cosine of the specified angle. Value - An angle, measured in radians.

All

Zeus www.krmicros.com

Page 85

Cosh
Cosh()
Cosh(Value) Cosh(exp) single/integer

Math Commands
Zl Zp

* Not Supported on Pocket PC Platform.

Description Returns the hyperbolic cosine of the specified angle. Value - An angle, measured in radians.

Dec()
Dec(variable) Dec(variable)

All

Description When used as a command (standalone) will decrement a supplied variable . Variable- Any type of variable may be supplied.

func main() dim X as integer dim Y as integer X=5 Dec(X)

Dec()
Dec(variable) Dec(variable) single/integer/string Description When used as a function will decrement a supplied variable and return its result so that it may be used in expressions. Variable- Any type of variable may be supplied.

All

print X Y = Dec(X) print Y,X endfunc

Exp()
Exp(Value) Exp(exp) single/integer Description Returns e raised to the specified power. Use the pow method to calculate powers of other bases. exp is the inverse of Log. Value - A number specifying a power.

All

Page 86

Zeus www.krmicros.com

Math Commands

Fix
Fix()
Fix(Value) Fix(exp) integer Description Converts a number to integer without rounding. Value - A number

All

Floor()
Floor(Value) Floor(exp) single/integer

All

func main() dim X as integer dim Y as integer X=5 Inc(X) print X Y =Inc(X) print Y,X endfunc

Description Returns the largest whole number less than or equal to the specified number. The behavior of this method follows IEEE Standard 754, section 4. This kind of rounding is sometimes called rounding toward negative infinity. Value - A number

Inc()
Inc(variable) Inc(variable)

All

Description When used as a command (standalone) will increment a supplied variable . Variable- Any type of variable may be supplied.

Inc()
Inc(variable) Inc(variable) single/integer/string Description When used as a function will increment a supplied variable and return its result so that it may be used in expressions. Variable- Any type of variable may be supplied.

All

Log()
Log(Value) Log(exp) single/integer Description Returns the logarithm of a specified number. Value - A number

All

Zeus www.krmicros.com

Page 87

Log10
Log10()
Log10(Value) Log10(exp) single/integer Description Returns the base 10 logarithm of a specified number. Value - A number whose logarithm is to be found.

Math Commands
All

Max()
Max(Value1,Value2) Max(exp,exp) single/integer Description Returns the larger of two specified numbers. Value1 - A number to check Value2 - A number to check

All

func main() print Max(10,20) endfunc

Min()
Min(Value1,Value2) Min(exp,exp) single/integer Description Returns the smaller of two specified numbers. Value1 - A number to check Value2 - A number to check

All

func main() print Min(10,20) endfunc

Pow()
Pow(X,Y) Pow(exp,exp) single/integer Description Returns a specified number raised to the specified power. X - A number to be raised to a power. Y - A number that specifies a power.

All

func main() print Pow(10,2) endfunc

Page 88

Zeus www.krmicros.com

Math Commands

Sinh
Random() All

func main() loop: print Random(-100,100) pause(100) goto loop endfunc

Random(Min,Max) Random(Iexp,Iexp) Integer Description Returns a random number between (including) the to numbers given. Min - The lower bounds of the number to return Max - The upper bounds of the number to return

Round()
func main() print Round(2.6) endfunc

All

Round(Value) Round(exp) single/integer Description Returns the number nearest the specified value. Value - A number

Sin()
Sin(Value) Sin(exp) single/integer Description Returns the sine of the specified angle. Value - An angle, measured in radians.

All

Sinh()
Sinh(Value) Sinh(exp) single/integer

Zl Zp

* Not Supported on Pocket PC Platform.

Description Returns the hyperbolic sine of the specified angle. Value - An angle, measured in radians.

Zeus www.krmicros.com

Page 89

Tan
Tan()
Tan(Value) Tan(exp) single/integer Description Returns the tangent of the specified angle. Value - An angle, measured in radians.

Math Commands
All

Tanh()
Tanh(Value) Tanh(exp) single/integer

Zl Zp

* Not Supported on Pocket PC Platform.

Description Returns the hyperbolic tangent of the specified angle. Value - An angle, measured in radians.

Sqrt()
Sqrt(Value) Sqrt(exp) single/integer Description Returns the square root of a specified number. Value - A Number

All

func main() print Sqrt(49) endfunc

Page 90

Zeus www.krmicros.com

Notes

Zeus www.krmicros.com

Page 91

ComBuff
ComBuff()
ComBuff(Channel) ComBuff(Iexp) Integer Description Returns the Number of bytes in the buffer. Channel - The com channel to read. (1-5)

Serial Commands
All
func main() dim x as integer dim tstr as string const Channel1 1 x=ComOpen(Channel1,baud=115200,port=1) print "Open Status = ";x 'Send byte values 0,1 2 x=ComOutput(Channel1,chr(0)+chr(1)+chr(2)) print "Output Status = ";x loop2: x = ComBuff(Channel1) if x > 0 then tstr = ComInput(Channel1) print tstr; endif goto loop2

ComClose()
ComClose(Channel) ComClose(Iexp)

All

endfunc

Description Closes a com channel and its associated port. Returns 0 of com port not open 1 if it is. This command may be standalone if you don't care about the result status. Channel - The com channel to close. (1-5)

ComCTS()
ComCTS(Channel) ComCTS(Iexp) Integer Description Returns the state of the CTS line of the port associated with this channel. Returns 0 or 1. Channel - The com channel to read. (1-5)

All
func main() ComOpen(1,baud=9600,port=1) print ComErrors(1) print ComStatus(1) print ComCTS(1) print ComDSR(1) ComClose(1) endfunc

ComDSR()
ComDSR(Channel) ComDSR(Iexp) Integer

All

Description Returns the state of the DSR line of the port associated with this channel. Returns 0 or 1. Channel - The com channel to read. (1-5)

Page 92

Zeus www.krmicros.com

Serial Commands

GetPacket
ComDTR()
ComDTR(Channel,State) ComDTR(Iexp,Iexp) integer or ComDTR(Channel,State) ComDTR(Iexp,Iexp) Description Sets the DTR line of the port associated with this channel. Returns 0 of com port not open 1 if it is. This command may be standalone if you don't care about the result status. Channel - The com channel to read. (1-5) State - The state to set. 0 Off and any thing else is high.

All

func main() ComOpen(1,baud=9600,port=1) ComBGSuspend(1,0) ComDTR(1,0) ComSettings(1,Timeout = 1,Priority = 100) print ComSendnWaitWord(1,"GetData",200) endfunc

ComGetByte()
func main() dim x as integer dim tstr as string const Channel1 1 x=ComOpen(Channel1,baud=115200,port=1) print "Open Status=";x loop: x = Comgetbyte(Channel1) if x = -1 then goto loop print x goto loop

All

ComGetByte(Channel) ComGetByte(Iexp) integer Description Gets a single byte from the internal buffer 0-255. If no byte is available it returns immediately with a value of -1. Channel - The com channel to read. (1-5)

endfunc

ComGetPacket()

All

ComGetPacket(Channel,NoDataLabel,TimeOutLabel,TimeOut,Index,Data1,..) ComGetPacket(Iexp,Label,Label,IntVarb,IntVarb,....) Description This command will check the comport and automatically populate data variables as data is received. The command will increment the index variable as a pointer to the data being populated. The index variable needs to be set to -1 the first time called. The command will automatically jump to the NoDataLabel if no data is received. If no data is received for the timeout value the command will jump to the TimeOutLable. When all data variable listed are populated the command will fall through to the next line. !! Important !! this command can not be called in an assignment or as a paramater. In other words it must be called as a stand alone command. Channel - The com channel to read. (1-5) NoDataLabel - The point to jump to if no data is available. TimeoutLabel - The point to jump to if no data is received for the timeout period.

func main() dim x1,x2,x3,x4,x5 dim cmdidx x1=ComOpen(1,baud=115200,port=1) print "Open Status=";x1 Again: cmdidx = -1 Loop: ComGetPacket(1,Loop,Timeout,500,cmdidx,x1,x2,x3,x4,x5) print "Fall Through ",x1,x2,x3,x4,x5 goto Again TimeOut: print "TimeOut" goto Again endfunc

Zeus www.krmicros.com

Page 93

ComGetVPacket
ComGetVPacket()
ComGetVPacket(Channel,NoDataLabel,TimeOutLabel,TimeOut,Index) ComGetVPacket(Iexp,Label,Label,IntVarb) Description This command will check the comport and automatically populate data variables as data is received. The command will increment the index variable as a pointer to the data being populated. The index variable needs to be set to -1 the first time called. The command will automatically jump to the NoDataLabel if no data is received. If no data is received for the timeout value the command will jump to the TimeOutLable. The first data value recieved will set the length of the packet. When all data bytes are recieved the command will fall through to the next line. !! Important !! this command can not be called in an assignment or as a paramater. In other words it must be called as a stand alone command. Channel - The com channel to read. (1-5) NoDataLabel - The point to jump to if no data is available. TimeoutLabel - The point to jump to if no data is received for the timeout period. Index - The command index variable.

Serial Commands
All
'ComGetVPacket Example func main() dim cmdidx,bytecount dim dats(15) as integer dim x as integer x=ComOpen(1,baud=115200,port=1) print "Open Status=";x Again: cmdidx = -1 Loop: ComGetVPacket(1,Loop,Timeout,500,cmdidx) print "Fall Through " print "Bytes=",bytecount for x = 0 to bytecount -1 print x,dats(x) next goto Again TimeOut: print "TimeOut" goto Again endfunc

Note that the Index passed is a variable. The bytecount variable as well as all the variables to be populated must be defined following the Index variable.

Page 94

Zeus www.krmicros.com

Serial Commands

ComGetIDPacket
ComGetIDPacket() All

'ComGetIDPacket Example func main() dim cmdidx,bytecount dim dats(15) as integer dim x as integer x=ComOpen(1,baud=115200,port=1) print "Open Status=";x Again: cmdidx = -1 Loop: ComGetIDPacket(1,Loop,Timeout,500,cmdidx) print "Fall Through " print "Bytes=",bytecount for x = 0 to bytecount -2 print x,dats(x) next goto Again TimeOut: print "TimeOut" goto Again endfunc

ComGetIDPacket(Channel,NoDataLabel,TimeOutLabel,TimeOut,Index,Target) ComGetIDPacket(Iexp,Label,Label,IntVarb,exp) Description This command will check the comport and automatically populate data variables as data is received. The command will increment the index variable as a pointer to the data being populated. The index variable needs to be set to -1 the first time called. The command will automatically jump to the NoDataLabel if no data is received. If no data is received for the timeout value the command will jump to the TimeOutLable. The first data value recieved will set the length of the packet. When all data bytes are recieved the command will fall through to the next line. Note that only if the 2nd byte in the packet matches that of the Target will the command fall through. !! Important !! this command can not be called in an assignment or as a paramater. In other words it must be called as a stand alone command. Channel - The com channel to read. (1-5) NoDataLabel - The point to jump to if no data is available. TimeoutLabel - The point to jump to if no data is received for the timeout period. Index - The command index variable. Target - The Target value (2nd byte in the packet)

Note that the Index passed is a variable. The bytecount variable,device as well as all the variables to be populated must be defined following the Index variable.

Zeus www.krmicros.com

Page 95

ComErrors
TimeOut - The number of milliseconds that will cause a timeout to occur if no data is received. Index - This a variable that will hold the index to the current variable in the list to be populated. Initially the variable should be set to -1. Data1-DataN - The variables to populate.

Serial Commands

ComErrors()
ComErrors(Channel) ComErrors(Iexp) Integer Description Returns the Error state of the current port associated with this channel. Bits Returned 0 - RX Overflow 1 - Break 2 - Framing 3 - RXOver 4 - RXParity 5 - TXFull Channel - The com channel to read. (1-5)

All
func main() ComOpen(1,baud=9600,port=1) print ComErrors(1) print ComStatus(1) print ComCTS(1) print ComDSR(1) endfunc

ComInput()
ComInput(Channel) ComInput(Iexp) String Description Removes and returns all the data in the receive buffer. Channel - The com channel to read. (1-5)

All
func main() dim x as integer dim tstr as string const Channel1 1 x=ComOpen(Channel1,baud=115200,port=1) print "Open Status = ";x 'Send byte values 0,1 2 x=ComOutput(Channel1,chr(0)+chr(1)+chr(2)) print "Output Status = ";x loop2: x = ComBuff(Channel1) if x > 0 then tstr = ComInput(Channel1) print tstr; endif goto loop2 endfunc

ComBreak()
ComBreak(Channel,Dur) ComBreak(Iexp,exp) Description Causes the UART to perform a break for up to 100 ms Channel - The com channel to break. (1-5) Duration - The length of the break. 1-100ms.

All

Page 96

Zeus www.krmicros.com

Serial Commands

ComOpen
ComOpen() All

func main() dim x as integer dim tstr as string const Channel1 1 x=ComOpen(Channel1,baud=115200,port=1) print "Open Status = ";x 'Send byte values 0,1 2 x=ComOutput(Channel1,chr(0)+chr(1)+chr(2)) print "Output Status = ";x loop2: x = ComBuff(Channel1) if x > 0 then tstr = ComInput(Channel1) print tstr; endif goto loop2 endfunc

ComOpen(Channel,configuration commands...) ComOpen(Iexp,cmd=xxx,cmd=xxx....) integer or ComOpen(Channel,configuration commands...) ComOpen(Iexp,cmd=xxx,cmd=xxx....) Description This command lets you set one of the 5 communications channels up. The channel is created as a background thread that will run outside the normal Zeus operation. You will use other commands to check on this channel as needed. Note that this command can be called with out assigning value to variable. This command can be issued in command or function mode. In function mode it will return a 1 if successful and a 0 if failure. Channel - The com channel to read. (1-5) Do not confuse the channel with the com port. The Zeus has 5 communications resources #1-#5 that can be used to set up a background task. Think of the channel number as the ID to this task. Commands - You can issue various commands when opening the channel. > baud=XXX - Where XXX is the baud rate. Valid Baud rates are 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 38400, 56000, 57600, 115200, 128000 and 256000 are valid baud rates > parity=XXX - Where XXX is the parity. Valid values are 0-None, 1-Odd, 2Even, 3-Mark, 4-Space > stop=XXX - Where XXX = the number of stop bits. 1 - 1 stop bits 1.5 - 1.5 stop bits 2 - 2 stop bits > bits=XXX - Where XXX is the number of data bits. 5-8 are valid. > Port=XXX - Where XXX is the Pocket PC comport to use. 1 is the default if not supplied. Note that you need not supply all the commands. The defaults are in bold face if not supplied.

Zeus www.krmicros.com

Page 97

ComOutput
ComOutput()
ComOutput(Channel,Text) ComOutput(Iexp,Sexp) integer or ComOutput(Channel,Text) ComOutput(Iexp,Sexp) Description This command sends a string to the com port associated with this channel. This data is placed in the transmit buffer and the command is returned immediately. If the Transmit buffer is full an error (Bit 5) is set. Returns 0 of com port not open 1 if it is. This command may be standalone if you don't care about the result status. Channel - The com channel to read. (1-5) Text - The data to be transmitted.

Serial Commands
All

func main() dim x as integer dim tstr as string const Channel1 1 x=ComOpen(Channel1,baud=115200,port=1) print "Open Status = ";x 'Send byte values 0,1 2 x=ComOutput(Channel1,chr(0)+chr(1)+chr(2)) print "Output Status = ";x loop2: x = ComBuff(Channel1) if x > 0 then tstr = ComInput(Channel1) print tstr; endif goto loop2 endfunc

ComPurge()
ComPurge(Channel) ComPurge(Iexp) integer or ComPurge(Channel) ComPurge(Iexp)

All
func main() ComOpen(1,baud=9600,port=1) ComBGSuspend(1,0) ComDTR(1,0) ComSettings(1,Timeout = 1,Priority = 100) ComPurge(1) ComOutput(1,"GetData") print ComWaitForByte(1,500) endfunc

Description Clears the transmit and receive buffers. Returns 0 of com port not open 1 if it is. This command may be standalone if you don't care about the result status. Channel - The com channel to read. (1-5)

Page 98

Zeus www.krmicros.com

Serial Commands

ComSendnWaitWord
ComRTS() All

func main() ComOpen(1,baud=9600,port=1) ComBGSuspend(1,0) ComRTS(1,0) ComSettings(1,Timeout = 1,Priority = 100) print ComSendnWaitWord(1,"GetData",200) endfunc

ComRTS(Channel,State) ComRTS(Iexp,Iexp) integer or ComRTS(Channel,State) ComRTS(Iexp,Iexp)

Description Sets the RTS line of the port associated with this channel. Channel - The com channel to read. (1-5) State - The state to set. 0 Off and any thing else is high.

ComSendnWaitByte()
ComSendnWaitByte(Channel,Data,TimeOut) ComSendnWaitByte(Sexp,Iexp,Iexp) integer
func main() ComOpen(1,baud=9600,port=1) ComBGSuspend(1,0) ComRTS(1,0) ComSettings(1,Timeout = 1,Priority = 100) print ComSendnWaitByte(1,"GetData",200) endfunc

All

Description Sends a string of data then returns 1 byte from the internal buffer. Will wait for the indicated time. Will return -1 if error or timeout. Data - The string of data to send. Channel - The com channel to read. (1-5) TimeOut - The amount of time (in milliseconds) to wait for the data.

ComSendnWaitWord()
ComSendnWaitWord(Channel,Data,TimeOut) ComSendnWaitWord(Sexp,Iexp,Iexp) integer
func main() ComOpen(1,baud=9600,port=1) ComBGSuspend(1,0) ComRTS(1,0) ComSettings(1,Timeout = 1,Priority = 100) print ComSendnWaitWord(1,"GetData",200) endfunc

All

Description Sends a string of data then returns 1 word (2 bytes) from the internal buffer. Will wait for the indicated time. Will return -1 if error or timeout. Data - The string of data to send. Channel - The com channel to read. (1-5) TimeOut - The amount of time (in milliseconds) to wait for the data.

Zeus www.krmicros.com

Page 99

ComSettings
ComSettings()
ComSettings(Channel,configuration command) ComSettings(Iexp,cmd=xxx,....) Description Sets various configuration commands for the channel. Returns 0 of com port not open 1 if it is. This command may be standalone if you don't care about the result status. Channel - The com channel to read. (1-5) Do not confuse the channel with the com port. The Zeus has 5 communications resources #1-#5 that can be used to set up a background task. Think of the channel number as the ID to this task. Commands - You can issue various commands when setting the channel. > rxbuffer=XXX - Where XXX is the number of bytes to assign.. You may assign any amount of bytes to this buffer but keep in mind the larger the buffer the more time is needed to process the data. The default is 5000 bytes. > txbuffer=XXX - Where XXX is the number of bytes to assign.. You may assign any amount of bytes to this buffer but keep in mind the larger the buffer the more time is needed to process the data. The default is 5000 bytes. > priority=XXX - Where XXX = the milliseconds this com channels thread will allot to other processes. The default is 5. For instance a value of 1000 will force this com channel to give way for 1 second to all other system processes. The priority only applies to background processing of the ComGetByte, ComBuff and ComInput commands. > timeout=XXX - Where XXX is the number milliseconds the receive port will wait for incoming data before timing out. The minimum value is 1 ms. The default is 10 ms. Note that you need not supply all the commands. The defaults are in bold face if not supplied.

Serial Commands
All

func main() ComOpen(1,baud=9600,port=1) ComBGSuspend(1,0) ComDTR(1,0) ComSettings(1,Timeout = 1,Priority = 100) ComPurge(1) ComOutput(1,"GetData") print ComWaitForByte(1,500) endfunc

Page 100

Zeus www.krmicros.com

Serial Commands

ComBGSuspend
ComStatus() All

func main() ComOpen(1,baud=9600,port=1) print ComErrors(1) print ComStatus(1) print ComCTS(1) print ComDSR(1) endfunc

ComStatus(Channel) ComStatus(Iexp) Integer Description Returns the com status bits of the port associated with the given channel. Bits Returned 4 - CTS On 5 - DSR On 6 - Ring On 7 - RLSD On Channel - The com channel to read. (1-5)

ComBGSuspend()
func main() ComOpen(1,baud=9600,port=1) ComBGSuspend(1,0) ComDTR(1,0) ComSettings(1,Timeout = 1,Priority = 100) ComPurge(1) ComOutput(1,"GetData") print ComWaitForByte(1,500) endfunc

All

ComSuspend(Channel,State) ComSuspend(Iexp,Iexp) integer or ComSuspend(Channel,State) ComSuspend(Iexp,Iexp) Description Stops auto buffering. The Data is held in place for the ComWaitxxx commands. Returns 0 of com port not open 1 if it is. This command may be standalone if you don't care about the result status. Set ComBGSuspend(X,1) when using: ComGetByte ComBuff ComInput ComGetPacket Set ComBGSuspend(X,0) when using: ComWaitForWord ComWaitForByte ComSendnWaitWord ComSendnWaitByte

Channel - The com channel to read. (1-5) State - 0 = No background processing 1 Turns on processing. This is the default.

Zeus www.krmicros.com

Page 101

ComWaitForByte
ComWaitForByte()
ComWaitForByte(Channel,TimeOut) ComWaitForByte(Iexp,Iexp) integer Description Returns 1 byte from the internal buffer. Will wait for the indicated time. Will return -1 if error or timeout. Channel - The com channel to read. (1-5) TimeOut - The amount of time (in milliseconds) to wait for the data.

Serial Commands
All
func main() ComOpen(1,baud=9600,port=1) ComBGSuspend(1,0) ComDTR(1,0) ComSettings(1,Timeout = 1,Priority = 100) ComPurge(1) ComOutput(1,"GetData") print ComWaitForByte(1,500) print ComWaitForWord1,500) endfunc

ComWaitForWord()
ComWaitForWord(Channel,TimeOut) ComWaitForWord(Iexp,Iexp) integer

All

Description Returns 1 word (2 Bytes) from the internal buffer. Will wait for the indicated time. Will return -1 if error or timeout. Channel - The com channel to read. (1-5) TimeOut - The amount of time (in milliseconds) to wait for the data.

Page 102

Zeus www.krmicros.com

Notes

Zeus www.krmicros.com

Page 103

SocketBuffer
Socket programming is a very complex and error prone activity. With Zeus we have abstracted it to a point that makes it a bit more manageable. While every attempt has been made to catch every error there may be situations that we may have missed or errors or problems that we can not catch. Zeus Sockets are basic TCP/IP sockets and are connection based. Normally one side of the connection acts as the client and the other acts as the server. Once the connection is made they communicate with one another in the same manor. The server will use the SocketListen command and the client will use the SocketConnect command. Again once the connections is complete they will communicate using the SocketOutput and SocketInput commands. Zeus sockets use a state system to indicate the current state the socket is in. Use the SocketState command to retrieve a number representing the current state. Zeus also provides a command called SocketError to indicate the last error detected. There are several examples in the Examples directory showing the various client and server type connections.

Socket Commands
func main() dim indata as string print "This computers name "+SocketData(0,12) print "This computers address "+SocketData(0,11) ReStart: print "*** Listen ***" '-- Setup to listen for a connection SocketListen(1,9000,-1,-1) '-- Wait For Connection here -Loop: print SocketState(1)+" / "+SocketData(1,6)+" / " _ +SocketData(1,5)+" / "+SocketData(1,8) if SocketState(1) = 4 then print "Connected" goto Connected endif if SocketState(1) = 0 then goto Restart endif pause(80) Sleep(100) Goto Loop 'Have Connection here. Now we echo every thing out Connected: if SocketBuff(1) > 0 then indata= SocketInput(1) print indata SocketOutput(1,indata) endif sleep(5) print SocketData(1,6)+" / "+SocketData(1,5)+" / " _ +SocketData(1,8) if SocketState(1) = 0 then SocketClose(1) goto Restart endif goto Connected

SocketBuffer()
SocketBuffer(Socket) SocketBuffer(exp) integer

ZW5

ZC5 Zp Pz

Description Returns a number of bytes in the receive buffer. You should follow-up with a SocketInput command to retrieve the buffer contents Socket - The Socket number. Not to be confused with port number.

endfunc

SocketConnect()
SocketConnect(Socket,Address,Port) SocketConnect(exp,sexp,exp) Description Connect socket to a remote server.

ZW5

ZC5 Zp Pz
func main() ConsoleCLS() print "Start up" dim stat as integer SocketConnect(1,"127.0.0.1",8000,5000)

Socket - The Socket number. Not to be confused with port number. By default sockets 0-10 are defend but by using larger numbers they will be allocated as needed. Address - This is the name or IP number of the server you wish to connect to. Note that using "127.0.0.1" will connect to a port on the current machine. This is good for connecting applications together. Port - This is the port to connect to.

Loop: stat = SocketState(1,1) print stat if stat > 1 then goto cont goto Loop Cont: print "Waiting for Data" SocketOutput(1,"Hello World") tt: if SocketState(1,2)> 0 then print SocketState(1,3); endif if SocketState(1,1) = 0 then print "Connection Closed" end endif goto tt

endfunc

Page 104

Zeus www.krmicros.com

Socket Commands

SocketData
SocketClearError() ZW5 ZC5 Zp Pz

'Sends a request to the KRMicros Web site func main() TryAgain: '-- Make the Connection -SocketConnect(1,"www.krmicros.com",80) '-- Wait For Connection here -WaitLoop: if SocketState(1) = 4 then print "Connected" print "Send Request" SocketOutput(1,"GET http://krmicros.com/index.htm"_ +chr(13)+chr(10)) goto Connected else print "Waiting.... "+SocketData(1,6)+" / "_ +SocketData(1,5) endif pause(100) Goto WaitLoop '-- Recieve Loop -Connected: if SocketBuff(1) > 0 then print SocketInput(1); endif if SocketState(1) = 0 then if SocketBuff(1) > 0 then print SocketInput(1); endif print print "All Done" SocketClose(1) End endif goto Connected endfunc

SocketClearError(Socket) SocketClearError(exp) Description Clears the last error Socket - The Socket number. Not to be confused with port number. By default sockets 0-10 are defend but by using larger numbers they will be allocated as needed.

SocketClose()
SocketClose(Socket) SocketClose(exp) Description Closes an open socket.

ZW5

ZC5 Zp Pz

Socket - The Socket number. Not to be confused with port number. By default sockets 0-10 are defend but by using larger numbers they will be allocated as needed.

SocketData()
SocketData(Socket,Field) SocketData(exp,exp) string

ZW5

ZC5 Zp Pz

Description Returns a string filled with Socket data. Note that if the socket has not been defined it will return "" Socket - The Socket number. Not to be confused with port number. Field - This is the data element to return. Fields 1 - InputBuffer (The same as SocketBuffer command) 2 - Resolved address when available 3 - State Command number 4 - Name as provided 5 - Last Error String 6 - Current State String 7 - RecieveThreadStat 8 - ListenThreadStat 9 - ConnectThreadStat 10 - Remote address of connected socket 11 - Local address 12 - Local name

Zeus www.krmicros.com

Page 105

SocketError
SocketError()
SocketError(Socket) SocketError(exp) integer Description Returns a number representing the last error. Note that you can retrieve an actual error string by issuing the SocketData(x,5) command. Socket - The Socket number. Not to be confused with port number. Errors 0 - "No Error" 1 - "Unable to Resolve Address" 2 - "Unable to Connect" 3 - "End Point Error" 4 - "No Sockets Available" 5 - "Socket Send Error" 6 - "Unable to Listen" 7 - "Other Error" Errors are cleared when starting a new connection or listen operation. You may also clear an error by issuing the SocketClearError command.

Socket Commands
ZW5 ZC5 Zp Pz

SocketInput()
SocketInput(Socket) SocketInput(exp) string Description Returns to contents of the receive buffer.

ZW5

ZC5 Zp Pz

Socket - The Socket number. Not to be confused with port number.

Page 106

Zeus www.krmicros.com

Socket Commands
ZW5 ZC5 Zp Pz

SocketListen()
func main() dim indata as string print "This computers name "+SocketData(0,12) print "This computers address "+SocketData(0,11) ReStart: print "*** Listen ***" '-- Setup to listen for a connection SocketListen(1,9000,-1,-1) '-- Wait For Connection here -Loop: print SocketState(1)+" / "+SocketData(1,6)+" / " _ +SocketData(1,5)+" / "+SocketData(1,8) if SocketState(1) = 4 then print "Connected" goto Connected endif if SocketState(1) = 0 then goto Restart endif pause(80) Sleep(100) Goto Loop 'Have Connection here. Now we echo every thing out Connected: if SocketBuff(1) > 0 then indata= SocketInput(1) print indata SocketOutput(1,indata) endif sleep(5) print SocketData(1,6)+" / "+SocketData(1,5)+" / " _ +SocketData(1,8) if SocketState(1) = 0 then SocketClose(1) goto Restart endif goto Connected

SocketListen Socket,Port,StartRange,EndRange SocketListen exp,exp,exp,exp Description Starts a socket and places it into listen mode. In listen mode the the socket is placed into server mode and it will wait for a client to connect to the port. Once a client connects it will transition into normal receive/transmit mode. Socket - The Socket number. Not to be confused with port number. By default sockets 0-10 are defend but by using larger numbers they will be allocated as needed. Port - This is the port to listen on. Start Range/End Range - Normally you will provide a -1 for these settings. However by providing a range of socket numbers they will automatically be assigned as connections are made. The Listen port will remain in listen mode looking for more connections.

SocketOutput()
SocketOutput(Socket,Data) SocketOutput(exp,exp) Description Sends a string of characters out the socket.

ZW5

ZC5 Zp Pz

Socket - The Socket number. Not to be confused with port number. By default sockets 0-10 are defend but by using larger numbers they will be allocated as needed. Data - The data to send out the socket.

endfunc

Zeus www.krmicros.com

Page 107

Socket Commands
ZW5 ZC5 Zp Pz

SocketState()
SocketState(Socket) SocketState(exp) integer

Description Returns a number representing the current state of the socket. Note that you can retrieve an actual state string by issuing the SocketData(x,6) command. Socket - The Socket number. Not to be confused with port number. States 0 - "Socket Idle" 1 - "Socket Started, Command Pending" 2 - "Address Resolved" 3 - "Socket Created, Connection Pending" 4 - "Connection Made, Receive State Pending" 5 - "Server State, Accept Connection Pending" 6 - "Unknown State"

func main() ConsoleCLS() print "Start up" dim stat as integer SocketConnect(1,"127.0.0.1",8000,5000)

Loop: stat = SocketState(1,1) print stat if stat > 1 then goto cont goto Loop Cont: print "Waiting for Data" SocketOutput(1,"Hello World") tt: if SocketState(1,2)> 0 then print SocketState(1,3); endif if SocketState(1,1) = 0 then print "Connection Closed" end endif goto tt

SocketQuickCheck()
SocketQuickCheck(Start) SocketQuickCheck(exp) integer

ZW5

ZC5 Zp Pz

Description This command will check all open sockets and will return the first socket number that has any input data pending. If no data is pending on any sockets then a -1 is returned. This command is a quick way to check multiple sockets for activity. Start - The Socket number to start checking.

endfunc

Page 108

Zeus www.krmicros.com

Notes

Zeus www.krmicros.com

Page 109

BeginsWith
BeginsWith()
BeginsWith(SourceString,SearchString) BeginsWith(Sexp,Sexp) integer Description Returns a 1 if a search item is found in a string. If it is not found the function returns a 0. SourceString - The string expression to search. SearchString - The string to look for at the beginning of the string.

String Commands
All
if BeginsWith("Name=Mike","Name") = 1 then print "Starts With Name" else print "Unknown" endif

Convert()
Convert(Number,Format) BeginsWith(exp,Sexp) string

ZW5

ZC5

Zl Zp Pz PzL

Description Does a windows conversion. Normally used to convert decimal to hexadecimal. Number - The number or expression to convert. Format - The windows conversion format. Valid Formats X=Convert to uppercase Hex digits x=Convert to lowercase Hex digits X2=Force to 2 Hex digits X4=Force to 4 Hex digits

if EndsWith("Mike is Good","Good") = 1 then print "He is good" else print "He is not good" endif

print format(10.123456,"0.000") print format(7,"000") Displays: 10.123 007

EndsWith()
EndsWith(SourceString,SearchString) EndsWith(Sexp,Sexp) integer

All

Description Returns a 1 if a search item is found in a string. If it is not found the function returns a 0. StringString - The string expression to search. SearchString - The string to look for at the end of the string.

Page 110

Zeus www.krmicros.com

String Commands
ZW5 ZC5

Format
Format()
Format(Value,Format) Format(exp,Sexp) string Description Returns a string formatted according to instructions contained in a format String expression. Value - Expression to be formatted Format 0 Digit placeholder. Displays a digit or a zero. If the expression has a digit in the position where the zero appears in the format string, display it; otherwise, displays a zero in that position. If the number has fewer digits than there are zeros (on either side of the decimal) in the format expression, displays leading or trailing zeros. If the number has more digits to the right of the decimal separator than there are zeros to the right of the decimal separator in the format expression, rounds the number to as many decimal places as there are zeros. If the number has more digits to the left of the decimal separator than there are zeros to the left of the decimal separator in the format expression, displays the extra digits without modification.

Zl Zp Pz PzL

# Digit placeholder. Displays a digit or nothing. If the expression has a digit in the position where the # character appears in the format string, displays it; otherwise, displays nothing in that position. This symbol works like the 0 digit placeholder, except that leading and trailing zeros aren't displayed if the number has fewer digits than there are # characters on either side of the decimal separator in the format expression. . Decimal placeholder. The decimal placeholder determines how many digits are displayed to the left and right of the decimal separator. If the format expression contains only # characters to the left of this symbol; numbers smaller than 1 begin with a decimal separator. To display a leading zero displayed with fractional numbers, use zero as the first digit placeholder to the left of the decimal separator. In some locales, a comma is used as the decimal separator. The actual character used as a decimal placeholder in the formatted output depends on the number format recognized by your system. Thus, You should use the period as the decimal placeholder in your formats even if you are in a locale that uses a comma as a decimal placeholder. The formatted string will appear in the format correct for the locale.

% Percent placeholder. Multiplies the expression by 100. The percent

Zeus www.krmicros.com

Page 111

Format Cont
character (%) is inserted in the position where it appears in the format string. , Thousand separator. The thousand separator separates thousands from hundreds within a number that has four or more places to the left of the decimal separator. Standard use of the thousand separator is specified if the format contains a thousand separator surrounded by digit placeholders (0 or #). A thousand separator immediately to the left of the decimal separator (whether or not a decimal is specified) or as the rightmost character in the string means "scale the number by dividing it by 1,000, rounding as needed." For example, you can use the format string "##0,." to represent 100 million as 100,000. Numbers smaller than 1,000 but greater or equal to 500 are displayed as 1, and numbers smaller than 500 are displayed as 0. Two adjacent thousand separators in this position scale by a factor of 1 million, and an additional factor of 1,000 for each additional separator. Multiple separators in any position other than immediately to the left of the decimal separator or the rightmost position in the string are treated simply as specifying the use of a thousand separator. In some locales, a period is used as a thousand separator. The actual character used as the thousand separator in the formatted output depends on the Number Format recognized by your system. Thus, You should use the comma as the thousand separator in your formats even if you are in a locale that uses a period as a thousand separator. The formatted string will appear in the format correct for the locale.

String Commands

\ Displays the next character in the format string. To display a character that has special meaning as a literal character, precede it with a backslash (\). The backslash itself isn't displayed. Using a backslash is the same as enclosing the next character in double quotation marks. To display a backslash, use two backslashes (\\). Examples of characters that can't be displayed as literal characters are the date-formatting and time-formatting characters (a, c, d, h, m, n, p, q, s, t, w, y, /, and :), the numeric-formatting characters (#, 0, %, E, e, comma, and period), and the string-formatting characters (@, &, <, >, and !).

-+$() Literal characters. These characters are displayed exactly as typed in the format string. To display a character other than one of those listed, precede it with a backslash (\) or enclose it in double quotation marks (" "). : time separator. The time separator separates hours, minutes, and seconds when time values are formatted. The actual character used as the time separator in formatted output is determined by your system settings. / Date separator. In some locales, other characters may be used to represent the date separator. The date separator separates the day, month, and year when date values are formatted. The actual character used as the date

Page 112

Zeus www.krmicros.com

String Commands

Format Cont
separator in formatted output is determined by your system settings. e- e+ E- E+ Scientific format. If the format expression contains at least one digit placeholder (0 or #) to the left of E-, E+, e-, or e+, the number is displayed in scientific format and E or e is inserted between the number and its exponent. The number of digit placeholders to the left determines the number of digits in the exponent. Use E- or e- to place a minus sign next to negative exponents. Use E+ or e+ to place a minus sign next to negative exponents and a plus sign next to positive exponents. You must also include digit placeholders to the right of this symbol to get correct formatting.

Zeus www.krmicros.com

Page 113

String Commands
Notes

Page 114

Zeus www.krmicros.com

String Commands
All

GetWord()
dim word as string dim text as string text = "Now is the Time" word = GetWord(text,1,3," ") Print word

GetWord(SourceStr,StartPos,Word,Tokens [,Status]) GetWord(Sexp,Iexp,Iexp,Sexp ,[Intvarb]) string Description Separates a string into words by a list of tokens. The Nth word is returned as indicated. SourceStr - String expression being searched. StartPos - Numeric expression that sets the starting position for each search. If omitted, search begins at the first character position. The start index is 1 based. If this value is less than 1 then the search will start at the last place the command left off. Word - Word number you are looking for. Tokens - A string of characters that represent separators. Status - A optional integer variable that will contain the last position of the search or a -1 if end of string was reached.

ICaps()
Print ICaps("mike")

All

ICaps(SourceString) ICaps(Sexp) string Description Returns a version of the string with the first character capitalized. Note that all other characters are not affected.. SourceString - The string to convert.

Insert()
Print Insert("Now is the time",8,"not ")

ZW5

ZC5

ZC

ZCLCE Zp Pz

Insert(SourceString,InsertPos,InsertString) Insert(Sexp,Iexp,Sexp) string Description Lets you insert a string into another at a particular point. Returns the new string. SourceString - The target string that you want to insert into. InsertPos - The point where you want to insert the string. A value of 1 will insert the string at the front of the target string. InsertString - This is the string to insert.

Displays: Now is not the time

Zeus www.krmicros.com

Page 115

Instr
Instr()
Instr(SourceString,StartPos,SearchString) Instr(Sexp,Iexp,Sexp) integer Description Returns an integer specifying the start position of the first occurrence of one string within another.

String Commands
All

dim ivarb as integer dim svarb as string svarb = "My name is mike" ivarb = instr(svarb,1,"mike") print ivarb Displays:

SourceString - String expression being searched. StartPos - Numeric expression that sets the starting position for each search. If omitted, search begins at the first character position. The start index is 1 based. SearchString - String expression sought.

12

Left()
Left(SourceString,Chars) Left(Sexp,Iexp) string

All

dim svarb as string svarb = "My name is mike" print left(svarb,2) Displays: My

Description Returns a string containing a specified number of characters from the left side of a string. SourceString - Source string expression Chars - Number of characters to copy.

Lower()
Lower(SourceString) Lower(Sexp) string

ZW5

ZC5

ZC

ZCLCE Zp Pz

Print Lower("I Need You")

Description Returns a lower case version of the string. SourceString - The string to convert to lowercase.

Displays: i need you

Len()
len(SourceString) len(Sexp) integer Description Returns an integer containing either the number of characters in a string. SourceString - Source string expression

All
dim ivarb as integer dim svarb as string dim fvarb as single svarb = "My name is mike" fvarb = len(svarb) print fvarb print len("Hello") Displays: 15 5

Page 116

Zeus www.krmicros.com

String Commands
ZW5 ZC5 Zp Pz

Overlay()
Print Overlay("You are a Frog",11,0,"Monkey")

Overlay(SourceString,OverlayPos,Length,InsertString) Overlay(Sexp,Iexp,Iexp,Sexp) string Description Lets you overlay one string on top of another string starting at a particular position. Returns the new string.

Displays: You are a Monk

SourceString - The target string that you want to overlay into. OverlayPos - The point where you want to overlay the string. A value o will start the overlay at the beginning of the string. Length - The maximum number of characters to insert. Note that the target will never grow in length so the insert will always stop at the end o the target. OverlayString - This is the string to overlay.

Mid()
dim svarb as string svarb = "My name is mike" print "Your ";mid(svarb,4,12) Displays: Your name is mike

All

Mid(SourceStr,StartPos,Chars) Mid(Sexp,Iexp,Iexp) string

Description Returns a string containing a specified number of characters starting from a specified position. SourceStr - Source string expression StartPos - Position to start copying. (1-x) Chars - Number of characters to copy.

ParseValue()
dim svarb as string dim res as string svarb = "Name=Mike" res = ParseValue(svarb,1,"Name="," ") print res

ZW5

ZC5 Zp Pz

ParseValue(SourceString,StartIndex,Key,Tokens) ParseValue(Sexp,Iexp,Sexp,Sexp) string

Displays: Mike

Description This command will search a string for a key then pull the value following tha key. If the StartIndex is negative it will do a conversion on the result. All + w be converted to spaces and hex values preceded with % will be converted t the appropriate value. This feature is useful in converting POST parm data its normalized value.

SourceString - The string to search and parse. StartIndex - The starting point to start looking for the key. This is 1 base Key - The Key or name field to look for. Tokens - A list of characters that separate the fields.

Zeus www.krmicros.com

Page 117

Replace
Replace()
Replace(SourceString,SearchString,ReplaceString [,StartPos,Count]) Replace(Sexp,Sexp,Sexp[,Iexp,Iexp]) string Description Returns a string in which a specified substring has been replaced with another substring. SourceString - Source string expression SearchString - String to find in SourceString ReplaceString - The string to replace the SearchString. This can be an empty string. StartPos - Sets the starting point to do the replace. This parm is optional. If omitted the start point will be the first character. Count - The number of replacements. This parm is optional. If omitted the count is unlimited.

String Commands
All
Print Replace("Now is the Time"," ","-",6,1)

Displays: Now is-the Time

Right()
Right(SourceString,Chars) Right(Sexp,Iexp) string

All

dim svarb as string svarb = "My name is mike" print Right(svarb,4) Displays: mike

Description Returns a string containing a specified number of characters from the right side of a string. SourceString - Source string expression Chars - Number of characters to copy.

Trim()
Trim(SourceString,Characters) Trim(Sexp,Sexp) string

ZW5

ZC5

ZC

ZCLCE Zp Pz
Print Trim("...Mike...",".")

Description Returns a string where all characters passed are removed from the front and end of a string. SourceString - The string to trim. Characters - The string of characters to remove from the beginning and end.

Displays: Mike

Page 118

Zeus www.krmicros.com

Upper
TrimEnd()
Print Trim("...Mike...",".")

Zp Pz

TrimEnd(SourceString,Characters) TrimEnd(Sexp,Sexp) string


Displays: ...Mike

Description Returns a string where all characters passed are removed from the end of a string. SourceString - The string to trim. Characters - The string of characters to remove from the end.

TrimStart()
Print TrimStart("...Mike...",".")

ZW5

ZC5

ZC

ZCLCE Zp Pz

Displays: Mike...

TrimStart(SourceString,Characters) TrimStart(Sexp,Sexp) string Description Returns a string where all characters passed are removed from the start of a string. SourceString - The string to trim. Characters - The string of characters to remove from the start.

Upper()
Print Upper("Name")

ZW5

ZC5

ZC

ZCLCE Zp Pz

Upper(SourceString) Upper(Sexp) string Description Returns a upper case version of the string. SourceString - The string to convert to uppercase.

Displays: NAME

Zeus www.krmicros.com

Page 119

Wild
Wild()
Wild(SourceString,StartPos,Pattern) Wild(Sexp,Iexp,Sexp) integer Description Returns an integer indicating the location of the found pattern. This is the first non * match character. If the pattern is not found the command will return a 1. SourceString - The string to search StartPos - The location to start looking. This is 1 based. Pattern - The pattern to look for. The following wild cards are supported in the pattern string: supports: the '?' and '.' matches any single character the '*' matches zero or more characters 'a' matches any alpha character. 'n' matches any digit. "[aeiouAEIOU]" matches any single character that is a vowel "[^aeiouAEIOU]" matches any non-vowel "[0-9]" matches any digit "[a-z0-9]" matches any lower case or digit the '\' allows a search for '?', '*' , 'a' , '.' , 'n' or '['

String Commands
Zp Pz

func main() dim stat as integer stat = Wild("Now is the Time",1,"Now*Time") print stat endfunc Returns 12 the position of the T in Time

Page 120

Zeus www.krmicros.com

Zeus Extensions

ColorBox
Zeus Extensions
These are special commands that extend the Zeus language. They are only available in the ZeusPro compiler once the ZPE option has been activated.

AppInfo()
AppInfo(Application,Mode) AppInfo(Sexp,Iexp) string
func main() print AppInfo("Zeus",2) endfunc

Zp

* This command only supported on desktop applications Description Returns information about a running application. Application - The name of the running application. Mode - Indicates the information you are requesting 1=Current applications name 2=Number of instances of application running 3=Title of Application 4=Start Time 5=Processor Time 6=User Time

Args()
func main() dim x as integer x=fuzzy(-1,90, 10,20, 30,40, 50,60, 70,80, 90,100) print x endfunc

Args(Argnum) Args(Iexp) string

Description Returns a passed argument used to start the application. Argnum - The number of the argumant to return.

ColorBox()
func main() dim tstr as string tstr = ColorBox(100,100,100) print tstr endfunc

Zp

ColorBox(red,green,blue) ColorBox(Iexp,Iexp,Ixep) string * This command only supported on desktop applications Description Opens a color box selection form for the user to select a color. Returns a string containing the 3 selected color elements. Zeus www.krmicros.com

Page 121

FileLoadResource
FileLoadResource()
FileLoadResource(Resource,File) FileLoadResource(Sexp,Sexp) string Description Returns a string representing the contents of a file located inside a Windows resource. Resources are a great way of packing several design elements into a single file. Resource - The path of the resource file File - The name of the file inside of the resource

Zeus Extensions
ZW5 ZC5 Zp Pz
func main() print FileLoadResource("ResourceTest","TextFile1.txt") print print print print FileLoadResource("ResourceTest","HTMLPage1.htm") endfunc

FormLoadBitmapResource()
FormLoadBitmapResource(Image,Resource,BitMap) FormLoadBitmapResource(Iexp,Sexp,Sexp) string

ZW5

ZC5

Zp Pz
func main() formloadbitmapResource(0,"ResourceTest","tank1.bmp") formdrawbitmap(0,0,0) endfunc

Description This command will load a bitmap located inside of a resource file. Resources are a great way of packing several design elements into a single file. Image - The image number you want to load into. Resource - The path of the resource file Bitmap - The name of the bitmap inside of the resource

Instructions()
Instructions(InstructionData) instructions(Sexp)

ZW5

ZC5

Zp Pz
func main() instructions("Hello") loop: sleep(0) doevents() goto loop endfunc

Description This command will popup a form containing simple instructions for your application. InstructionData - A string containing the instructions.

Page 122

Zeus www.krmicros.com

Zeus Extensions
ZW5 ZC5 Zp Pz

func main() PlaySoundResource("ResourceTest","exp1.wav") endfunc

FormLoadBitmapResource()
PlaySoundResource(Resource,File) PlaySoundResource(Sexp,Sexp)

Description This command will load a sound file located inside a resource and play it. Resources are a great way of packing several design elements into a single file.

Resource - The path of the resource file File - The name of the sound file inside of the resource

Fuzzy()

ZW5

ZC5

ZC

ZCLCE Zp Pz

Fuzzy(FailValue,SearchValue,Pair0L,Pair0H,Pair1L,Pair1H) Fuzzy(exp,exp,exp,exp,exp) integer Description Search a list of values then return an index to that value. This function is zero based and will return FailValue if it can not find the SearchValue. The lookup values are retrieved in pairs. If the Search value falls on or between thenHigh and Low value then that index will be returned. FailValue - The value to return if the Search value is not located in any of the Values given. SearchValue - The Value used to search for. (Pair0L,Pair0H)-(PairNL,PairNH) - The high and low lookup values to be tested.

! Available on all target platforms with ZPE option

Zeus www.krmicros.com

Page 123

Zeus Extensions

Page 124

Zeus www.krmicros.com

Zeus Turorial

Section 2 Zeus Tutorial

Zeus Language Tutorial Table of Contents Getting Started


Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . .127 Function Definition . . . . . . . . . . . . . . . . . . . . . . .128 Print . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .128 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .128 Calling a Function . . . . . . . . . . . . . . . . . . . . . . . .129 Program Flow . . . . . . . . . . . . . . . . . . . . . . . . . . .130 Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .130 Spaghetti Code . . . . . . . . . . . . . . . . . . . . . . . . . .131 Gosub . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .131 Return . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .131 Integer Variables . . . . . . . . . . . . . . . . . . . . . . . . .132 Dim statement . . . . . . . . . . . . . . . . . . . . . . . . . . .132 Variable Scope . . . . . . . . . . . . . . . . . . . . . . . . . .132 Global Variables . . . . . . . . . . . . . . . . . . . . . . . . .133 Floating Point Variables . . . . . . . . . . . . . . . . . . .134 Printing Floating Point Numbers . . . . . . . . . . . . .134 Floating Point Conversion . . . . . . . . . . . . . . . . . .135 Integer Math . . . . . . . . . . . . . . . . . . . . . . . . . . . .136 Floating Point Math . . . . . . . . . . . . . . . . . . . . . . .138 Floating Point Truncation . . . . . . . . . . . . . . . . . .138 Signed Numbers . . . . . . . . . . . . . . . . . . . . . . . . .138 for / next . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .139 if / then / else . . . . . . . . . . . . . . . . . . . . . . . . . . .141 Using multiple and/or statements . . . . . . . . . . . .142

The Next Step


Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . .143 Passing Values to Functions . . . . . . . . . . . . . . . .144 Returning a value from a function. . . . . . . . . . . .145 Parameter Conversion . . . . . . . . . . . . . . . . . . . .146 Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .147 Array Restrictions . . . . . . . . . . . . . . . . . . . . . . . .148 Double Dimension Arrays . . . . . . . . . . . . . . . . . .148 Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .149 String Direct Access . . . . . . . . . . . . . . . . . . . . . .149 Partial String Assignment . . . . . . . . . . . . . . . . . .150 Print Command and Strings . . . . . . . . . . . . . . . .150

Other
Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .151 Complex Macros . . . . . . . . . . . . . . . . . . . . . . . . .152 Debugger / Simulator (Desktop) . . . . . . . . . . . . .153 Variable Watch Form (Desktop) . . . . . . . . . . . . .154 Debugger / Simulator (PocketPC) . . . . . . . . . . . .157 Variable Watch Form (Pocket PC) . . . . . . . . . . .158

What is Zeus
What is Zeus? Zeus is a very simple development system that will allow you to create Desktop,Laptop or Pocket PC programs. The applications may contain Buttons,Textboxes,Labels and other graphics. If graphics are not needed you can also use the built-in console or a combination of both. If you are looking at creating a high speed game keep in mind that is may not run with sufficient speed on the Pocket PC. Zeus employs a double buffering scheme for graphics so there is no flicker as graphic items are updated. Zeus was designed as an inexpensive and easy way to create interface programs to various devices. In the engineering field it can be used in conjunction with various Chips and interfaces to remote control or data aquisition. In the Robotics field it can be used with various microcontrollers and other control chips to control robotic operation. The turnaround speed for a typical Interfaces is 1ms. What does this mean. If you need to make decicions for you robot within microseconds this needs to be done off line. So if you are building a balance bot the actual balance interface needs to be done with a high speed microcontroller like the Dios. You use Zeus to controls such aspects as the human interface or higher order functions like robot location or problem solving. Why Pocket Zeus? We created Pocket Zeus so that you could edit and compile programs on the pocket PC. The down side is that larger programs can take a considerable amount of time to compile. This is why we recommend that you do a large amount of your development on the desktop. However this said its very nice that you can pull out your pocket PC and work on that interface formula. For instance I totally worked out the math needed to compute sonar ping times to actual distances all on the pocket PC while in the waiting room of my doctors office.

Zeus Executables When you create a Zeus executable with ZeusPro or PocketZeus it will be placed in the directory where the source is located. The name of this executable will be based on the name of the source file. You may change this name to any thing you wish just make sure you keep the .exe extension. The name that appears on the form will be based on the name. Once you create a Zeus Executable you no longer need ZeusPro or PocketZeus. It is important to understand the ZeusPro. PocketZeus and any programs they create require .Net framework V1.1 or later on the desktop and .Net compact framework V1.0 SP3 on the Pocket PC.

Page 126

Zeus www.krmicros.com

1: Getting Started
Introduction
This chapter will provide the basic knowledge needed to start programming with Zeus. It is assumed you know how to start the Zeus software. We will cover creating and calling functions, variable declaration and program loops. The examples provided are small enough that it recommended that you hand code each one to help you grasp the concepts discussed. To try a program type it as shown in the edit form and hit the run button on your Zeus compiler. As an option you may also use the debugger and single step through the code line by line. See Chapter 4 on using the debugger.

Zeus www.krmicros.com

Page 127

2: Getting Started
Function Definition
The Zeus language is made up of a series of instructions stored in program areas. These program areas are self-contained and execute their instructions from beginning to end. These program areas are called functions, each identified by a unique name. Example 2.1 shows the simplest function in the world. We use the func command to start a function and the endfunc command to end it. In this case we have created a function called main. A list of arguments can be inserted following the name of the function. This list Note that the Zeus language is case insensitive. You may type the names of your functions or other identifies in any case you wish.

Example 2.1
func main()
The function name is always followed by parentheses.

Note that the entry point into your code is the first function. It does not matter what the name is that will be the first function loaded and run.

endfunc

Later we will pass arguments to the function inside these parenthesis.

must be enclosed in parentheses. In the example we dont have any arguments.

Print
In order to get our function to do a little more lets look at the print command. The print command will allow us to send information to the Zeus Console. In

Example 2.2
func main() print Hello World endfunc order to send text to the Console we must enclose the text in quotes.
This example prints Hello World in the Console window.

When the Zeus software detects a print command, the Console terminal will automatically come to the front.

Comments
There are many times you will want to place comments and remarks in your

Example 2.3
func main() This is a comment endfunc This is a comment as well
You can also place comments at the end of an instruction.

The print command is the most powerful command in the Zeus language. It can print any variable type and even funtion output. You can change the format of output on the fly.

Page 128

Zeus www.krmicros.com

2: Getting Started
Calling a Function
In Example 2.2 we created a function that had a single function with a single print command. Lets expand on that a bit. In Example 2.4 we added a second function. However when the program is run it only prints Hello World. It never gets to main2. Why?

Example 2.4
Root Function func main() print Hello World endfunc 2nd Function func main2() print Hello Again endfunc

Hey! This example does the same as the last one. Whats up?

When the end of the root function is reached Zeus will no longer execute any of your commands.

When the Zeus program is started the first defined function is the function that is executed. This first functon becomes the root function. When the end of the root function is reached Zeus stops execution. In order to to run another function we must tell the program to run that function specifically. We do this by calling the function. We call a function by using its name. In Example 2.5, when the main2() function is encountered in the root function the Dios jumps to that function and starts executing. When the end of main2() is reached Zeus exits main2() and continues where it left off in the root program.

Example 2.5
Root Function func main() print Hello World main2() print Im Back endfunc
Maybe this will help

func main()
... ... main2() ... ... endfunc

func main2()
... ... ... endfunc

2nd Function func main2() print Next Function endfunc

You jump to another program area by using its name. When it is finished you continue where you left off.

Zeus www.krmicros.com

Page 129

2: Getting Started
Program Flow
Normally the program flows from top to bottom executing commands as they are encountered. We call this program flow. One way to change the program flow is by calling a function as we saw in Example 2.5. Another way to change the program flow is using the goto command. In order to use the goto command you must be able to tell the program where to go. We do this with a label. All names created must adhere to certain rules. This applies to function and label names They must begin with a letter. They may not contain spaces. They may contain only letters and numbers. They are case insensitive.

Labels
A label is a place holder for a location in your program code. Labels are only valid within a function. To declare a label just use a name followed by a colon. The name is alphanumeric and must begin with a letter. The names are case insensitive, so the label loop: is ths same as label Loop:.

Example 2.6
func main() loop: print Hello World goto loop endfunc Zeus allows the following:
This is the program that never ends. The endfunc command is never reached. Remember labels are just place holders. They represent a location in your code.

Functions: No Limit Macros: No Limit Labels: No Limit Local int variables: 1,000,000 Local float variables: 1,000,000 String Variables: 1,000,000 Global Variables: No Limit

Example 2.6 shows simple loop to demonstrate both the goto and label commands. The program will print the words Hello World over and over again in the console window. It will do this forever. You cannot goto a label in another function. from one function to another. In other words, you cant jump

Gosubs: No Limit Nested Gosubs: 25 For loops: No Limit Nested For loops: 50 If Commands: No Limit Nested If statements: 50 Include File: 50 Note that available memory and performance will determine the actual number of resources that can be realistically used.

Example 2.7
func main() goto loop endfunc Func testfunc() loop: print Where am I endfunc

Page 130

Zeus www.krmicros.com

2: Getting Started
Spaghetti Code
Lets look at a common programming error. Example 2.8 shows what we call spaghetti code. It jumps all over the place and is hard to follow. Unfortunately the use of extensive goto commands can lead to some pretty bad spaghetti code.

Example 2.8
func main() goto step1 Step2: print In step 2 goto done Step1: print In step 1 goto step2 Done: endfunc
Im so confused!!!

Gosub
One way to eliminate spaghetti code is to creat small subroutines within your functions. You can do this with the gosub command. The gosub command works identical to the goto command with one exception. When a gosub command is executed it saves its location so that the program may return where it left off.

Return
The return command is used to tell the program to return back to where the gosub command was issued. Its kind of like calling a function but with the gosub and return you stay inside the current function.

Example 2.9
Maybe this will help ... ... ... gosub sayhello ... ... ...

sayhello:
... ... ... return

func main() loop: gosub sayhello goto loop sayhello: print Hello return endfunc

When the gosub is reached we jump to the sayhello label. When we reach the return we go back to the point just after the gosub command.

Zeus www.krmicros.com

Page 131

2: Getting Started
Integer Variables
If all you could do was jump from place to place in the code you would not get much done. We want to be able to manipulate some data. Data space is different than program space and is normally accessed by using variables. Zeus has three types of variables but we will concentrate on the simplest, the integer variable.

Dim statement
To declare (create) an integer variable, use the dim statement as shown in Example 2.14. By default any variable created this way is an integer.

Example 2.14
func main() dim age endfunc
You can specifically tell the compiler to define an integer by using the statement: dim age as integer

To put a variable to work we need to store information in that variable and retrieve information from it. One way to store information in a variable is to use the assignment operator. The value on the right side is stored in the variable on the left side. In Example 2.15 the variable age will contain the value of 25.

Example 1.15
func main() dim age age = 25 print age endfunc
The = operator can be used to assign a value to a variable.

The print statement is very versatile. It can print all types of variables directly.

Variable Scope
Variables that are defined in a function are only valid until the function exits. This is called scope. Once the function that created the variable exits the variable space is freed up. This makes for very efficient use of variable space. In Example 1.16 each age variable is valid only within the function it was created (dim command). Had we not used the dim command in testfunc we would have received an error. This is because the age variable in the main function does not exist in the testfunc function.

Page 132

Zeus www.krmicros.com

2: Getting Started
Example 2.16
When a variable is defined in a function it is important to know that any value assigned will not remain intact when the function exits. The only function where the variables will remain in tact is the root function, since it will never exit unless the program ends. This is also true of calling functions. If a function contains a variable and calls another function its own variables will remain intact until it exits. func main() dim age age = 25 testfunc() print main age ,age endfunc

These two age variables are different and have nothing to do with one another

func testfunc() dim age age = 32 print testfunc age ,age endfunc

Global Variables
The variables that are defined inside functions are considered local. You can also define variables that can be shared with all functions. These variables are called global variables. All functions can access these variables. You use the global statement to declare (create) global variables. Local variables can only be created inside functions and global variables can be created anywhere in the program.

Zeus integer variables can store a value range of -2,147,483,648 to 2,147,483,647. They cannot contain decimal points.

Example 2.17
func main() global age age = 25 print age testfunc() print age endfunc func testfunc() age = 44 endfunc

Once a variable is created with the global statement we can access it from all functions. Global variables never go away.

Zeus www.krmicros.com

Page 133

2: Getting Started
Floating Point Variables
You learned about integer variables. Now its time to get your hands a little dirty and learn about the floating point variables. In many cases you will use them just as you would the integer variables. The Zeus uses 32-bit IEEE 754 floating point. What does floating point mean? In vary basic terms it means we have a number and the decimal point can be calculated to reside at various places in that whole number. If this sounds a bit confusing dont worry. Unless you want to manipulate the individual bits of the 4 bytes that make up the number, you wont have to concern yourself with the behind the scene details. You will have to keep a few things in mind. Like Visual Basic or other high level languages 32-bit floating point is considered single precision. You will get 6 to 7 significant digits of accuracy. The more digits on the left side of the decimal place the less digits on the right side of the decimal point. Also when using decimal points you will notice rounding errors as the digits get close to the outer range. How do we define a floating point number? You define a floating point variable with the dim statement just like you did with integer variables. There is no shortcut to define floating point variables. You must always use the as single option.

Example 2.18
func main() dim mynumber as single global myglobnumber as single endfunc
This is how a floating point variable is defined. The first dim statement is a local variable. The second global statement is a global variable.

Printing Floating Point Numbers


The print command will automaticly detect the use of floating point and display appropriatly. Example 2.19 will start counting 70000 and increment by 10.

In Example 2.19 the print command displayed a number until it was out of range for the particular display format. To change the display format you can use the format operators.

Page 134

Zeus www.krmicros.com

2: Getting Started
Example 2.19
func main() dim number as float number = 70000 loop: print number number = number + 1 goto loop endfunc

This example will display: 70000 70001 70002 ..... until the number is out of range for the display format.

Example 2.20 will count from 0 to 8,388,60.7 in .1 increments.

Example 2.20
For more information on the format command check out the Zeus String functions help docs or manual. func main() dim number as single number = 0 loop: print format(number,.0) number = number + .1 goto loop endfunc

This example will display: .0 .1 .2 .3 ..... until the number is out of range for the display format.

Don't place a comma between the format data and the values.

Floating Point Conversion


When a command or function requires a variable parameter you can substitute integer and floating point variables. Zeus will automaticaly convert them for you.

Zeus www.krmicros.com

Page 135

2: Getting Started
Integer Math
Math on the Zeus works as you may expect with just a few exceptions. As shown in Example 2.21, we simply place the result variable on the left side of the equal sign and the math expression on the right side. In this case 2 * 7 will be evaluated to 14 and placed in the variable called value.

Example 2.21
func main() dim value as integer value = 2 * 7 print value endfunc

Zeus calculates the expression in the order that they are encountered. This is done for speed and simplicity and actually works quite well. You can change the order with parenthesis. In Example 2.22 the math calculation will work like this: 2 and 1 will be added. 7 will then be multiplied by the result.

Example 2.22
func main() dim value value = 2 + 1 * 7 print value endfunc
2 is placed in result. 1 is added to result. Result is multiplied by 7. The result 21 is placed in the variable value.

You can also use other variables in your math expressions. In Example 2.23 we first assign values to both y and z variables.. Next we take the two variables and use them in an expression assigning them to the x variable.

Example 2.23
func main()

When using the shortcut to declare integers you can place multiple variables on the same line. You can only do this with integers

dim x, y, z y = 10 z=5 x=y/z print x endfunc

y (10) is placed in result. Result is divided by z (5). Result is placed in variable.

Notice the dim statement in Example 1.23. When the shortcut version of the dim statement is used you may place multiple variables on the same line. Simply seperate them by a comma.

Page 136

Zeus www.krmicros.com

2: Getting Started
A few notes on integer math. In integer math the values will contain whole numbers only. If a result contains a decimal number it is simply removed. The result in Example 2.24 will be 2 not 2.5. If you dont want to round use floating point and the \ instread of the /.

Example 2.24
func main() dim x x = 10 / 4 print x endfunc Any command that accepts expressions can also be passed a math expression. The print command is a good example. As shown in Example 2.25, when a math expression is passed to a command it will be evaluated first then passed. Many commands and functions will call for expressions as input. This can be a simple number or it can be a complex math expression.

Example 2.25
func main() print 4 * 5 endfunc
The expression is evaluated then passed to the command.

Zeus www.krmicros.com

Page 137

2: Getting Started
Floating Point Math
Floating point math works exactly like integer math with a few exceptions.

Floating Point Truncation


When you devide a number with floating point you have the ability to chop off the ramainder so that ther will be no rounding. You use the \ operator instead of the normal / operator.

Signed Numbers
As with integer variable floating point variables are signed as well. This means they can be negative.

Example 2.26
func main() dim myvarb as single myvarb = 10 - 12 print myvarb endfunc
Displays -2

Note that you can always use the abs math function to convert any negative number to a positive one. Zeus has several built in math functions.

Abs Acos Asin Atan Atan2 Ceiling Cos Cosh

Exp Floor Log Log10 Max Min Pow Random

Round Sin Sinh Tan Tanh Sqrt

These can be used with any variable type and the conversion will be automatic. They are used like functions

Example 2.27
func main() dim myvarb as float myvarb = Random(1,5) print myvarb endfunc

Page 138

Zeus www.krmicros.com

2: Getting Started
for / next
While you can use the goto command to create loops, the for/next command allows you to create some very efficient and specific loops. In order to use a for loop you must use an integer or floating point variable to act as an index while the for/next command is executed. Lets take a closer look at the syntax used with the for command. for AAA = BBB to CCC In the Zeus language the for/next command is always checked before the actual loop is executed. This means if the index is out of range it will not execute even on the first pass. AAA is the variable to used as the counting index BBB is the starting expression CCC is the ending expression Example 2.28 will count from 1 to 10. As long as the counting values are within the range of 1 to 10 the commands between the for and next commands will be executed.

Example 2.28
func main() dim x for x = 1 to 10 print x next endfunc
This program will loop 10 times. Each time the x variable will be incremented by 1.

There is an optional argument that can be supplied with the for/next command. This is the step argument. This allows you to specify how much you want to increment the index during each iteration. In Example 1.29 the for/next loop will count from 2 to 10 by 2s.

Example 2.29
func main() dim x for x = 2 to 10 step 2 print x next endfunc
This program will count by 2s because of the step command.

Zeus www.krmicros.com

Page 139

2: Getting Started
You can modify the index variable freely as the for command iterates. Once the end count is reached either by counting or by user intervention, the loop will exit once the next command is reached. In Example 2.30 we show how to manipulate the index.

Example 2.30
func main() dim x for x = 1 to 5 print x x = 10 print x next
The for/next loop will execute 1 loop. Notice that the index variable will contain the correct index until you change it.

You can use an integer or floating point variable as the index variable in a for/next loop.

To count backwards you must use the step argument with a negative number as shown in example 2.31.

Example 2.31
func main() dim x for x = 10 to 1 step -1 print x next endfunc
Any time you want to count backwards you must use the step argument. Supply it with a negative interval.

You can also use a goto command to exit a for/next loop. A gosub command may be used to temporarily exit a for/next loop. Once the return is encountered it will reenter the loop where it left off. This is the same for functions. You may temporarily exit the loop to call a function but it will return to the loop once the function exits.

When using a floating point variable as your index you can increment or decrement by fractions by using the step argument as in Step .5.

Page 140

Zeus www.krmicros.com

2: Getting Started
if / then / else
The if/then command is where real programming can be done. By combining them with the other looping commands and math expression some pretty advanced constructs can be created. if/then/else expressions support both floating point and integer variables. To compare strings use the StrIf command. Lets look at the simplest if then command. I call this the single line if/then. The syntax goes something like this: If expression1 condition expression2 then do something The expressions can be just about any variable/math combination. The condition can be any of the following = Equal < Less than > Greater than <> Not Equal to >= Greater than Equal to <= Less than Equal to When using the single line if then beware as it does not work with macros at this time. In Example 2.32 the state of port 0 is compared with the value of 1. Since we are using an equal sign as the condition operator, the condition will evaluate as true only when the variable x is equal to 10.

Example 2.32
func main() dim x as integer x = 10 if x = 10 then print "Its 10" endfunc
If condition is true then everything following the then command is executed.

To get a little fancier in example2.33 we made the if command a multiline statement. This will allow us to actually process multiple commands if the condition is met.

Example 2.33
func main() dim x as integer x = 10 if x = 10 then print "Its 10" endif endfunc Zeus www.krmicros.com

If condition is true then all commands between the then and endif are executed.

Page 141

2: Getting Started
To take it one step further we will add the else option. In Example 2.34, by adding the else command we give the if statement a place to go if the test condition is false.

Example 2.34
func main() dim x x=9 if x = 10 then print "Its 10" else print "Its Not 10" endif endfunc

If x is 10 then print Its 10

If x is not 10 print Its Not 10

You can also test two conditions by using the and/or statements.

Using multiple and/or statements


While you can use multiple and/or statements each will be calculated as they are encountered.

Example 2.35
func main() dim x as integer dim y as integer x = 10 y = 20 if x = 10 and y = 15 then print "Yep" else print "Nope" endif endfunc

You can have as many and/or statements as you wish. They are evaluated as they are encountered. Think of all the expressions as pairs. The first two will be compared with the and/or operator. At that point it will pass or fail. If it passes the next and/or statement is evaluated.

In this example we added the and statement. With the and statement both if expressions must evaluate true to pass.

This is very similar to short circuiting in VB with the AndAlso and OrElse commands.

Page 142

Zeus www.krmicros.com

3: The Next Step


Introduction
In this chapter we will get our hands a little dirtier. We will discover the real power of functions. You will learn how to define and access array data. You will learn how to manipulate string data.

Zeus www.krmicros.com

Page 143

3: The Next Step


Passing Values to Functions
In order for a function to be useful you must be able to pass parameters to a function. You could use a global variable but this defeats the whole reason for using local variables. A functions real power is in its ability to isolate a segment of code from the main program. The only real way to isolate the code is to create a set of input parameters. The parameter list is created when a function is defined. In Example 3.1 two parameters are shown as width and length. When you create a function that uses parameters you are creating a piece of reusable code.

Example 3.1
func printboxtotal(width as integer,length as integer) dim ttotal as integer ttotal = width + length print "Total Box Size = ",ttotal endfunc

The parameter list is placed inside the parentheses just after the function name.

You must set the type of each parameter passed. As shown in Example 3.1 both are integer. Once the parameters have been defined they are treated as normal local variables to the function that created them. You can change the values that were passed as shown in Example 3.2.

A couple of things happen behind the scenes when you define a parameter list. It provides the interface for calling the function. It defines the parameters in the list as local variables.

Example 3.2
func printboxtotal(width as integer,length as integer) dim ttotal as integer width = width * 2 ttotal = width + length print "Total Box Size = ",ttotal endfunc

Changed local variables will not effect the values or variables that were used to call the function. To call a function and pass it values, place the values you wish to pass inside paretheses in the order that they were defined as shown in Example 3.3. Note: The use of parentheses is not optional.

Page 144

Zeus www.krmicros.com

3: The Next Step


Example 3.3
func main() printboxtotal(25,10) endfunc
The value 25 is placed in the width variable. The value 10 is placed in the length variable.

func printboxtotal(width as integer,length as integer) dim ttotal as integer ttotal = width + length print "Total Box Size = ",ttotal endfunc

Returning a value from a function.


A function may also return a value. This is done with the exit command. The exit command allows you to return an integer, string, or floating point value

Example 3.4
When a function exits without the exit command it always returns a zero. exit requires () even when no parameters are used. func getboxsize(width as integer,length as integer) as integer exit(width + length) endfunc
The exit command is used to return a value. Here we define the function as an integer. We could also define the function as a single or string. If no function type is given it defaults to integer.

depending on how the function was defined as shown in Example 3.4. By default, functions are defined as integer. In order to define a function as a floating point you must use the as single option as shown in Example 3.5.

Example 3.5
func formual(value1 as integer,value2 as single) as single exit(value1 / value2) endfunc

Notice the single declarations

Zeus www.krmicros.com

Page 145

3: The Next Step


In order to get the value from a function you must use the function in a variable assignment as shown in Example 3.6.

Example 3.6
func main() dim bs as integer bs = boxsize(25,10) print "Box Size = ",bs endfunc

Here is where we make the call to the boxsize function. The result will be placed in the bs variable.

When you pass values to a function without a matching parameter list, the values are placed into the first defined variables. This can cause unexpected results with floating point variables and values.

func boxsize(width as integer,length as integer) as integer exit(width + length) endfunc You can create some compound assignments as shown in Example 3.7.

Example 3.7
func main() dim bs as integer dim v1 as integer v1 = 10 bs = sqr(v1) + 25 print "Value = ",bs endfunc func sqr(n1) as integer exit(n1 * n1) endfunc

Something you may have noticed. If you seperate parameters in the print command with a comma it will print a tab in its place on the console.

Parameter Conversion
If a parameter has been defined as float and you pass an integer value it will automatically be converted to float before being placed in the parameter variable. If a parameter has been defined as integer and you pass a floating point value it will get converted as well. In this case you could lose accuracy of the passed value. This is also true of strings.

Page 146

Zeus www.krmicros.com

3: The Next Step


Arrays
Arrays are groups of variables that are defined and indexed. We use an index to access any single variable in the group. To define a group of variables you use the dim and global commands as you do with non array variables. To define an array of integers you just need to indicate how many are in the group.

Example 3.8
dim size(10) as integer

This defines a group of 10 integers.

Example 3.8 shows how to define an integer array that consists of 10 integers. It works the same with floating point arrays.

Example 3.9
Array indexes are zero based. 0 accesses the first variable. 1 accesses the next and so on. func main() dim size(10) as integer size(5)=21 print size(5) endfunc
Here we assign the 6th integer in the group the value of 21.

Here we read the 6th integer in the group. Its the 6th becsue arrays are zero based.

In Example 3.9 we show how to access the individual elements in an array. You can use the for loop to rapidly access multiple array elements as shown in Example 3.10.

Zeus www.krmicros.com

Page 147

3: The Next Step


Example 3.10
func main() dim size(10) as integer dim idx as integer for idx = 0 to 9 size(idx) = 21 + idx next for idx = 0 to 9 print "Item ",idx," size = ",size(idx) next endfunc There is no bounds checking in Zeus. If you go outside the defined array group you will start writing into the next variable or array. This could be useful.

In this for loop we make the assignement to each element in the array.

In this loop we access each element in the array.

Array Restrictions
While array elements may be used in just about every situation as that of normal variables, there are a few exceptions. You may not pass a whole array to a function, only a single element. You may not return a whole array from a function, only a single element. When a function expects a variable you may not use an array element. Many of these restrictions can be overcome and will be covered in advanced technques. You can create arrays of integers, floating point and string variabled.

Double Dimension Arrays


Zeus also supports double dimension arrays as in dim myarray(10.20).

Page 148

Zeus www.krmicros.com

3: The Next Step


Strings
The Zeus language can work with strings as easy as it can integers and floating point variables. String alocation is automatic. There is no need to set the length of the string when you create them. You define a string by using the dim and global statement just like you did with the integer and floating point varaibles. Example 3.11 shows an example of how to define a string. Its much like what we do to define an array.

Example 3.11
func main() You cant use normal math operators when assigning strings. The only two valid operators are: + Adds the strings - Subtracts the contents of the string on the right side if it exists on the left side dim name as string
Define the string here.

name = "Mike" print "Hello "+name endfunc

Lets look at some of the ways we can access and manipulate strings.

String Direct Access


Direct access works much like you would expect. You assign a set of characters to a string using quoted characters or other strings. Example 3.12 show basic direct access.

Example 3.12
'Direct Access with strings func main()
First we define 3 strings.

global name as string global greeting as string global misc as string name="Mike" greeting="Hello" misc= greeting + " " + name print misc endfunc Zeus www.krmicros.com
Here we print the final string Next we assign a few values to the strings. In this assignment we build a string based on other strings.

Page 149

3: The Next Step


Partial String Assignment
It is possible to assign portions of a string to another. We use the Mid string function for this.

Example 3.13
'Partial String Assignment func main() global testvarb as string global myvarb2 as string testvarb="ABCDEFGH" myvarb2 = mid(testvarb,2,5) print myvarb2 endfunc
The (2,5) says take sting varb testvarb and starting at the 2nd pos (1 Based) take 5 characters. This Example will display BCDEF

Print Command and Strings


The print command is actually a string command. When you print integers and floating point they are converted to strings. This why some expression have results you might not expect.

Example 3.14
func main() print 10 + 20 endfunc

Example 3.20 will print 1020 not 30 as you would expect. This is because the 10 is converted to a string 10 and the 20 is printed to a string of 10. To force the print command to handle them they way we want we place the integer expression in the int() converter function as shown in Example 3.15 This is also what you do if you want to assign an expression to a string.

Example 3.15
func main() print int(10 + 20) endfunc

Page 150

Zeus www.krmicros.com

4: Macros
Macros
The Zeus language supports the use of both simple and complex macros. Simple Macros Simple macros are the easiest to create. You start a macro with the macro command. You end a macro with the endmacro command. Each macro is given a name that will be used throughout your code. Simple Macro Example 4.1 macro hello print hello endmacro func main() hello endfunc Example 4.1 shows a simple macro. Important Macros must be defined at the beginning of your program before the first function.

There is no limit to the number of macros that you may define.

Each time you use the hello macro the word hello will be printed. With macros you can create your own commands.

Macro Example 4.2 macro hello print hello : endmacro func main() hello endfunc You can also define a macro on the same line as shown in Example 4.2

It is much more efficient to use macros instead of functions for simple operations. It is not uncommon to create a complete interface library with nothing but macros.

'Macro Example 4.3 macro hello print "hello [exp0]" endmacro func main() hello mike endfunc You can supply parameters to your macro like you would a command by using a [exp0] substitution field. Note that you can use up to 20 parameters. They are named [exp0] through [exp19]. To use them just place them in your code where you want the parameter to be substituted. To use the parameter just pass it as a argument with the macro name. There is no proccessing of the text or paramaters. The text is simply substituted be for the compiler compiles that piece of code.

Zeus www.krmicros.com

Page 151

4: Macros
'Macro Example4.4 macro crazy loop[#]: print Hello goto loop[#]: endmacro func main() crazy endfunc When using labels within macros you should always end the label name with a [#]. This allows the macro compiler a way of creating unique instances of the label. If you don't do this you can only use the macro once and it may interfeer with other labels. Macros can not be used as function arguments.

Complex Macros
Complex macros are 2 part macros. With a two part macro you can start the macro include normal code then finish the macro. You split a macro into 2 parts with a splitmacro command. You must supply the 2nd half of the macro 'Macro Example 4.5 a name as well. macro while loop[#]: if [exp0] then splitmacro wend goto loop[#] endif endmacro ---------------------------------------func main() dim x x=0 while x < 5 print x x=x+1 wend endfunc Example 4.5 shows how to build a complex macro.

This complex macro creates a new command while/wend.

Page 152

Zeus www.krmicros.com

5: Zeus Debugger (Desktop)


Debugger / Simulator (Desktop)
Zeus allows you to single step through your program.

First compile your program. If there were no errors you can start the Debugger.

The Debugger controls are located on the file manager. Once you compile your program the bar will become enabled.

Start the program. This will run the program continuously.

Once started you can pause the program by hitting the pause control. This will place the program into single step mode.

This is the single step control. This will cause the highlighted command to be executed.

This control will stop the program.

Zeus www.krmicros.com

Page 153

5: Zeus Debugger (Desktop)

The speed bar lets you control the speed when you are running the program in continuous mode. The full left is no delay and the right is 1 second per command.

The command in your source code will be highlighted as the debugger steps through your program.

Variable Watch Form (Desktop)


The debugger has the ability to view the contents of your local and global variables.

You load the watch form by selecting the Variable Watch Form entry from Forms menu on the Zeus File Manager.

Page 154

Zeus www.krmicros.com

5: Zeus Debugger (Desktop)

Local Variables being Watched Available Variables

Global Variables being Watched

Once loaded all available variables will be displayed on the left side of the form. All local variables will be displayed under the function where they are located in your source code. All global variables will be located under the Global Variables entry. To watch a variable just double click it. It will be added to the appropriate watch window. The local variables will be displayed on the upper right panel. The global variables will be displayed in the lower right panel. You may watch up to 50 local variables and 50 global variables. Currently if the variable is an array on only the first item in the array will be displayed. Zeus Lite only allows you to view 1 Local and 1 Global variable at a time. By right clicking on an item in the watched variables panels you can delete the watch or modify the actual Zeus variable.

Zeus Lite does not have the ability to edit a variable.

Zeus www.krmicros.com

Page 155

5: Zeus Debugger (Desktop)


When the form exits it will save its location and variable watch list. Each time you compile a program the available variables will be updated. If one of you watched variables is not in this list it have a ? at the end of the name. Note that when you add global variables or edit global variables these changes take place immediately. Local variables will only be updated when they are in scope. Also when you edit local variables and they are not in scope the update will be lost.

Page 156

Zeus www.krmicros.com

5: Zeus Debugger (Pocket PC)


Debugger / Simulator (PocketPC)
Zeus allows you to single step through your program.

First compile your program. If there were no errors you can start the Debugger.

The Debugger controls are located on the Edit tab. Once you compil your program the bar will become enabled.

Start the program. This will run the program continuously.

Once started you can pause the program by hitting the pause control. This will place the program into single step mode.

This is the single step control. This will cause the highlighted command to be executed.

This control will stop the program.

Run to cursor. Place the cursor on a point in the code. The program will run until it reaches that point.

Zeus www.krmicros.com

Page 157

5: Zeus Debugger (PocketPC)

The speed bar lets you control the step speed when you are running the program in continuous mode. The full left is no delay and the right is 1 second per command.

The command in your source code will be highlighted as the debugger steps through your program.

Variable Watch Form (Pocket PC)


The debugger has the ability to view the contents of your local and global variables.

You load the watch form by selecting the Variable Watch Tab

Page 158

Zeus www.krmicros.com

5: Zeus Debugger (Pocket PC)

Local Variables being Watched

Available Variables Global Variables being Watched

Once loaded all available variables will be displayed on the left side of the form. All local variables will be displayed under the function where they are located in your source code. All global variables will be located under the Global Variables entry. To watch a variable just hold the stylus down until the menu pops up and select the Add to Watch entry It will be added to the appropriate watch window. The local variables will be displayed on the upper right panel. The global variables will be displayed in the lower right panel. You may watch up to 50 local variables and 50 global variables. Currently if the variable is an array on only the first item in the array will be displayed. Zeus Lite only allows you to view 1 Local and 1 Global variable at a time. By holding the stylus down on a watched variable in one of the watched panels you can delete the watch or modify the actual Zeus variable. Zeus Lite Does not have the ability to edit a variable. When you shut down Pocket Zeus it will save the variable watch list. Each time you compile a program the available variables will be updated. If one of you watched variables is not in this list it have a ? at the end of the name. Note that when you add global variables or edit global variables these changes take place immediately. Local variables will only be updated when they are in scope. Also when you edit local variables and they are not in scope the update will be lost.

Zeus www.krmicros.com

Page 159

5: Zeus Debugger (PocketPC)


When ever you use the print command the data gets displayed on the Console form located on the Console Tab. A nice feature while you are debugging is to place a copy of the console on the Edit Tab. You do this by selecting the Edit checkbox on the Console Tab.

Now when ever the Edit Tab is selected the copy of the Console will be displayed below the edit form.

The Watch Tab also has the ability to move one of the watch panels to the Edit Tab. Select the Local or Global Panel.

Page 160

Zeus www.krmicros.com

5: Zeus Debugger (PocketPC)

Now all the needed information is located on the Edit Tab. Even though there is limited landscape on the Pocket PC you find this feature very helpful as you debug code. It also works very nice if you are learning to program.

Zeus www.krmicros.com

Page 161

Page 162

Zeus www.krmicros.com

Section 3 Zeus Form Builder

This manual will provide a basic understanding of the Zeus Form Builder. OverView The Zeus Form Builder is a WYSIWYG designer that is integrated into the Zeus Language. The Zeus Form Builder supports the following graphical objects. Horizontal Line Vertical Line Rectangle Filled Rectangle Ellipse Filled Ellipse Label TextBox Button This tutorial does not cover every detail about the Form Builder. It is intended as a getting started guide. Feel free to experiment. The Form Builder was designed to be as intuitive as possible but if you find something out of place or don't understand any concept or function feel free to contact KRMicros. We welcome any question or suggestion you may have.

www.kronosrobotics.com

1: What is Form Builder


What is Form Builder The Zeus language supports various graphical objects that allow you create what we call a form. Commands like FormFillRectangle and FormTextBox can be used to create a user interface. While you can create a very nice user interface manualy using these commands, it is much faster if you can do it using a WYSIWYG interface. WYSIWYG stands for What You See Is What You Get. This means that instead of using code to place a button on form, you do it visually. For example take the command FormButton 0,10,10,60,20,My Button To get it placed in the right place on the screen you may have to adjust the location and size parameters many times to get it perfect. With WYSIWYG you doit by actualy dragging the button around on a mock form like the one sown here.

To move the button you place the mouse on the object and simply drag it to where you want it to be. To resize the button you place the mouse on one of the sizing squares and drag until you see the size you want. Any object you select will have the sizing squares and you may also use the keyboard arrow keys to move an object in any direct one pixel at a time. By holding the shift key down you may also use the arrow keys to change the size one pixel at a time.

Zeus www.krmicros.com

Page 165

2: Getting Started
Lets jump right in and create a simple form using the Form Builder.

Step 1
Create a new Zeus file.

Step 2
Select Add Empty Form Builder Declaration from the Edit menu.

Page 166

Zeus www.krmicros.com

2: Getting Started
This inserts a <FormBuilderStart()> and a <FormBuilderEnd> entry at the end of the program.

Step 3
You will need to give the form a name. This is used to identify the form. Any constants created in the form will be prefaced with this name. Insert the name in between the two parenthesis as shown here

Changes that you make to the Form Builder are stored internally but they flag the program code edit form each time you make a change. When you Compile, Run or Save your program code the actual Form Builder objects are collected and placed directly into your code. This means that your form definitions are located with your source code. Along with the object definitions for form builder is the actual code to create the form.

Zeus www.krmicros.com

Page 167

2: Getting Started
At this point you can bring up a the Form Builder screen. This is done by clicking on the <FormBuilderStart(Main)> line in your program.

This is what an empty Form Builder form looks like.

Step 4
To add a graphical item (object) to the form select an item from the Items menu. In this case we want to add a button.

Any time you add a graphical item to the Form Builder form they will appear in the location show here. Keep this in mind as they may get get covered by other items.

When you click on an item it will become selected. When an item is selected 8 resize boxes will appear around the item. You can resize the item by dragging any of these resize boxes.

Page 168

Zeus www.krmicros.com

2: Getting Started
When an item is selected all the property fields for that item will be displayed. You can modify these manually if you wish but the change will not take place until the field you changed looses focus. (IE you move to another field) Note that if you have not purchased a Form Builder Key the Text field will display the form data but you are not allowed to change it.

You may nudge the location of a selected item by using the arrow keys. If you hold down the shift key this will nudge the size.

Step 6
Add a TextBox to the form then place both the TextBox and the Button in the positions shown here. Step 7 Save your program as a file called FormDemo. When you save your program all the items in the form are converted to code and placed in between the <FormBuilderStart(Main)> and the <FormBuilderEnd> statements.

Zeus www.krmicros.com

Page 169

2: Getting Started
Note that when you Compile or do a Quick Run the Form Builder data is collected as well. Once collected two functions are added. XXXX_DisplayForm() XXXX_CheckButtons() XXXX is the form name. DisplayForm is a function that you call from your program to build the form. Note that you may call this function more than once. It will erase the form and build a new one each time. Important: You may optionaly pass the width and height of the form in the DisplayForm function. XXXX_DisplayForm(700,800) CheckButtons is a function that you call to test all the buttons you placed on the form. It will return a number indicating the button pressed. If no button have been pressed it will return -1. Note that you can also add button handler code directly to the CheckButtons function. More on this later. If you scroll down through the added code you will also notice a section of code that starts with <%~~FB Start~~#> This starts and area the stores the raw form data. While this data is not used to run your code it is used to store the raw Form Builder data used to build the form in Form Builder when you double click the <FormBuilderStart statement.

Page 170

Zeus www.krmicros.com

2: Getting Started
Step 8
In order to actually use the form data you create with the Form Builder you have to add a couple pieces of code to your main program. To build and display the form you need to call the DisplayForm function. Remember we must preface the DisplayForm() with the name of the form as in Main_DisplayForm() as shown here. In order to check the state of the buttons you must make a call to the Check_Buttons() function as in Main_CheckButtons() Main_CheckButtons() will return a value based on which button has been pressed so you will need to store the value in a variable. In this example we are storing it in the variable Stat. if the Main_CheckButtons() function returns a -1 no button was hit so we simply jump back to the loop and try again. When you build your form with Form Builder, buttons are assigned values in the order that they are created. For instance the first button will be 0 and the second will be 1. The number returned by the Main_CheckButtons() function is this number.

Step 9
Enter the program data shown above and hit the Quick Run button. When you hit the button the console will display the button number. Try adding more buttons and see what happens when you run the program. Step 10 Add the code shown on Page 12. The problem with using numbers to test which button is pressed presents a problem if you change the order of the form item in the Form Builder. You would have to go back and change all your code each time you changed this order. It is best to use the global constant that is created by the Form Builder. You will notice that each graphical item has a Name field. This is the name given to the item. Well almost. The full name is actually the form name and the item name separated by a _. Hence the name of our button is actually Main_Button0. We can use this name anywhere in our program to access the item. This is how we retrieve and change our Label, TextBox and Button form data.

Zeus www.krmicros.com

Page 171

2: Getting Started
We use the statement if Stat=Main_Button0 to test our button and no matter what order we place the buttons in our code will be safe. Notice how we use the text box name Main_TextBox1 with the FormTextBox function to retrieve the text box data.

Step 11
Add a few buttons and display a different message based on the button hit.

Did you notice that as you change data on the Form Builder the program code form received a notification that the data has changed. This is indicated by the * in the name of the program form.

There are other ways to access the buttons in the form. One way is to use the FormButton function and the button name to test the button directly. In this case you don't have to call the CheckButtons function. This is a bit more work but you have total control over your buttons. If you have purchased a Form Builder key there is yet another way to handle button data. You can create a handler for each button.

Page 172

Zeus www.krmicros.com

2: Getting Started
Step 12
Change the text for the Button to Hello (Only Registerd Form Builder Users) Select a button and hit the code Tab.

Enter the following code into the code window. MsgBox(Hello +FormTextBox(Main_TextBox0),0) This code will be executed each time this button is hit.

When using a button handler your program code is much simpler.

Step 12
Make the changes shown here to your program code. Run the program and give it a test.

Zeus www.krmicros.com

Page 173

2: Getting Started
There are other advantages to using the button handlers. You can use a wild card in the place of the form name. Example: MsgBox(Hello +FormTextBox([FormName]_TextBox0),0) When the code is added to the program it will automatically substitute the proper form name. This will allow you to used the same form logic with other form names. One final item before we end the tutorial. You can change the order of an item or control using the order options in the Edit Menu.

A few things to keep in mind are that while you can change the order of individual items they are grouped and displayed in the following order. 1. Graphic items like rectangles and Ellipses. (Always on bottom layer) 2. Labels. 3. TextBoxes. 4. Buttons. (Always on top layer)

Thats it for the tutorial. Experiment with some of the other graphic items. There are various examples using the Form Builder. This normally have Form in the name of the example file. Remember to load the Form Builder click on the <FormBuilderStart statement and the form data will be loaded. Even if you don't have a registered version of Form Builder you can look at the data and make many modifications. There are three main restrictions when the Form Builder is not registered. Only 5 graphic items can be added to the form You may not edit the Text field You may not edit the Button handler field

Page 174

Zeus www.krmicros.com

3: Properties
The following is a description of each of the graphic item properties. Name This is name used to access the Label, Button and TextBox. The actual name will be prefaced by the form name and a _. Example Main_TextBox0 Applies to Label, Button, TextBox Xpos The left position of the graphic item. Applies to All Ypos The top position of the graphic item. Applies to All Width The width in pixels of the graphic Item. Applies to All Height The height in pixels of the graphic Item. Applies to All Order Shows the draw order of the graphic item. This field can only be changed by using the Edit menu. Applies to All BackColor Sets the background color of a particular graphic item. You can change the individual RGB values or use the color picker control button. Applies to Label, Button, TextBox, Filled Ellipse, Filled Rectangle ForeColor Sets the foreground color of a particular graphic item. You can change the individual RGB values or use the color picker control button. Applies to All
Zeus www.krmicros.com

Page 175

3: Properties
The following is a description of each of the graphic item properties. Name This is name used to access the Label, Button and TextBox. The actual name will be prefaced by the form name and a _. Example Main_TextBox0 Applies to Label, Button, TextBox Xpos The left position of the graphic item. Applies to All Ypos The top position of the graphic item. Applies to All Width The width in pixels of the graphic Item. Applies to All Height The height in pixels of the graphic Item. Applies to All Order Shows the draw order of the graphic item. This field can only be changed by using the Edit menu. Applies to All BackColor Sets the background color of a particular graphic item. You can change the individual RGB values or use the color picker control button. Applies to Label, Button, TextBox, Filled Ellipse, Filled Rectangle ForeColor Sets the foreground color of a particular graphic item. You can change the individual RGB values or use the color picker control button. Applies to All
Zeus www.krmicros.com

Page 176

4: Item Constants
As you add graphical items global constants will be assignd so that you can acces varius attrubutes from code.

For instance if you added a Filled Ellipse called speed the following constants will be added. gconst gconst gconst gconst gconst gconst gconst WSI_SpeedX X coord WSI_SpeedY Y coord WSI_SpeedH Height WSI_SpeedW Width WSI_SpeedBCR Color Red WSI_SpeedBCG Color Green WSI_SpeedBCB Color Blue

If you add a boarder to the ellipse then the following will also be added. gconst WSI_SpeedFCR Border Color Red gconst WSI_SpeedFCG Border Color Green gconst WSI_SpeedFCB Border Color Blue

These constants allow you to set program code based on position and colors of items created with the FormBuilder.

Zeus www.krmicros.com

Page 177

Das könnte Ihnen auch gefallen