Talk:Nasal scripting language: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
m (→‎Usage: added)
Line 8: Line 8:
== Mailing List Discussions ==
== Mailing List Discussions ==
=== Usage ===
=== Usage ===
* [http://www.mail-archive.com/flightgear-devel@lists.sourceforge.net/msg12116.html $FG_HOME/Nasal/*.nas]
* [http://www.mail-archive.com/flightgear-devel@lists.sourceforge.net/msg01939.html Use of listeners to wait for events]
* [http://www.mail-archive.com/flightgear-devel@lists.sourceforge.net/msg01939.html Use of listeners to wait for events]
* [http://www.mail-archive.com/flightgear-devel@lists.sourceforge.net/msg13557.html Nasal & "var"]
* [http://www.mail-archive.com/flightgear-devel@lists.sourceforge.net/msg13557.html Nasal & "var"]

Revision as of 17:11, 13 October 2011

Contents that need to be incorporated

Todo

  • mention/explain nil
  • shorthand ops: += *= ~= /=
  • operator precedence, prioritizing expressions using parentheses
  • multi-assignments don't work as expected for functions with multiple return values

Mailing List Discussions

Usage

Features

Nasal Modules

Moving to Nasal Modules.

setprop() functionality

setprop() concatenates a list of input arguments by means of inserting a "/" in between. That is nice for properties, as this slash is part of the tree. However, when one wants to make use of indices, like [0], one has to concatenate by hand (using "~") inside one part of the string argument list. An example is:

 var i = 4;
 setprop("instrumentation","cdu","page["~i~"]","title","MENU");

This results in instrumentation/cdu/page[4]/title = 'MENU' (string). Hcc23