Variables in Monkeyspeak are defined with

This can be optional through MonkeyspeakEngine.Options see GettingStarted

Variables must be assigned to a Monkeyspeak.Page to be used.
This is one way of how you can assign a variable
Monkeyspeak.Variable var = page.SetVariable("%testVariable", "Hello World");
You can also create a variable object and then add it to a Page.
Monkeyspeak.Variable var = new Monkeyspeak.Variable("%testVariable", "Hello World");
You do not need to add the % on the front so this would also create a %testVariable variable
Monkeyspeak.Variable var = page.SetVariable("testVariable", "Hello World");

Constant Variables

Variables that are declared Constant can only be modified through page.SetVariable. Otherwise trying to assign a value to a Constant Variable will throw a exception.

page.SetVariable has a optional parameter to set the Variable returned as Constant.
If I want to make a Constant Variable I would set the third parameter to true.
Monkeyspeak.Variable var = page.SetVariable("%testVariable", "Hello World", isConstant:true);
Now to check if a Variable is Constant you would check the Variable's IsConstant property
if (var.IsConstant)
   Console.WriteLine(var.Name + " is constant!");

Last edited Jun 20, 2012 at 9:34 PM by Squizzle, version 8


No comments yet.