Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
ego_script [2026/07/22 17:45] hermann |
ego_script [2026/07/22 20:26] (current) hermann |
||
|---|---|---|---|
| Line 112: | Line 112: | ||
| Since the start and end values in each range above are equal, interpolating between them keeps the value constant — keys 1–4 and 6–9 all map to ''1'', and key 5 maps to ''-8''. When a script is saved from the GUI, ranges like this are automatically collapsed back into ''..'' notation where possible. See [[lookup_table_type|Lookup Table Type]] for the full syntax, including optional key/value column names, and [[table_type|Table Type]] for the syntax rules that apply to tables in general. | Since the start and end values in each range above are equal, interpolating between them keeps the value constant — keys 1–4 and 6–9 all map to ''1'', and key 5 maps to ''-8''. When a script is saved from the GUI, ranges like this are automatically collapsed back into ''..'' notation where possible. See [[lookup_table_type|Lookup Table Type]] for the full syntax, including optional key/value column names, and [[table_type|Table Type]] for the syntax rules that apply to tables in general. | ||
| + | |||
| + | A general table follows the same bracket syntax but allows any number of columns, mixing Real and String data, with types inferred from each column's own values unless overridden with a ''#type'' suffix: | ||
| + | |||
| + | <code> | ||
| + | [ | ||
| + | "PatchId*#string", "Area", "Category", | ||
| + | 007, 12.4, "forest", | ||
| + | 013, 8.7, "pasture" | ||
| + | ] | ||
| + | </code> | ||
| + | |||
| + | Without the ''#string'' override, ''PatchId'''s unquoted values would be inferred as Real numbers — ''007'' would collapse to the number ''7'', losing its leading zero. The explicit type forces String interpretation instead, preserving each value exactly as written. ''Area'' and ''Category'' are left to plain inference: Real from ''12.4''/''8.7'', String from the quoted ''"forest"''/''"pasture"''. | ||
| A call can mix all forms with variable references in a single argument list: | A call can mix all forms with variable references in a single argument list: | ||
| Line 513: | Line 525: | ||
| Converting abbreviated syntax to verbose is always lossless. Converting verbose to abbreviated is only possible when all hooks are free of comments, properties, and identifiers that do not appear in the expression. | Converting abbreviated syntax to verbose is always lossless. Converting verbose to abbreviated is only possible when all hooks are free of comments, properties, and identifiers that do not appear in the expression. | ||
| + | |||
| + | > **Note:** This distinction applies only to saved or generated script text. The graphical interface always displays and edits a calculator functor's expression in the verbose ''i1''/''t1''/''v1'' form, with each hook represented as its own functor node, regardless of whether the //Use abbreviated syntax// option is enabled or which form the underlying file uses. The ''#name''/''%name''/''$name'' abbreviated form exists only in script text; the graphical interface has no corresponding abbreviated representation. | ||
| A common situation where this matters: if you connect a map or lookup table purely to define the output format — not because it is referenced in the expression — connecting it via a ''NumberMap'' or ''NumberTable'' hook will block abbreviated syntax, since the hook defines an identifier absent from the expression. Use the dedicated port instead: the ''Result Format'' input port for map calculators, or the ''Base Lookup Table'' input port for lookup table calculators. These connections do not create hooks and do not affect the availability of abbreviated syntax. | A common situation where this matters: if you connect a map or lookup table purely to define the output format — not because it is referenced in the expression — connecting it via a ''NumberMap'' or ''NumberTable'' hook will block abbreviated syntax, since the hook defines an identifier absent from the expression. Use the dedicated port instead: the ''Result Format'' input port for map calculators, or the ''Base Lookup Table'' input port for lookup table calculators. These connections do not create hooks and do not affect the availability of abbreviated syntax. | ||
| Line 987: | Line 1001: | ||
| hectaresColumn := GetTableColumn areaTable 3; | hectaresColumn := GetTableColumn areaTable 3; | ||
| </code> | </code> | ||
| - | |||