A minimal example of a DSL command to move a player piece.

ID: 1385

				
					using uCalcSoftware;

var uc = new uCalc();
uc.DefineVariable("player1_position = 0");

// Define a rule to translate the MOVE command
var t = uc.ExpressionTransformer;
t.FromTo("PLAYER {@Number:p} MOVES {@Number:n} SPACES", "player{p}_position = player{p}_position + {n}");

// Execute a single command
uc.EvalStr("PLAYER 1 MOVES 5 SPACES");

Console.WriteLine($"Player 1 is now at position: {uc.EvalStr("player1_position")}");
				
			
Player 1 is now at position: 5
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   uc.DefineVariable("player1_position = 0");

   // Define a rule to translate the MOVE command
   auto t = uc.ExpressionTransformer();
   t.FromTo("PLAYER {@Number:p} MOVES {@Number:n} SPACES", "player{p}_position = player{p}_position + {n}");

   // Execute a single command
   uc.EvalStr("PLAYER 1 MOVES 5 SPACES");

   cout << "Player 1 is now at position: " << uc.EvalStr("player1_position") << endl;
}
				
			
Player 1 is now at position: 5
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      uc.DefineVariable("player1_position = 0")
      
      '// Define a rule to translate the MOVE command
      Dim t = uc.ExpressionTransformer
      t.FromTo("PLAYER {@Number:p} MOVES {@Number:n} SPACES", "player{p}_position = player{p}_position + {n}")
      
      '// Execute a single command
      uc.EvalStr("PLAYER 1 MOVES 5 SPACES")
      
      Console.WriteLine($"Player 1 is now at position: {uc.EvalStr("player1_position")}")
   End Sub
End Module
				
			
Player 1 is now at position: 5