Difference between revisions of "Macro Constants"

From GiderosMobile
(added example + formatting)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
<languages />
 
 
<!-- GIDEROSOBJ:Macro Constants -->
 
<!-- GIDEROSOBJ:Macro Constants -->
 
'''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]]<br/>
 
'''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]]<br/>
 
'''<translate>Available since</translate>:''' Gideros 2017.10<br/>
 
'''<translate>Available since</translate>:''' Gideros 2017.10<br/>
 +
 
=== <translate>Description</translate> ===
 
=== <translate>Description</translate> ===
<translate><br />
+
Macro Constants can be used for string and numeric constants.
Macro Constants can be used for string and numeric constants.<br /><br />
+
 
 +
Just use @ rather than = when defining the macro.
 +
 
 +
You can use any of these delimiters after @ but they must be used in pairs.  Numbers are auto-detected.
  
Just use @ rather than = when defining the macro.<br /><br />
+
'''\`~ ! # $ % ^ & * / + = |'''
  
You can use any of these delimiters after @ but they must be used in pairs.  Numbers are auto-detected.<br />
 
\`~ ! # $ % ^ & * / + = |<br /></translate>
 
 
=== <translate>Examples</translate> ===
 
=== <translate>Examples</translate> ===
'''Simple examples'''<br/>
+
'''Simple examples'''
<source lang="lua">  
+
<source lang="lua">
 +
num1 @ &2^0&
 +
num2 @ &2^1&
 +
num3 @ &num1 + num2&
 +
 
 
pi@3.14159265358979324
 
pi@3.14159265358979324
num1 @ -100.54
+
num4 @ -100.54
num2 @ 232
+
num5 @ 232
num3 @ 444.10
+
num6 @ 444.10
 
str1 @ 'hello'
 
str1 @ 'hello'
 
str2 @ "world"
 
str2 @ "world"
Line 24: Line 29:
 
Hello,
 
Hello,
 
world!
 
world!
]]</source>
+
]]
'''Commenting out the print command'''<br/>
+
</source>
<source lang="lua">  
+
 
 +
'''Commenting out the print command'''
 +
<source lang="lua">
 
print @ |--|
 
print @ |--|
  
print(x, y, z, x + y, y * z) -- this line will be skipped</source>
+
print(x, y, z, x + y, y * z) -- this line will be skipped
 +
</source>
 +
 
 
{|-
 
{|-
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|

Revision as of 22:38, 15 August 2020

Supported platforms: Platform android.pngPlatform ios.pngPlatform mac.pngPlatform pc.png
Available since: Gideros 2017.10

Description

Macro Constants can be used for string and numeric constants.

Just use @ rather than = when defining the macro.

You can use any of these delimiters after @ but they must be used in pairs. Numbers are auto-detected.

\`~ ! # $ % ^ & * / + = |

Examples

Simple examples

num1 @ &2^0&
num2 @ &2^1&
num3 @ &num1 + num2&

pi@3.14159265358979324
num4 @ -100.54
num5 @ 232
num6 @ 444.10
str1 @ 'hello'
str2 @ "world"
str3 @ [[
Hello,
world!
]]

Commenting out the print command

print @ |--|

print(x, y, z, x + y, y * z) -- this line will be skipped

Methods

Events

Constants