Chosen Script: Difference between revisions
New page: {{context|Kit Reference|Script Types}} ==Technical Details== :{| class="scripttable" |class="leftnormal"|Initial Context: |Pick |- |Alternate Context: |None |- |Fields F... |
No edit summary |
||
Line 19: | Line 19: | ||
:{| class="infotable" | :{| class="infotable" | ||
|class="leftnormal"|text | |class="leftnormal"|text | ||
|Entry: Contains the default text to display ("-Please Select-").<br> | |(String) Entry: Contains the default text to display ("-Please Select-").<br> | ||
Exit: Contains the text to be displayed to the user as the chosen selection. The final text may contain [[Encoded Text|encoding]]. | Exit: Contains the text to be displayed to the user as the chosen selection. The final text may contain [[Encoded Text|encoding]]. | ||
|- | |- | ||
|ispick | |ispick | ||
|Entry: Indicates whether the chooser contains a selection or not.<br> | |(Number) Entry: Indicates whether the chooser contains a selection or not.<br> | ||
Exit: Ignored. | Exit: Ignored. | ||
|} | |} |
Revision as of 12:25, 15 December 2008
Context: HL Kit … Kit Reference … Script Types
Technical Details
Initial Context: Pick Alternate Context: None Fields Finalized? Yes
The Chosen script utilizes the following special symbols:
text (String) Entry: Contains the default text to display ("-Please Select-").
Exit: Contains the text to be displayed to the user as the chosen selection. The final text may contain encoding.
ispick (Number) Entry: Indicates whether the chooser contains a selection or not.
Exit: Ignored.
Description
The Chosen script is essentially a special-purpose Label script used in conjunction with choosers. This script allows you to synthesize the text to be displayed as the current selection within a chooser. If nothing has been selected yet, you can prompt the user to do so, and you can use color-coding to indicate errors with the current selection.
The initial context for the script is the currently selected item. If nothing is selected, the initial context with be invalid, so you're limited to displaying something simple. Aside from that, the Chosen script is a standard Label script.
NOTE! The Chosen script is read-only. Within this script, virtually all aspects of the structural hierarchy can be accessed, but nothing can be changed.
Example
Choosers provide an excellent solution when the user must choose exactly one option from an assortment. An excellent example is race, where a character must be assigned a single race. The code below shows the Chosen script for the race chooser within the Skeleton files, including color highlighting when no selection has yet been made.
if (@ispick = 0) then @text = "{text ff0000}Select Race" else @text = "Race: " & field[name].text endif