Hi fellow wiki editors!

To help newly registered users get more familiar with the wiki (and maybe older users too) there is now a {{Welcome to the wiki}} template. Have a look at it and feel free to add it to new users discussion pages (and perhaps your own).

I have tried to keep the template short, but meaningful. /Johan G

Difference between revisions of "Nasal Hello World"

From FlightGear wiki
Jump to: navigation, search
m (+canvas example)
 
Line 12: Line 12:
 
<syntaxhighlight lang="nasal">
 
<syntaxhighlight lang="nasal">
 
gui.popupTip("Hello, World!");
 
gui.popupTip("Hello, World!");
 +
</syntaxhighlight>
 +
 +
To use a [[Canvas]] GUI dialog, try the following:
 +
 +
 +
<syntaxhighlight lang="nasal">
 +
# create a new InputDialog with a title, label, and a callback
 +
canvas.InputDialog.getText("Hello World", "Please enter your name", func(btn,value) {
 +
    if (value) gui.popupTip("You entered: "~value);
 +
});
 
</syntaxhighlight>
 
</syntaxhighlight>
  

Latest revision as of 10:41, 12 January 2020


In the programming world, a "Hello, World!" program This is a link to a Wikipedia article 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):

print("Hello, World!");

This will print the string Hello, World! into the console.

To show a message inside the FlightGear window using a GUI tooltip instead, use the following snippet:

gui.popupTip("Hello, World!");

To use a Canvas GUI dialog, try the following:


# create a new InputDialog with a title, label, and a callback
canvas.InputDialog.getText("Hello World", "Please enter your name", func(btn,value) {
    if (value) gui.popupTip("You entered: "~value);
});