Modules

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Variable Definitions and Operations > MOD. - Modules >

Modules

MOD.New

Previous Top Next


MiniRobotLanguage (MRL)

 

MOD.New

Create a new named Module

 

 

Intention

 

What is a Module?

A module is a namespace of global variables. This means inside a module all variables that start with $$xxx have a dedicated value or are undefined.

Once you switch to another module all these variables may have other values and are defined or undefined as it may be in that module.

Generally modules are namespaces for variables and only for global variables.

These are all variables that start with the double dollar sign. Once you switch to a new module all these variables are whether empty or have that value that they have in that module.

 

Generally, you could use modules without namespaces and just switch to modules from number 0, which is the main module - it also has the name "main" -  where you are generally inside, up to number 255, which is the highest number that is currently supported for modules. Because generally it is easier to work with named modules, that's why you can create named modules and use module names instead of numbers.

 

What does this command?

This command will:

1. Create a new named module. In fact it will give the next module that has no name, a name.

Module names are internally stored in lower cases. No matter how you specify them or write them, they will always be converted to lower space names for easier usage.

If the module name already exists you will not get an error message.

Instead the command will just switch to that existing Module.

 

If you specify a number instead of a name then the robot will prefix the number with "Module_". This is necessary because alternatively to a module name you can also specify simply the module number in many commands,  and then you will also switch or do whatever with that module. Therefore, module names can never be pure numeric.

Module names can be used to switch between modules.

 

2. Switch to that Module

This command will not only create the new named module but it will also switch the current namespace to that module.

This means that all previously defined global variables will be invisible from that moment unless you switch back to the previous module.

 

 

 

Syntax

 

 

MOD.New|P1

 

 

Parameter Explanation

 

P1 - (Text) Is the name for the Module. There is no Limitation about length, it can even contain spaces (inside only).

                             The name is internally Lower cased, therefore all Module-names are internally in lowercase.

 

                             The command will leave the number of the new Module on the TOS.

 

 

 

Example

 

'***********************************

' MOD.New-Sample

'***********************************
$$VAA=In Main

PRT.$$VAA

' This will be created as Module 1

MOD.New|Left Side Module

$$VAA=In Module 1

PRT.$$VAA

MOD.New|Right Side Module

$$VAA=In Module 2

PRT.$$VAA

MOD.Enter|Left Side Module

PRT.$$VAA

MOD.Enter|Right Side Module

PRT.$$VAA

DMP.gv

MBX.Done

ENR.

 

 

 

 

 

Remarks

 

-

 

 

Limitations:

If you try to create more then 255 new Modules you will get this error.

 

clip0971

 

 

See also: