Introducing Zinzala - page 7

Et voila ... the calculator is ready to be scripted. You may consult the complete source code of the application here.

We can verify that the application can be scripted by typing the following command from the command line once we have started the calculator application:

@> yo hexaZen/phalorieburn info got answer in 1.000047 ms What = 0x7a415279 Context = 0x0 Item 'zSDK' have 1 value(s) 0 string (5) 'v0.1' Item 'Username' have 1 value(s) 0 string (4) 'jlv' Item 'MaxInstances' have 1 value(s) 0 uint8 (1) 125 Item 'Scripting' have 1 value(s) 0 uint8 (1) 2 Item 'AuthRequested' have 1 value(s) 0 bool (4) false Item 'MaxMSGLength' have 1 value(s) 0 uint16 (2) 300 Item 'GUIEngine' have 1 value(s) 0 string (7) 'Photon'

We can get a list of the targetable widgets of the window named "calc":

@> yo hexaZen/phalorieburn tell calc list distance dunit weight wunit compute result

We can then simply change the value of the distance ran by doing:

@> yo hexaZen/phalorieburn tell calc.distance set value 23.6

source 1

Although the value in the widget has changed, the message that is supposed to be sent by the widget to the window hasn't been cast away. We need to enforce this by scripting the user's action. This is done by the following command:

@> yo hexaZen/phalorieburn tell calc.distance invoke

We can now set a value for the weight and invoke the widget in the same call to yo:

@> yo hexaZen/phalorieburn tell calc.weight set value 60 , tell calc.weight invoke

source 2

Finally, we are going to invoke the compute button widget, as though the user just clicked on it:

@> yo hexaZen/phalorieburn tell calc.compute invoke

source 3

If we want, we can retreive the text displayed by the result widget:

@> yo hexaZen/phalorieburn tell calc.result get text 1466.98 calories

We can put together all these commands in a simple shell script, to compute and retreive the calories burned for a series of different weights for the distance of 42 kms:

#!/bin/sh for w in $@; do yo hexaZen/phalorieburn \ tell calc.distance set value 42 , \ tell calc.weight set value $w , \ tell calc.distance invoke , \ tell calc.weight invoke , \ tell calc.compute invoke , \ tell calc.result get text done

The resulting script gives us:

@> calories.sh 50 55 60 65 70 75 80 85 2175.60 calories 2393.16 calories 2610.72 calories 2828.28 calories 3045.84 calories 3263.40 calories 3480.96 calories 3698.52 calories

5. Conclusion

Using the building blocks provided by the Zinzala SDK, we are able to assemble an application with relative ease. The simplicity and power of the API gives developers of all levels the possibility of creating innovative solutions for the QNX platform.

The built-in support for scripting expands the user's experience in ways which are not forseen by the developers. Applications can be bent, within certain limits, to better suit the user's needs and usage.

The SDK should be available to third-party developers in a few months, for x86 and StrongARM architectures.

To obtain more information, please contact hexaZen at www.hexazen.com
Zinzala and zSDK are trademarks, registered trademarks, or service marks of hexaZen.
All other names mentioned are trademarks, registered trademarks, or service marks of their respective companies.
Copyright © hexaZen 2003-2004. All rights reserved. Zinzala/Docs/Papers/Introducing

Print version

All content © 2004-2007, hexaZen - Vancouver BC, Canada