Lee Elliott wrote:
> and the scripts then need to be explicitly invoked.
>
> Presumably, omitting the '<![CDATA[' and ']]>' bits will then result in the
> scripts being executed at start-up.

No, the CDATA stuff is just escaping to prevent the XML parser from
being confused by literal "<", ">" or "&" characters inside the
script.

Maybe the confusion is the difference between a function definition
and its execution?  The stuff between the <script> tags is exactly one
script, and it is always executed at startup.  But if all it does is
something like:

myFunction = func { ... }

then nothing will happen, because all it did is assign the value of
the myFunction *variable* to a function definition.  If you want to
invoke the thing you can then do a "myFunction()".  If you never want
to invoke it again, then they're no need for the func {} stuff at all.

This is a perfectly legal script, for example:

  <nasal>
    <B52F>
      <script><![CDATA[

       myFunction = func { print("Executing myFunction()!"); }
       print("Hello World!\n");

      ]]></script>
    </B52F>
  </nasal>

When you start up, it will print "Hello World!" on the console.  It
will *not* print "Executing myFunction()!".  But later on some other
piece of Nasal code could do:

   B52F.myFunction();

Which would then print "Executing myFunction()!".

Is that clearer?


> I'll have a look at how the bo105 does it and see about moving all
> the scripts I've put in the set file out to external .nas files and
> use the set file scripts just for start-up stuff.

There is no different in execution between code placed in an external
file and code placed in the script tag.  The choice is solely one of
convenience.  Small and simple stuff should go inline, more
complicated code ought to have its own file.

Andy

_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel

Reply via email to