Difference between revisions of "Logic Syntax"

From AGI Wiki
Jump to navigationJump to search
 
(19 intermediate revisions by the same user not shown)
Line 1: Line 1:
This article describes the '''logic syntax''' for the C-like "official" AGI syntax described in the [[AGI Specs|AGI Specs]] and supported by [[AGI Studio|AGI Studio]] and [[WinAGI|WinAGI]].
+
[[Tutorials and Guides|Tutorials and Guides Table of Contents]]<br />
 +
 
 +
<div align="center"><span style="font-size: 22pt">Logic Syntax</span><!-- <br />
 +
''By '' --></div>
  
'''Note:''' The [[WinAGI|WinAGI]] development environment supports an [[VB Logic Syntax|alternate syntax]], that is based on Microsoft's Visual Basic language, rather than the C language. At this time, the C-based syntax described in this article is the most widely-supported AGI logic syntax.
+
&nbsp;
  
 
This article describes the '''logic syntax''' for the C-like "official" AGI syntax described in the [[AGI Specs|AGI Specs]] and supported by [[AGI Studio|AGI Studio]] and [[WinAGI|WinAGI]].
 
This article describes the '''logic syntax''' for the C-like "official" AGI syntax described in the [[AGI Specs|AGI Specs]] and supported by [[AGI Studio|AGI Studio]] and [[WinAGI|WinAGI]].
Line 170: Line 173:
 
|[[Message|Message]]|| m
 
|[[Message|Message]]|| m
 
|-
 
|-
|[[Animated object|Object]]|| o
+
|[[Animated Object|Object]]|| o
 
|-
 
|-
 
|[[Inventory item|Inventory item]]|| i
 
|[[Inventory item|Inventory item]]|| i
Line 196: Line 199:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
For a complete list of the commands and their argument types, see [[Logic commands by name|Logic commands by name]].
+
For a complete list of the commands and their argument types, see [[Logic Commands by Name|Logic commands by name]].
  
 
Messages and inventory items may be given in either numerical or text format:
 
Messages and inventory items may be given in either numerical or text format:
Line 253: Line 256:
  
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockHeader">Code:</div>
<div class="CodeBlockStyle">
 
 
<syntaxhighlight lang="agi">
 
<syntaxhighlight lang="agi">
 
Label1:
 
Label1:
</syntaxhighlight></div>
+
</syntaxhighlight>
  
 
The label name can contain letters, numbers, and the characters '_' and '.'. No spaces are allowed.
 
The label name can contain letters, numbers, and the characters '_' and '.'. No spaces are allowed.
  
The [[Goto|Goto]] command takes on parameter, the name of a label:
+
The [[goto|goto]] command takes on parameter, the name of a label:
  
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockHeader">Code:</div>
<div class="CodeBlockStyle">
 
 
<syntaxhighlight lang="agi">
 
<syntaxhighlight lang="agi">
 
goto(Label1);
 
goto(Label1);
</syntaxhighlight></div>
+
</syntaxhighlight>
  
 
== Comments ==
 
== Comments ==
Line 273: Line 274:
  
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockHeader">Code:</div>
<div class="CodeBlockStyle">
 
 
<syntaxhighlight lang="agi">
 
<syntaxhighlight lang="agi">
 
// - rest of line is ignored
 
// - rest of line is ignored
Line 280: Line 280:
  
 
/* Text between these are ignored */
 
/* Text between these are ignored */
</syntaxhighlight></div>
+
</syntaxhighlight>
 
 
 
The /*...*/ can be nested:
 
The /*...*/ can be nested:
  
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockHeader">Code:</div>
<div class="CodeBlockStyle">
 
 
<syntaxhighlight lang="agi">
 
<syntaxhighlight lang="agi">
 
/* comment start
 
/* comment start
Line 300: Line 298:
  
 
*/                  // uncomments
 
*/                  // uncomments
</syntaxhighlight></div>
+
</syntaxhighlight>
  
 
'''Note:''' the fact that these comments can be nested is very different from almost every other language that uses these types of comments, including C, C , and Java.
 
'''Note:''' the fact that these comments can be nested is very different from almost every other language that uses these types of comments, including C, C , and Java.
Line 317: Line 315:
  
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockHeader">Code:</div>
<div class="CodeBlockStyle">
 
 
<syntaxhighlight lang="agi">
 
<syntaxhighlight lang="agi">
 
#message 4 "You can't do that now."
 
#message 4 "You can't do that now."
</syntaxhighlight></div>
+
</syntaxhighlight>
  
 
Then you can give the message number as the parameter in commands:
 
Then you can give the message number as the parameter in commands:
  
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockHeader">Code:</div>
<div class="CodeBlockStyle">
 
 
<syntaxhighlight lang="agi">
 
<syntaxhighlight lang="agi">
 
print(m4);
 
print(m4);
</syntaxhighlight></div>
+
</syntaxhighlight>
  
 
Or embed the message in commands as normal and the number you assigned to it before will be used:
 
Or embed the message in commands as normal and the number you assigned to it before will be used:
  
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockHeader">Code:</div>
<div class="CodeBlockStyle">
 
 
<syntaxhighlight lang="agi">
 
<syntaxhighlight lang="agi">
 
print("You can't do that now.");
 
print("You can't do that now.");
</syntaxhighlight></div>
+
</syntaxhighlight>
  
<nowiki>#message can be used anywhere in the file, so you do not have to set the message before you use it. </nowiki>
+
<nowiki>#message can be used anywhere in the file, so you do not have to set the message before you use it.</nowiki>
  
 
For more details, see [[Message|Message]].
 
For more details, see [[Message|Message]].
Line 344: Line 339:
 
== The <code>return</code> command ==
 
== The <code>return</code> command ==
  
The [[Return|return]] command is just a normal action command (command number 0), with no arguments. This must be the last command in every [[Logic|logic resource]}.
+
The [[Return|return]] command is just a normal action command (command number 0), with no arguments. This must be the last command in every [[Logic Resource|logic resource]].
  
 
== See also ==
 
== See also ==
Line 352: Line 347:
 
== Sources ==
 
== Sources ==
  
* [[AGI Studio|AGI Studio]] help file
+
* [[agi:AGIStudioHelp|AGI Studio Help File]]
 
 
== If structures and test commands ==
 
 
 
An if structure looks like this:
 
 
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockStyle">
 
if (test commands) {
 
  action commands
 
}
 
</syntaxhighlight></div>
 
 
 
or like this
 
 
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockStyle">
 
if (test commands) {
 
  action commands
 
}
 
else {
 
  more action commands
 
}
 
</syntaxhighlight></div>
 
 
 
Carriage returns are not necessary:
 
 
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockStyle">
 
if (test commands) { action Commands } else { more action commands }
 
</syntaxhighlight></div>
 
 
 
 
 
Test commands are coded like action commands except there is no semicolon. They are separated by <code>&&</code> or <code>||</code> for AND and OR, respectively:
 
 
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockStyle">
 
if (isset(f5) &&
 
    greatern(v5,6)) { ......
 
</syntaxhighlight></div>
 
 
 
Again, carriage returns are not necessary within the if statement:
 
 
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockStyle">
 
if (lessn(v5,6) && (greatern(v5,2)) { .......
 
 
 
if (isset(f90) && equalv(v32,v34) &&
 
    greatern(v34,20)) { .......
 
</syntaxhighlight></div>
 
 
 
A&nbsp;! placed in front of a command signifies a NOT.
 
 
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockStyle">
 
if (!isset(f7)) {
 
  ......
 
</syntaxhighlight></div>
 
 
 
Boolean expressions are not necessarily simplified so they must follow the rules set down by the file format. If test commands are to be ORred together, they must be placed in brackets.
 
 
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockStyle">
 
if ((isset(f1) || isset(f2)) {
 
  ......
 
 
 
if (isset(f1) && (isset(f2) || isset(f3))) {
 
  ......
 
 
 
if (isset(1) || (isset(2) && isset(3))) {    is NOT legal
 
</syntaxhighlight></div>
 
 
 
Depending on the compiler, simplification of boolean expressions may be supported, so the above may not apply in all cases (although if these are rules are followed then the logic will work with all compilers).
 
 
 
Substitutions for the following test commands are available:
 
 
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockStyle">
 
equaln(v30,4)      v30 == 4
 
equalv(v30,v32)    v30 == v32
 
greatern(v30,4)    v30  4
 
greaterv(v30,v32)  v30  v32
 
lessn(v30,4)      v30  4
 
lessv(v30,v32)    v30  v32
 
!equaln(v30,4)    v30&nbsp;!= 4
 
!equalv(v30,v32)  v30&nbsp;!= v32
 
!greatern(v30,4)  v30 = 4
 
!greaterv(v30,v32) v30 = v32
 
!lessn(v30,4)      v30 = 4
 
!lessv(v30,v32)    v30 = v32
 
</syntaxhighlight></div>
 
 
 
Also, flags can be tested for by just using the name of the flag:
 
 
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockStyle">
 
if (f6) { .....
 
 
 
if (v7 > 0 && !f6) { .....
 
</syntaxhighlight></div>
 
  
which is equivalent to:
+
&nbsp;
  
<div class="CodeBlockHeader">Code:</div>
+
[[Tutorials and Guides|Tutorials and Guides Table of Contents]]
<div class="CodeBlockStyle">
 
if (isset(f6)) { .....
 
  
if (v7 > 0 && !isset(f6)) { .....
+
&nbsp;
</syntaxhighlight></div>
 
 
 
== Argument types ==
 
 
 
There are 9 different types of arguments that commands use:
 
 
 
{| border="1" cellpadding="5"
 
! Type
 
! Prefix
 
|-
 
| Number
 
| (no prefix)
 
|-
 
|
 
[[Variable|Variable]]
 
| v
 
|-
 
|
 
[[Flag|Flag]]
 
| f
 
|-
 
|
 
[[Message|Message]]
 
| m
 
|-
 
|
 
[[Animated object|Object]]
 
| o
 
|-
 
|
 
[[Inventory item|Inventory item]]
 
| i
 
|-
 
|
 
[[String|String]]
 
| s
 
|-
 
|
 
[[Word|Word]]
 
| w
 
|-
 
|
 
[[Controller|Controller]]
 
| c
 
|}
 
 
 
The [[Said|said]] test command uses its own special arguments which will be described later.
 
 
 
Each of these types of arguments is given by the prefix and then a number from 0-255, e.g. <code>v5</code>, <code>f6</code>, <code>m27</code>, <code>o2</code>.
 
 
 
The word type represents words that the player has typed in (as opposed to words that are stored in the [[WORDS.TOK|WORDS.TOK]] file). Strings are the temporary string variables stored in memory, not to be confused with messages (that are stored in the logic resources). Controllers are menu items and keys.
 
 
 
Compilers can enforce type checking, so that the programmer must use the correct prefix for an argument so that they know they are using the right type. Decoders should display arguments with the right type.
 
 
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockStyle">
 
move.obj(o4, 80, 120, 2, f66);
 
 
 
if (obj.in.box(o2, 30, 60, 120, 40)) { .....
 
</syntaxhighlight></div>
 
 
 
For a complete list of the commands and their argument types, see [[Logic commands by name|Logic commands by name]].
 
 
 
Messages and inventory items may be given in either numerical or text format:
 
 
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockStyle">
 
print("He's not here.");
 
 
 
print(m12);
 
 
 
if (has("Jetpack")) { .....
 
 
 
if (has(i9)) { .....
 
 
 
</syntaxhighlight></div>
 
Messages can also be split over multiple lines:
 
 
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockStyle">
 
print("This message is split "
 
      "over multiple lines.");
 
</syntaxhighlight></div>
 
 
 
Quote marks must be used around messages and inventory item names. This is important because some messages or inventory item names may contain parentheses or commas, which could confuse the compiler. This is also the case for the said command which will be described shortly.
 
 
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockStyle">
 
if (has("Buckazoid(s)")) { .....  // no ambiguity here about where
 
                                  // the argument ends
 
</syntaxhighlight></div>
 
 
 
If quote marks are part of the message or inventory object, a \ should be placed in front of these. To use a \, \\ should be used. \n can also be used for a new line.
 
 
 
The said test command uses different parameters to all the other commands. Where as the others use 8 bit arguments (0-255), said takes 16 bit arguments (0-65535). Also, the number of arguments in a said command can vary. The numbers given in the arguments are the word group numbers from the WORDS.TOK file.
 
 
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockStyle">
 
if (said(4, 80)) { .....
 
</syntaxhighlight></div>
 
 
 
Words can also be given in place of the numbers:
 
 
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockStyle">
 
if (said("look")) { .....
 
 
 
if (said("open","door")) { .....
 
</syntaxhighlight></div>
 
 
 
Quote marks must also be used around the words.
 
 
 
== Labels and the <code>goto</code> command ==
 
 
 
Labels are given like this:
 
 
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockStyle">
 
Label1:
 
</syntaxhighlight></div>
 
 
 
The label name can contain letters, numbers, and the characters '_' and '.'. No spaces are allowed.
 
 
 
The [[Goto|Goto]] command takes on parameter, the name of a label:
 
 
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockStyle">
 
goto(Label1);
 
</syntaxhighlight></div>
 
 
 
== Comments ==
 
 
 
There are three ways that comments can be used.
 
 
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockStyle">
 
// - rest of line is ignored
 
 
 
[ - rest of line is ignored
 
 
 
/* Text between these are ignored */
 
</syntaxhighlight></div>
 
 
 
The /*...*/ can be nested:
 
 
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockStyle">
 
/* comment start
 
 
 
  print("Hello");    // won't be run
 
 
 
  /*                // a new comment start (will be ignored!)
 
 
 
    v32 = 15;        // won't be run
 
 
 
  */                // uncomments the most inner comment
 
 
 
  print("Hey!");    // won't be run, still inside comments
 
 
 
*/                  // uncomments
 
</syntaxhighlight></div>
 
 
 
'''Note:''' the fact that these comments can be nested is very different from almost every other language that uses these types of comments, including C, C , and Java.
 
 
 
== Defines ==
 
 
 
See [[Defines|Defines]].
 
 
 
== Including files ==
 
 
 
See [[Includes|Includes]].
 
 
 
== More on messages ==
 
 
 
In some cases you may want to assign a specific number to a message so you can refer to it in other places. This is done by using the #message command, followed by the number of the message then the message itself:
 
 
 
<div class="CodeBlockHeader">Code:</div>
 
<syntaxhighlight lang="agi">
 
#message 4 "You can't do that now."
 
</syntaxhighlight>
 
 
 
Then you can give the message number as the parameter in commands:
 
 
 
<div class="CodeBlockHeader">Code:</div>
 
<syntaxhighlight lang="agi">
 
print(m4);
 
</syntaxhighlight>
 
 
 
Or embed the message in commands as normal and the number you assigned to it before will be used:
 
 
 
<div class="CodeBlockHeader">Code:</div>
 
<syntaxhighlight lang="agi">
 
print("You can't do that now.");
 
</syntaxhighlight>
 
 
 
<nowiki>#message can be used anywhere in the file, so you do not have to set the message before you use it. </nowiki>
 
 
 
For more details, see [[Message|Message]].
 
 
 
== The <code>return</code> command ==
 
 
 
The [[Return|return]] command is just a normal action command (command number 0), with no arguments. This must be the last command in every [[Logic|logic resource]}.
 
 
 
== See also ==
 
 
 
* [[Logic language|Logic language]]
 
 
 
== Sources ==
 
  
* [[AGI Studio|AGI Studio]] help file
+
[[Category:AGI Logic]]
 +
[[Category:Variables]]
 +
[[Category:Syntax]]

Latest revision as of 13:59, 30 January 2024

Tutorials and Guides Table of Contents

Logic Syntax

 

This article describes the logic syntax for the C-like "official" AGI syntax described in the AGI Specs and supported by AGI Studio and WinAGI.

Note: The WinAGI development environment supports an alternate syntax, that is based on Microsoft's Visual Basic language, rather than the C language. At this time, the C-based syntax described in this article is the most widely-supported AGI logic syntax.

Action Commands

Normal action commands are specified by the command name followed by parentheses which contain the arguments, separated by commas. A semicolon is placed after the parentheses. The parentheses are required even if there are no arguments. The arguments given must have the correct prefix for that type of argument as explained later in this document (this is to make sure the programmer does not use a variable, for example, when they think they are using a flag).

Code:

<syntaxhighlight lang="agi"> assign.v(v50,0);

program.control(); </syntaxhighlight>

Multiple commands may be placed on the one line:

Code:

<syntaxhighlight lang="agi"> reset(f6); reset(f7); </syntaxhighlight>

Substitutions for the following action commands are available:

Code:

<syntaxhighlight lang="agi"> increment(v30); v30++; decrement(v30); v30--; assignn(v30,4); v30 = 4; assignv(v30,v32); v30 = v32; addn(v30,4); v30 = v30 + 4; or v30 += 4; addv(v30,v32); v30 = v30 + v32; or v30 += v32; subn(v30,4); v30 = v30 - 4; or v30 -= 4; subv(v30,v32); v30 = v30 - v32; or v30 -= v32; mul.n(v30,4); v30 = v30 * 4; or v30 *= 4; mul.v(v30,v32); v30 = v30 * v32; or v30 *= v32; div.n(v30,4); v30 = v30 / 4; or v30 /= 4; div.v(v30,v32); v30 = v30 / v32; or v30 /= v32;

lindirectn(v30,4); *v30 = 4; lindirectv(v30,v32); *v30 = v32; rindirect(v30,v32); v30 = *v32; </syntaxhighlight>

If structures and test commands

An if structure looks like this:

Code:

<syntaxhighlight lang="agi"> if (test commands) {

 action commands

} </syntaxhighlight>

or like this

Code:

<syntaxhighlight lang="agi"> if (test commands) {

 action commands

} else {

 more action commands

} </syntaxhighlight>

Carriage returns are not necessary:

Code:

<syntaxhighlight lang="agi"> if (test commands) { action Commands } else { more action commands } </syntaxhighlight>


Test commands are coded like action commands except there is no semicolon. They are separated by && or || for AND and OR, respectively:

Code:

<syntaxhighlight lang="agi"> if (isset(f5) &&

   greatern(v5,6)) { ......

</syntaxhighlight>

Again, carriage returns are not necessary within the if statement:

Code:

<syntaxhighlight lang="agi"> if (lessn(v5,6) && (greatern(v5,2)) { .......

if (isset(f90) && equalv(v32,v34) &&

   greatern(v34,20)) { .......

</syntaxhighlight>

A ! placed in front of a command signifies a NOT.

Code:

<syntaxhighlight lang="agi"> if (!isset(f7)) {

 ......

</syntaxhighlight>

Boolean expressions are not necessarily simplified so they must follow the rules set down by the file format. If test commands are to be ORred together, they must be placed in brackets.

Code:

<syntaxhighlight lang="agi"> if ((isset(f1) || isset(f2)) {

 ......

if (isset(f1) && (isset(f2) || isset(f3))) {

 ......

if (isset(1) || (isset(2) && isset(3))) { is NOT legal </syntaxhighlight>

Depending on the compiler, simplification of boolean expressions may be supported, so the above may not apply in all cases (although if these are rules are followed then the logic will work with all compilers).

Substitutions for the following test commands are available:

Code:

<syntaxhighlight lang="agi"> equaln(v30,4) v30 == 4 equalv(v30,v32) v30 == v32 greatern(v30,4) v30 4 greaterv(v30,v32) v30 v32 lessn(v30,4) v30 4 lessv(v30,v32) v30 v32 !equaln(v30,4) v30 != 4 !equalv(v30,v32) v30 != v32 !greatern(v30,4) v30 = 4 !greaterv(v30,v32) v30 = v32 !lessn(v30,4) v30 = 4 !lessv(v30,v32) v30 = v32 </syntaxhighlight>

Also, flags can be tested for by just using the name of the flag:

Code:

<syntaxhighlight lang="agi"> if (f6) { .....

if (v7 > 0 && !f6) { ..... </syntaxhighlight>

which is equivalent to:

Code:

<syntaxhighlight lang="agi"> if (isset(f6)) { .....

if (v7 > 0 && !isset(f6)) { ..... </syntaxhighlight>

Argument types

There are 9 different types of arguments that commands use:

Type Prefix
Number (no prefix)
Variable v
Flag f
Message m
Object o
Inventory item i
String s
Word w
Controller c

The said test command uses its own special arguments which will be described later.

Each of these types of arguments is given by the prefix and then a number from 0-255, e.g. v5, f6, m27, o2.

The word type represents words that the player has typed in (as opposed to words that are stored in the WORDS.TOK file). Strings are the temporary string variables stored in memory, not to be confused with messages (that are stored in the logic resources). Controllers are menu items and keys.

Compilers can enforce type checking, so that the programmer must use the correct prefix for an argument so that they know they are using the right type. Decoders should display arguments with the right type.

Code:

<syntaxhighlight lang="agi"> move.obj(o4, 80, 120, 2, f66);

if (obj.in.box(o2, 30, 60, 120, 40)) { ..... </syntaxhighlight>

For a complete list of the commands and their argument types, see Logic commands by name.

Messages and inventory items may be given in either numerical or text format:

Code:

<syntaxhighlight lang="agi"> print("He's not here.");

print(m12);

if (has("Jetpack")) { .....

if (has(i9)) { .....

</syntaxhighlight>

Messages can also be split over multiple lines:

Code:

<syntaxhighlight lang="agi"> print("This message is split "

     "over multiple lines.");

</syntaxhighlight>

Quote marks must be used around messages and inventory item names. This is important because some messages or inventory item names may contain parentheses or commas, which could confuse the compiler. This is also the case for the said command which will be described shortly.

Code:

<syntaxhighlight lang="agi"> if (has("Buckazoid(s)")) { ..... // no ambiguity here about where

                                  // the argument ends

</syntaxhighlight>

If quote marks are part of the message or inventory object, a \ should be placed in front of these. To use a \, \\ should be used. \n can also be used for a new line.

The said test command uses different parameters to all the other commands. Where as the others use 8 bit arguments (0-255), said takes 16 bit arguments (0-65535). Also, the number of arguments in a said command can vary. The numbers given in the arguments are the word group numbers from the WORDS.TOK file.

Code:

<syntaxhighlight lang="agi"> if (said(4, 80)) { ..... </syntaxhighlight>

Words can also be given in place of the numbers:

Code:

<syntaxhighlight lang="agi"> if (said("look")) { .....

if (said("open","door")) { ..... </syntaxhighlight>

Quote marks must also be used around the words.

Labels and the goto command

Labels are given like this:

Code:

<syntaxhighlight lang="agi"> Label1: </syntaxhighlight>

The label name can contain letters, numbers, and the characters '_' and '.'. No spaces are allowed.

The goto command takes on parameter, the name of a label:

Code:

<syntaxhighlight lang="agi"> goto(Label1); </syntaxhighlight>

Comments

There are three ways that comments can be used.

Code:

<syntaxhighlight lang="agi"> // - rest of line is ignored

[ - rest of line is ignored

/* Text between these are ignored */ </syntaxhighlight> The /*...*/ can be nested:

Code:

<syntaxhighlight lang="agi"> /* comment start

 print("Hello");    // won't be run
 /*                 // a new comment start (will be ignored!)
   v32 = 15;        // won't be run
 */                 // uncomments the most inner comment
 print("Hey!");     // won't be run, still inside comments
  • / // uncomments

</syntaxhighlight>

Note: the fact that these comments can be nested is very different from almost every other language that uses these types of comments, including C, C , and Java.

Defines

See Defines.

Including files

See Includes.

More on messages

In some cases you may want to assign a specific number to a message so you can refer to it in other places. This is done by using the #message command, followed by the number of the message then the message itself:

Code:

<syntaxhighlight lang="agi">

  1. message 4 "You can't do that now."

</syntaxhighlight>

Then you can give the message number as the parameter in commands:

Code:

<syntaxhighlight lang="agi"> print(m4); </syntaxhighlight>

Or embed the message in commands as normal and the number you assigned to it before will be used:

Code:

<syntaxhighlight lang="agi"> print("You can't do that now."); </syntaxhighlight>

#message can be used anywhere in the file, so you do not have to set the message before you use it.

For more details, see Message.

The return command

The return command is just a normal action command (command number 0), with no arguments. This must be the last command in every logic resource.

See also

Sources

 

Tutorials and Guides Table of Contents