Modules

<< Click to Display Table of Contents >>

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

Modules

MOD.Leave

Previous Top Next


MiniRobotLanguage (MRL)

 

MOD.Leave

Leave the current Module and delete all variables

 

 

Intention

 

The MOD.Leave command will leave the current module and delete all variables from that module.

It will only delete the variables, the module will not be deleted and therefore must not be recreated.

 

 

The MOD.Leave command can, for example, be used in sub-programs which you have been entered, used the variables and do not need them anymore. Then you can leave the sub-program with the LEAVE command. You leave the module and all the variables are deleted. So they do not more exist when you enter the sub-program the next time.

 
The leave command also knows which module you have been in before, we call it the "last module", and will generally switch the to this last module where you have been before.

 

There is something important to this.

If you have switched to other modules inside this module, then the last module may not be the module where you have been coming from.

Therefore the leave command will just remember one last module where you have been before.

 

That is why the MOD.Leave command has a second option, if you want to actively decide to which module you want to leave out of this current module,

you can add a parameter to the leave command and then the MOD.Leave|P1 command will exit the current module, delete all variables from the current module and switch to the specified module P1.

 

In complicated constructs you can remember the last module where you have been in a variable inside your module and use it with the leave command to exit to the right module.

 

 

$$VAA=In Main

PRT.$$VAA

MOD.New|Left

MOD.New|Right

MOD.New|Other

GSB.Test

MOD.Enter|Main

MOD.Get Last Name|$$KEP

GSB.Test

GSB.LeftSub

DMP.gv

GSB.Test

GSB.Rightsub

DMP.gv

GSB.Test

DMP.gv

MBX.!

ENR.

'-----------------------------------------------------------

:LeftSub

MOD.Enter|Left

MOD.Get Last Name|$$KEP

PRT.Left KEP1 is: $$KEP

GSB.Test

' Here we leave to the Module which we came from.

PRT.Left KEP2 is: $$KEP

MOD.Leave|$$KEP

RET.

'-----------------------------------------------------------

:Rightsub

MOD.Enter|Right

MOD.Get Last Name|$$KEP

PRT.Right KEP1 is: $$KEP

GSB.Test

' We remeber where we came from at the start here

' WE can now Switch Modes as we like

GSB.Othersub

PRT.Right KEP2 is: $$KEP

' Here we leave to the Module which we came from.

MOD.Leave|$$KEP

RET.

'-----------------------------------------------------------

:Othersub

MOD.Enter|Other

MOD.Get Last Name|$$KEP

PRT.Other KEP1 is: $$KEP

GSB.Test

PRT.Other KEP2 is: $$KEP

MOD.Leave|$$KEP

RET.

'-----------------------------------------------------------

:Test

MOD.Get Last Name|$$THI

PRT.We came from: $$THI

MOD.Get Name|$$CUR

PRT.We are here: $$CUR

RET.

'-----------------------------------------------------------

 

 

 

 

 

Syntax

 

 

MOD.Leave[|P1]

 

 

Parameter Explanation

 

P1 - (optional) Is the name or number of a Module where to switch after Leaving the current Module, and deleting all Variables of the current Module.

                                  If P1 is missing, means you do not give any parameter, then the MOD.Leave command will remember the last module where you have been before and switch to this module after leaving the current module.

 

 

 

Example

 

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

' MOD.Leave-Sample

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

PRT.$$VAA

 

MOD.New|Left Side Module

$$VAA=In Module 1

PRT.$$VAA

 

MOD.New|Right Side Module

$$VAA=In Module 2

PRT.$$VAA

 

' The following "MOD.Leave" will bring us back to Module 1 because we came from there

' Will also delete all Variables from Module 2

MOD.Leave

PRT.$$VAA

 

MOD.Enter|Right Side Module

PRT.Is empty: $$VAA

 

DMP.gv

MBX.Done

ENR.

 

clip0974

Output from the Script above. As you can see all Variables defined in Module 2 have been deleted using MOD.Leave.

 

 

 

Remarks

 

-

 

 

Limitations:

 

-

 

 

See also: