Zamae

The Prosciutto Project

a small footprint mobile application engine and browser - and open source!

HECL COMMANDS IN PROSCIUTTO:

Hecl is a great small mobile scripting language. We've integrated it to Prosciutto for enhancing your Prosciutto-based applications.

For some examples of how to invoke a Hecl script from within a model.xml file in Prosciutto you can check the model.xml file provided in the HelloProsciutto demo app in svn.
There are two ways to indicate this: you can either specify the name of your hecl script file here, as in "/script.hcl" (note the beginning slash is important) or, if your Hecl script is rather small, you can just write it as the value of the parameter attribute of this tag. In this latter case, the Hecl script must come in the action parameter and always start with a "hecl:" prefix.
For example:
<action_fire fire_param='hecl:puts "Hello, World"'>exec_hecl</action_fire>
Or, for a file: <action_fire fire_param='/script.hcl'>exec_hecl</action_fire>


Here are some examples:

getattr example:

    <behavior>
<action_fire fire_param='hecl: set i [getttr 40020 902 18]; puts "This button contains the following text: "; puts $i;'>exec_hecl</action_fire>
</behavior>


settext example:

<behavior>
<action_fire fire_param='hecl: settext 40019 "changed text" "hidden data";'>exec_hecl</action_fire>
</behavior>

An example using goto, goback, goto_absolute, and openurl:

<behavior>
<action_fire fire_param='hecl: hello; goback; set i 1000; while { < $i 10000 } { puts "i is now $i"; incr $i }; goto 13000; set i 1000; while { < $i 10000 } { puts "i is now $i"; incr $i }; goto_absolute 12000; set i 1000; while { < $i 10000 } { puts "i is now $i"; incr $i }; openurl http://www.google.com; exitapp;'>exec_hecl</action_fire>
</behavior>

MMAPI play example

<behavior>
<action_fire fire_param='hecl: puts "waiting 3 secs..."; after 3000; play "/scale.mid|audio/midi"; puts "playing";'>exec_hecl</action_fire>
</behavior>

Execute a hecl script from an embedded file:

<behavior>
<action_fire fire_param='/script.hcl'>exec_hecl</action_fire>
</behavior>

Here's a list of possible commands you can use from within your Hecl script:

       "goto"                                        goto indicates that another form should be shown on screen and get the focus. 
                                                            The goto command has one parameter/argument which is the form ID where to goto 
                                                            (Prosciutto will display such form on the screen). A stack is kept so we can 
                                                            use "goback" actions in the destination form.
       "goto_absolute"                               goto_absolute is the same as "goto", but it doesn't keep track of what is the 
                                                            form that called the destination. Must specify the destination form ID.
       "exitapp"                                     exits the application. No arguments needed.
       "openurl"                                     opens the native browser in the specified URL. The argument to this command is 
                                                            the URL you want the browser to open to.
       "goback"                                      puts the caller of the actual form on screen and sets the focus on the previously 
                                                            focused element in such a form. No arguments needed.
       "settext"                                     this action changes the text and hidden values of a given button to be the same 
                                                            as the parameter of this action, and the form where this button belongs to is 
                                                            shown on the screen. Arguments are the button ID, the new text to be set and 
                                                            the new hidden param (state) to be set for this button.
       "set_attr"                                    set a specific element's attribute to the given value. You should understand 
                                                            the internals of Prosciutto's attribute indexing. This command provides the means 
                                                            for a Hecl script to set any attribute in a object that is currently loaded in 
                                                            Prosciutto's cache/state machine. It requires 4 params: element ID, element type, 
                                                            attribute index that you wish to change, and the new value to be set for such 
                                                            attribute. 
       "get_attr"                                    get a specific element's attribute current value. You should understand the 
                                                            internals of Prosciutto's attribute indexing. It requires 3 parameters: element ID, 
                                                            element type, and attribute index that you want to query.
       "set_cookie"                                  sets the cookie string to a given value. The cookie string is only valuable 
                                                            for connection-oriented applicaitons to send information back and forth from the server.
       "goto_and_show_in_dropdown_mode"              this action is useful for forms that do not occupy the whole device screen. 
                                                            This action reads the actual element's X and Y coordinates (upper left corner) 
                                                            and copies such coordinates to the destination form, giving the feel of the 
                                                            destination form appearing as a drop down menu. The argument to this command is 
                                                            the Form ID to be set onscreen.
       "rethink_heights"                             this action is useful only when new forms are fetched. All heights for all UI 
                                                            elements are recalculated in order to fit the device screen where Prosciutto is 
                                                            running on.
       "set_dflt_form"                               this action sets the default form to be that of the UID indicated in the action 
                                                            parameter.
       "set_zajag_url"                               this action sets the ZAJAG URL. This is the URL where Prosciutto is going to ask for 
                                                            an element that cannot be found in memory.
       "set_orientation"                             Sets the screen orientation. 0, 90, 180 and 270 degrees are the possible values. 
                                                            (try it out, it's nice!).
       "switch_orientation"                          Switches the current orientation to (curr_orientation + 90) degrees. Loops, as 
                                                            in 270+90 = 0.
       "set_language"                                Sets the native language. Currently only English, Spanish and Portuguese are 
                                                            supported (values are 0, 1 and 2 respectively).
       "setenckey"                                   Sets the encryption key. Only useful when using Bouncycastle DES or AES algorithms.
       "set_focus_on_element"                        Sets the focus on a given element as per the ID indicated in the action parameter.
       "play"                                        This is for playing/pausing audio/video files with the MMAPI (one at a time).
       "stop"                                        Stops the currently playing audio/video file.
       "read_gps"                                    Asks Prosciutto to read the underlaying platform's GPS coordinates and save those in its internal memory.
       "get_coordinates"                             Retrieves the coordinates as obtained by the read_gps command, in the form of a string conatining latitude and longitude, separated by a space character.
    

Back to the form object description
Back to UI objects listing