Renaming Variables

Movicon has a function which consents to updating all the references to variables in projects automatically when they are renamed. This means that when a variable is renamed you will not need to go and replace the old name with the new one in the various points of the project where the variable has been used.

 

The automatic replacement mechanism is active only if the project execution property "Enable Renaming Manager" is enabled. If not, all the aliasing mechanism as described below will not work and the renamed variables should be replaced manually where used in the project.

 

Movicon uses an 'aliasing'  mechanism which keeps track of the variable's original name and its new one.  When the variable is remained many times, only the first and last name is tracked down. This information, consisting of the relationship between the variable's original name and the last one associated, is contained in the  ".movrealtimedb"  file with the <RenamedVariables> tag, as shown below:

 

...

<RenamedVariables>

<item key="VAR00001" value="VAR00002"/>

<item key="VAR00003" value="VAR00006"/>

<item key="VAR00004" value="VAR00007"/>

</RenamedVariables>

...

 

where:

 

item key: represents the variable's original name

value: represents the last name used for renaming the variable

 

If the Renaming Manager has been enabled, it is recommended not to use the original names of the renamed variables to create new variables. When trying doing so, Movicon shows an advice message as the following:

 

Warning! The variable Name 'VAR00001' has been renamed to 'VAR00002' in this project. Do you want to use this variable name? Answering "Yes" will remove the recorded renamed link.

 

Warning! The 'Screen1' resource name have been renamed in 'Screen2' in this project.  Do you wish to use the same resource name? If you ask with 'Yes? the saved rename link will be removed.

 

The message above has been generated since you tried to create or rename a variable using the "VAR00001" as new name, which has already been used as original name for the variable renamed "VAR00002". Answering "Yes" to the message box, the link "original name - new name" will be deleted and the automatic replacing mechanism will be cancelled for that variable.

As an example, if "VAR00001" has been associated to a display object, then "VAR00001" is renamed as "VAR00002", the display object will result associated to "VAR00002". The RealTimeDB will contain only one variable, that is "VAR00002". If later a new variable is added to the database using "VAR00001" as new name, the renaming link will be deleted and the display object will result associated to "VAR00001", being VAR00001 a new variable. Both VAR00001 and VAR00002 will be present in the RealTimeDB, being two different variables.

 

When insert a new variable Movicon will propose a name which has not yet been used in the RealTimeDB and which has not yet been used as a original name of a variable which has already been renamed. If, for instance, you insert the VAR00001 and then rename it to VAR00002,  when inserting a new variable Movicon will propose VAR00003 as its name.

When a variable is renamed, any retentivity file belonging to the variable will not get automatically renamed and as a result this variable will have a "0" value at the project startup and the first modification to this variable will create a new retentivity file with the variable's new name.

 

WARNING! The aliasing mechanism can be cancelled deleting from the".movrealtimedb" file the xml tags listing the renamed variables. This way the renamed variables will keep their last name, while the references added for example to objects or commands will be linked to the variables original names. As a result, the reference to original variables could be invalid.

 

The automatic variable aliasing works according to  the object or resource in question:

 

 

Applying Renamed Variables Permanently

You can apply the new names of renamed resources permanently (screens, basic scripts, menu and shortcuts) by using the "Apply Renamed Variables and  Resources" command from the "Edit" and "View" menus or by using the "Apply New Name" command from the variable's resources' context menus.  In this case, a search will take place in all the project resources and objects to replace all the variable old names with the new one and the renamed variable in the ".movrealtimedb" file will be deleted.  However, this will eliminate the Aliasing mechanismn for this variable.  

A request to activate this command will also appear when the option for renaming variables and resources management has been disabled.  

 

This  command also replaces the names of the variables resources used within basic script code of objects or basic script resources.

Comments are also inserted in the code to indicate where the replacement was made:

 

''Var1' variable replaced with new 'Var2' name'

 

 

'Criteria for replacing Variables in Basic Script Code

When activating the command for applying new names of variables the parser will only replace the text of corresponding renamed variables with their new names when found in the basic script code  if one of the following rules applies:

 

 

The "BasicKeywords.xml" external file consents you to define key word lists used while replacing variables in basic script code.  The "BasicKeywords.xml"  file structure is as follows:

 

<?xml version="1.0" encoding="iso-8859-1"?>

<BasicKeywordsList>

<Key>If</Key>

<Key>ElseIf</Key>

<Key>Select Case</Key>

<Key>Loop Until</Key>

<Key>Loop While</Key>

<Key>While</Key>

</BasicKeywordsList>

 

Communication Drivers

A new item called "Renaming Manager" has been added to the list of communication driver features which consents you to find out whether the driver supports the renaming management or not.  Those Drivers which support the remaining management have this option set at 'true' will display those variables with names modified within their configuration window; and will also support  the apply renaming command.  

 

 

See Also