[Note: This is an intermediate/advanced level tutorial. You are expected to know how to create forms and how to use the form design view.]
In this tutorial you will learn how to create mini applications with Xbase forms and scripts. We'll be building a Celsius to Fahrenheit temperature converter. So lets get started!
- Create a new document.
- Create a new form called "Converter" with no content table.
- Add a text field to your form by dragging one from the controls section in the options pane.
- Change the text field's label to "Celsius".
- Change the text field's script name, using the action inspector, to "celsius".
- Add another text field to your form.
- Change the second text field's label to "Fahrenheit".
- Change the second text field's script name to "fahrenheit".
- Select the Celsius text field and click "Add Action" in the toolbar.
- Now change the script so it looks like this:
function form_celsius(ctrl) { Form.ControlNamed("fahrenheit").numValue = ctrl.numValue * 9/5 + 32; } - Go back to the form, select the Fahenheit text field and click add action again. Then change new function to this:
function form_fahrenheit(ctrl) { Form.ControlNamed("celsius").numValue = (ctrl.numValue - 32) * 5/9; } - That's it! Switch to form data view. Type a number into a text fields and press return. The other text field should update with the converted value.