You are on page 1of 10

ETSMART CALCULATOR SCRIPT CREATION

GUIDE
Location in script tree (Required)
Example: [Dashboard\Toyota\Corolla - 93C56]

Must always be started with a "[" and end with a "]" and must use backslash "\" there is no semicolon used.

Will appear in the folder tree as below:


Dashboard
ᶫ Toyota
ᶫ Corolla - 93C56

Notes: If 2 or more entries appear of the same name on the same tier, the first one located will be the only one
shown, e.g. you had a second file pointing to [Dashboard\Toyota\Corolla - 93C56] then the scripts file name is used
to sort, and whichever one comes alphabetically first will be displayed,

This is also true for 2 files on the same tier, (Dashboard would be tier 1, Toyota tier 2, and so on). so say you had a
file pointing to [Dashboard\Honda\Corolla - 93C56] (No such vehicle exists its only an example), as it comes first, the
vehicle listed under Toyota would not be shown, this is something to be aware of with your naming convention.

Size (Required)
Example: Size(280,320);

The first number is the width of the form to display,

The second number is the height of the form to display,

the2 numbers must be separated by a comma "," and must be followed by a semicolon.

Notes: The size of the apply and close buttons must be added to the size of the form, they are 40 pixels high, and to
not be cut off the form should be at least 240 pixels wide

The area they take up along the bottom expands as wide as you make the form remaining centered,

A neat looking padding is about 5 pixels between groups and the edges of the form.

Script Info
Example: !This script was written by me.

Must start with "!" does not require anything after it, only works one line at a time, but can be used as many times as
you would like.

This is the text shown in the Info tab while viewing the script tree, It will be displayed followed by the file location of
the script file

Notes: A space is automatically added at the start of the text when displayed, and adding an additional line with
only a "!" following your text separates it nicely from the file location.
Script Picture
Example: @brain.bmp
@Toyota\brain.bmp
@C:\\Users\brain.bmp

Must start with "@" does not require anything after it, only the first use will be shown

This is the image shown in the image tab of the script tree, It will be scaled to fit in the tab, by default it points to the
Doc directory inside the ETsmart folder, however it also works for folders inside the Doc directory and for files
located elsewhere on your computer.

Additional Information Link


Example: #brain.doc
#Toyota\brain.doc
#C:\\Users\brain.doc

Must start with a "#" does not require anything after it, only the first use will be shown

When used an additional hyperlink will appear at the top of the form saying "Additional Information" this link can be
used to open any file type on your computer, with the limitation that it ignores anything after the file type, so
"brain.exe" will work "brain.exe -s" will not, you can however work around this by pointing it to a batch file.

Note that it cannot open folders, at this time there is no known way to open a folder

Execute:

Form (Required)
Example:

Form
{
Group("Mileage",5,5,140,50)
{
Digit(Distance," ",5,18,90);
Label(lb1,"Km",110,20);
}
}

Must start with the word "Form" followed by "{" and ended with "}"

This part describes the how you will be displaying the various groups, text and functions that will make up the user
interface to your calculator, these functions will be discussed in further detail below, inside this function like all
functions, you want to make sure the number of opening brackets is equal to the number of closing brackets.

Group
Example:

Group("Mileage",5,5,140,50)
{
Digit(Distance," ",5,18,90);
Label(lb1,"Km",110,20);
}
Must start with the word "Group" followed by a "(" and ended with ")"

"Mileage" is the word shown in the header of the group.


First number is offset from left of the form in pixels,
Second number is offset down on the form in pixels,
Third number is Width of the group box in pixels,
Fourth number is height of the group box in pixels,

This draws an outlined box to group various text or number boxes, checkboxes, etc. all items inside of it are
referenced to the group box as opposed the form.

Picture
Example: Picture(Logo,"Toyota.bmp",180,5,0,0);

Must start with the word "Picture" followed by "(" and ended with ");"

Logo is the variable name for the image,


"Toyota.bmp" is the image file to be displayed
The first number is offset from left on the form or group in pixels
The second number is offset down on the form or group in pixels
The third number is image width, if "0" will use original image width
The fourth number is the image height, if "0" will use original image height.

By default references the folder: Etsmart\Calculators\Pictures , This function can be used as many times as you
please, but in general is used to display the Manufacturers logo or script authors logo.

Currently the only valid image types are BMP, and Jpeg / jpg.

Label
Example: Label(lb1,"Km",110,20);

Must start with the word "Label" followed by "(" and ended with ");"

lb1 is the variable that holds the text


"Km" is the text displayed by default
The first number is the offset from left in pixels.
The second number is the offset down in pixels.

By default the text entered in quotes will be shown, however you can assign it to show any text you like later on in
the program, (Discussed later). if you have 2 labels that overlap, the one referenced last will sit on top of the one
referenced earlier.

Digit
Example: Digit(Distance," ",5,18,90);

Must start with the word "Digit" followed by "(" and end with ");"

Distance is the variable to display and edit


" " is the text displayed on the left side of the number field
The first number is the offset from left in pixels
The second number is the offset down in pixels
The third number is the width of the field in pixels

Creates a field that only numbers can be displayed or entered into, Can be used as many times as you like.

If the variable is never given a value in the software it will remain blank and show no value.
Hexdigit
Example: Hexdigit( Pin," ",5,38,50,6);

Must start with the word "Hexdigit" followed by "(" and end with ");"

Pin is the variable to display and edit


" " is the text displayed on the left side of the Hex field
The first number is the offset from left in pixels
The second number is the offset down in pixels
The third number is the width of the field in pixels
The fourth number is the number of characters to display

Creates a field that only hexadecimal can be displayed or entered into, Can be used as many times as you like.

If the variable is never given a value in the software it will remain blank and show no value.

String
Example: String(Vin," ",5,58,110);

Must start with the word "String" followed by "(" and end with ");"

Vin is the variable to display and edit


" " is the text displayed on the left side of the number field
The first number is the offset from left in pixels
The second number is the offset down in pixels
The third number is the width of the field in pixels

Creates a field that text can be displayed or entered into, Can be used as many times as you like. data entered into it
must be ascii characters.

Checkbox
Example: CheckBox(Write,"Write Hours",70,140);

Must start with the word "Checkbox" followed by "(" and end with ");"

Write is the variable that reflects the state of the checkbox


"Write Hours" is the text displayed to the left of the check box
The first number is the offset left in pixels
The second number is the offset down in pixels

Draws a checkbox that can be used to control or show an on/off, yes/no option.

0 = un-ticked, 1+ = ticked. Can be used as many times as you like.

If the variable is never given a value in the software it will show unticked.

Combobox
Example: ComboBox(Type,"Type",20,25,120,"Tachometer","Speedometer");

Must start with the word "Combobox" followed by "(" and end with ");"

Type is the variable to display and edit


"Type" is the text displayed on the left side of the combo box
The first number is the offset from left in pixels
The second number is the offset down in pixels
The third number is the width of the combo box in pixels
All options for the checkbox are then separated by a comma and followed afterwards.

Draws a drop down combo box that can be used to present a list of selectable text options,

0 = first option, 1 = second option, etc.... Can be used multiple times.

Listbox??
Onshow
This part of the software is run when the calculator is first opened and only runs once, generally it is used for things
like reading the current mileage off the bin file, and testing whether the file is valid,

OnChange
This part of the software is run whenever the calculator is opened and the user selects or edits anything in the hex
file, could be used for something like calculating a files checksum while you edit something not added to the script.

OnApply
This part of the software is run whenever the apply button is pressed, this part generally runs the bulk of the
calculation, writing back your edited value

In all 3 of the above segments any variable not controlling something in Form will not carry across to another, so
setting Var1 = 20; in onshow, then trying to read it in onapply will not work, if you want to accomplish something like
this, add a digit, hexdigit, or string that can hold what you require and offset it outside of the form.

Any code outside of these 3 areas will be ignored, meaning you can use it for large text blocks,

Labels and Label Properties

Updating Text
Example: Message = "Hello";
Message = "Hello" + " " + "World";
Message = #i.Var1;
Message is the variable being modified

At the most basic level, the first example makes the label display the word hello,

Following the second example you can combine bits of text, say in a part number, you need to add a letter in
the middle; you can do it using this method

For the third example, the scripts have the option of combining hex or a variable to a few different outputs:

#b.Var1 Converts Var1's value to Hexadecimal


#c.Var1 Converts Var1's last nibble into a single ASCII Character.
#d.Var1 Converts Var1's value to a 32 bit hexadecimal value
#i.Var1 Converts Var1's value to a Decimal Number
#w.Var1 Converts Var1's value to a 16 bit hexadecimal value

You can mix and match these, e.g. "Vin: " + #c.Var1 + #c.Var2 + #c.Var3 + " " and so on,

Notes: For the conversion options, the letters must remain lower case

Colour
Example: Message.Color = 0xFF0000;

Message is the label variable being modified


0xFF0000 is Full Blue
0x00FF00 is Full Green
0x0000FF is Full Red

The 6 hex numbers represent the 3 colour channels, red green and blue. It can only be used on labels

Bold
Example: Message.Bold = 1;

Message is the label variable being modified

0 = Regular
1 + = Bold

Alignment
Example: Message.Alignment = 1;

Message is the label variable being modified


0 = Left Alignment
1 = Center Alignment
2+ = Right Alignment

Bit math
To move around and modify values, there are a few functions to help

Shift Left "<<"


The shift functions are used to push a value left or right, or as a alternative way to write a division or multiplication
by a power of 2, e.g. for shift left Var1 = 2 << 1; Returns 4, 2 << 2 Returns 8.
For every 8 positions you shift you have moved one byte into the next, so it's common to see this expression Var1 =
(@0x01 << 8) | @0x00; or similar, this is taking the bytes from locations 00 and 01, shifting along position 01 into the
next byte, e.g. 1234 becomes 12340000, then using the OR command discussed below joins the 2 together, so if
location 00 was 5678, Var1 would equal 12345678.

Shift Right ">>"


Shift right is very similar to shift left except it is equivilent to division, so 4 >> 1 = 2, 4 >> 2 = 1, etc, This function is
commonly used when writing back the edited parts to the file, as you can only write the lowest byte, it means for
each part you have to shift it across, e.g. in the above example, @0x00 = Var1; this works just fine because its
already the lowest byte, @0x01 = Var1 >> 8; This time it needs to have the upper byte shifted along until it is the
lower byte.

AND "&"
And is used to mask of one number from another, e.g. Var1 = 0x123456 & 0xFF; Would return 0x56 because the
larger part of the number does not match the mask, to make it more clear involves looking in binary, 0xF is 1111 in
binary, in other words if you where to and it with any single digit hex value it would pass, if you say picked 0x7 as
your mask (0111 in binary) any number greater than 7 would be cropped off.

OR "|"
Or is used to combine values together, commonly used in the shift left example. e.g. Var1 = 0x1234 | 0xFFFF; would
return 0xFFFF, or Var1 = 0x1030 | 0x0204; would return 0x1234, To look at it in binary, 0x4 is 0100, anf 0xF is 1111,
so when "Or'd" together, the 1's in F fill the 0's and you have 0xF returned.

XOR "^"

Xor is used to invert numbers or in checksum's, the most common use is Var1 = 0x1234 ^ 0xFFFF; to invert a number,
in this case it is similar to writing Var1 = 0xFFFF - 0x1234; however there is a benefit in that if instead the number
was larger say 0x12345, it would return an unexpected value as the number will wrap around rather than become a
negative, becoming something like 0xFFFFDCBA,
The proper use of Xor is that were ever 2 bits in the same location are equal it returns a 0, where they are not equal
it returns a 1, e.g. Var1 = 0xF ^ 0xA; 1111 ^ 1010 returns 0101 or 0x5.
Reading and Writing
Example: @0x00 = 1;
Var1 = @0x00;

To read or write a value in etsmart you need to use "@" to tell it to treat it as a location rather than a value,

In both cases it only reads or writes 1 byte at a time, and the lowest byte for writes, e.g. @0x00 = 1234; would write
0x34,

Variables
Example: Var1 = 0;

you can treat variables like buckets to store data, you can fill or empty a bucket to a given value, or fill another
bucket to match the same value, but in this same respect changing the value of one will not affect any of the others,
and if you don't assign a value to one before using it, it can upset things as you don't control how much you started
with.

In most cases you will be using "Var" to define all your variables, this is a reserved word and it will treat Var followed
by any number as a variable, e.g. Var1001, however you can also use any variables you set up in your form, e.g. Vin.

Variables can be assigned either numbers or words, e.g. Var1 = "Hello".

The largest value a variable can hold is 0xFFFF FFFF FFFF FFF, leading zero's before this are ok, but adding a 16th digit
will make it overflow, and should the last value be F, will fail,

Mismatch
Example: @0x00.mismatch = 1;

Controls whether a byte is high-lighted as a mismatch from the original, by default the bytes will change colour, but
this can be used to force a byte to remain the normal colour,

0 = Normal colour, black by default


1 = Mismatch colour, light blue by default.
Reserved Words

VAR
STR
DIM
IF
ELSE
WHILE

Strings Initialised like VAR's, str1 = "hello";


To be defined:

Page
pagecontrol

ts

arrary index too big

DIM?

!=

<=

You might also like