Nasal Hello World: Difference between revisions

Jump to navigation Jump to search
A few more edits, inc. comment out stuff on strings which doesn't belong here
No edit summary
(A few more edits, inc. comment out stuff on strings which doesn't belong here)
Line 1: Line 1:
{{Nasal Navigation}}
{{Nasal Navigation}}


In the programming world, a "Hello, World!" program is used to illustrate basic syntax using a very simple program. The '''"Hello, World!" program in [[Nasal]]''' would look like this:
In the programming world, a {{wikipedia|"Hello, World!" program}} is used to illustrate basic syntax using a very simple program. The '''"Hello, World!" program in [[Nasal]]''' would look like this (run this in the [[Nasal Console]]):
<syntaxhighlight lang="nasal">
<syntaxhighlight lang="nasal">
print('Hello World!');
print("Hello World!");
</syntaxhighlight>
</syntaxhighlight>


This will show the "Hello World" string during startup in the console window. The hash sign (#) just introduces comments (i.e. will be ignored by the interpreter).
This will print the string <code>Hello, World!</code> into the console.
 
Note: Script-specific symbols such as global variables (or functions) will be put into a scope (namespace) based on the script's name, scripts embedded via aircraft-set.xml files can separately specify a corresponding module name (see [[Howto: Make an aircraft]] for details).


<!--
Strings in Nasal can also use double quotes which support escaping:
Strings in Nasal can also use double quotes which support escaping:
<syntaxhighlight lang="nasal">
<syntaxhighlight lang="nasal">
Line 42: Line 41:


Nasal strings are always arrays of bytes (never characters: see the utf8 library if you want character-based equivalents of substr() et. al.). They can be indexed just like in C (although note that there is no nul termination -- get the length with size()):
Nasal strings are always arrays of bytes (never characters: see the utf8 library if you want character-based equivalents of substr() et. al.). They can be indexed just like in C (although note that there is no nul termination -- get the length with size()):
-->

Navigation menu