ETsmart Script Creation

Discussion in 'Creating/Modifying Scripts' started by Rerouter, 3 November 2017.

  1. Rerouter

    Rerouter New Member New Member

    Seeing as its not well documented, and there is a bit of a barrier to entry for people not yet familiar with scripting languages, I felt i would write up a more detailed guide to getting started.

    Attached is my main guide, the trailings at the end are functions supported by the scripts, but I do not yet know how to use them, most of this came from me manually trudging through the source code.

    OK, so to begin with, every script in etsmart is a file type .cal located in Etsmart / Calculators,
    These files read as plain text when viewed in a program like notepad, (some manufacturers packs are encoded and will not read as text) allowing for easy modification. Attached is one such file,

    The top line inside the "[" and "]" control where it appears in ETsmarts calculator list, each "\" creates a subfolder for the following, so this one appears in Folder "Dashboard", with a sub folder "Toyota" that then contains the script "Alphard - 93C56 - Yazaki" This is just text, and you can edit and change this how you wish.

    Next up is "Size(,)" This controls the width and the height of the window the calculator will appear in, so if it feels a bit tight, or you want to include bigger images, you can always make this bigger

    Next up are the 4 main "Keywords" that control how the calculator appears and behaves,
    "Form" lays out where all the number boxes, labels, checkboxes, etc are, and where they appear on the window.
    "OnShow" this runs 1 time when the script is first opened, so this is generally used for things like reading out values,
    "OnChange" this runs any time you edit the contents of the eeprom window, you could for instance have it re-calaculate a checksum while you manually change the eeprom contents, This one i rarely use.
    "OnApply" this runs whenever you press the "Apply" button on the bottom of the window, I generally use him to write values back in to the eeprom contents.


    Ok so how to actually make sense of what the script is doing, well in a Yazaki file, it stores the milage in fractions of the main mileage, i nickname this one "Yazaki 17" because its 1/17th of the original milage for this one, there is not much rhyme or reason for why 17, its just what Yazaki chose.

    So to begin with under "OnShow" The first 2 lines "Message.Bold" / "Message.Alignment", these relate back to the Label back in the middle of "Form" we have 1 Label called "Message", so this is setting the text of that message to Bold, and centering the text. we haven't written any text to that label yet, but its just there because it ends up bolded in both cases, whether the dump was good or not.

    So in this script i want to know that this file is not empty, to not waste my time, an empty EEPROM file will generally be full of 0xFF, so I create a variable "Var0" and use some bit math to combine 2 bytes, using the "@" symbol tells the script that we are reading or writing to an EEPROM location, so @0x01 reads for eeprom location 0x01, and similar.

    So we read in locations @0x00 and @0x01, each is a byte big, but the milage in this algorithm is stored across 2 bytes, and we need to combine them, and this is done by using what is called "Bit Math",

    So to better explain it, each byte is 8 bits, a byte is normally represented as a "Hexadecimal" number in our eeprom file editors, e.g. "0x12" which when converted to binary would be 00010010b, each hexadecimal number takes up 4 bits, so if you wanted to take 2 values e.g. 0x12 and 0x34 and make it 0x1234 all you need to do is shift the first value across 8 bits to the left making 0x1200, then combine the 2,

    So again assuming
    @0x00 = 0x34;
    @0x01 = 0x12;

    we take the value of @0x01, we shift is across 8 bits with
    (@0x01 << 8) // 0x1200

    we then want to combine @0x00 on to the end of it, the spot that is now 0x00, to do this you use the "|" Bitwise OR symbol,

    0x34 = 00110100b
    0x12 = 00010010b

    0x12 << 8 = 00010010 00000000b
    | 0x34 00110100b
    = 00010010 00110100b
    = 0x1234

    We then use an "If Statement" to test something, and do something whether that test is True or not.
    So in the example, Var0 now = 0x1234, we are testing if it is "<" less than 0xFFFF, it is, so it runs the piece of code in the brackets after the If statement, if it failed, it would run the piece of code after the "Else" brackets

    So we use "Message.Color" to set the text a colour, we write the test that it is ok, and next we take our value and times it by 17, because yazaki chose to store the milage as 1/17th of the original.

    We then write the value of this milage to a "Digit" called "Distance" up the top of "Form", this is an editable number field, where you can write numbers to it, or read from them.

    If you have gotten this far with understanding, have a read deeper in to my guide, and feel free to ask questions here. I wont outright wright script from scratch for you, but i'm willing to help get your own work running.

    Attached Files:

    Sebacarrera, mk1, saozaaaaa and 10 others like this.
  2. Johnner

    Johnner Administrator

    Admin Post
    Thank you very much Rerouter for this thread...It's exactly what we need here...and hopefully people read it,and ask questions :y:
  3. cfst_arica

    cfst_arica New Member New Member

  4. delenda

    delenda New Member New Member

    I need script grand i10 24C16 VER 01 + VER 02
    Totinho_94, riad3131 and miloudmess like this.
  5. riad3131

    riad3131 New Member New Member

    me too i need script for grand i10 24C16 VER 01 + VER 02
  6. Totinho_94

    Totinho_94 New Member New Member

    with which exactly you edit the Cal. format calculators from etsmart
  7. Cllau

    Cllau Super Moderator Staff Member

    you can create or edit with text editor on your windows...;)

Share This Page