Nasal Hello World: Difference between revisions

Jump to navigation Jump to search
m
nothing much
m (Link to special directory articles)
m (nothing much)
Line 1: Line 1:
{{Nasal Navigation}}
{{Nasal Navigation}}


== Hello world ==


A simple hello world example in Nasal would be (to be saved in [[$FG_ROOT]]/Nasal):
A simple hello world example in Nasal would be (to be saved in [[$FG_ROOT]]/Nasal):


<syntaxhighlight lang="php">
<syntaxhighlight lang="php">
# [[$FG_ROOT]]/Nasal/hello.nas
# [[$FG_ROOT]]/Nasal/hello.nas
print('Hello World!');
print('Hello World!');
</syntaxhighlight>
</syntaxhighlight>


Line 17: Line 15:
Strings in Nasal can also use double quotes which support escaping:
Strings in Nasal can also use double quotes which support escaping:
<syntaxhighlight lang="php">
<syntaxhighlight lang="php">
# hello.nas
# hello.nas
print("Hello\nWorld!");
print("Hello\nWorld!");
</syntaxhighlight>
</syntaxhighlight>


Double quotes support typical escape sequences:
Double quotes support some of the typical escape sequences:


* \n Newline
* \n Newline
* \t Horizontal Tab
* \t Horizontal Tab
* \v Vertical Tab
* \b Backspace
* \r Carriage Return
* \r Carriage Return
* \f Form feed
* \a Audible Alert (bell)
* \\ Backslash
* \\ Backslash
* \? Question mark
* \' Single quote
* \" Double quote
* \" Double quote
* \x''yy''  Hexadecimal-specified character (yy stands for two hexadecimal digits; \x is literal)


For example, to print a new line, use:
For example, to print a new line, use:


print ("\n");
<syntaxhighlight lang="php">
print ("\n");
</syntaxhighlight>


To print a quoted string, use:
To print a quoted string, use:


print ("\"quoted string\"");
<syntaxhighlight lang="php">
print ("\"quoted string\"");
</syntaxhighlight>


and so on.
and so on.
395

edits

Navigation menu