VARIABLE LOG CONTROL (VC)
RECEIVER

Used to log flags, variables, timers, functions (FU) and loops( DO) used in the script.

It can save the log to an external file: ERMVarsUsed.LOG for further use.
Attention: This receiver should be used as an instruction (!#VC:...) syntax otherwise it does not make sense.

!#VC:XXXX; Variable Control


OPTIONS

Commands with variable control

B; Start logging used ERM variables
C; Clear the list of used ERM variables
E; Stop logging used ERM variables
N; Stop a cross-reference checking section
Y; Start a cross-reference checking section
W; Write log to "ERMVarsUsed.log" file


Comments.

Please note that the logging and saving to file operations are launched only when the ERM compiler executes these commands, this meaning during the wogification process of the map, before day 1. So you still have to launch the game and start a map in order to log your variables, functions and so on, from your script(s).

You have to always use B and E in pairs. You can use B and E command more than one time to control different parts of script. The effect will be summed up.

Example: The v10 and v12 variables will be logged, and v11 skipped:
!#VC:CB; clear list, start logging
!!VRv10:...;
using variable v10
!#VC:E;
stop logging
!!VRv11:...;
using variable v11
!#VC:B;
start logging
!!VRv12:...;
using variable v12
!#VC:EWC; stop logging, writing log to ERMVarsUsed.LOG file, clear list
As you have seen above, it is indicated to clear the list (C) before starting to log the first time, and when finished with all log operations.

You can also use more than one Y and N sections.
Example:
!#VC:CB;
!!VRv10:...;
!!VRv11:...;
!#VC:Y;
!!VRv11:...;
!!VRv12:...;
!#VC:N;
!!VRv12:...;
!!VRv14:...;
!#VC:Y;
!!VRv14:...;
!#VC:N;
!!VRv13:...;
!#VC:EWC;

The next vars will be signed as cross referenced: v11 and v14;
and not cross-referenced: v10,v12,v13
(v12 is not cross-referenced because it was not used before checking)

The VC instruction allows you to log these types of elements:
1. flags : 1...1000
2. v vars: v1...v10000
3. w vars: w1...w100
4. z vars: z1...z1000
All marked with:
- 'p' if used as a parameter;
- '&' if used in & condition section;
- '|' if used in | condition section;
- '*' if cross-referenced;
5. Timers: TM1...TM100
- marked with 't' if a trigger was found
- marked with 'r' if a receiver or instruction was found
6. Functions/Loops: FU1...FU30000, DO1...DO30000
- marked with 't' if a trigger (function definition) was found
- marked with 'r' if a receiver or instruction (function call) was found
- marked with 'd' if a receiver or instruction (cycle call) was found

Also, VC cannot log an indirect referenced vars like this:
!!VRvx10:...
The index of v var is unknown here at loading time because x10 is undefined at that point.
This means that if you want to be sure that a script (that is not created by you), you logged elements from, does not use indirect referenced variables, you have to check it manually, line for line. To avoid such a work in the future, the proposition is to initialize all variables that you may use in your script like this:
!#VR...:S0;

at the top of the script, to be sure that this var will be logged


You can log vars from several script files. Say, you can put !#VC:CB; in script00.erm file and !#VC:EWC; to script40.erm and you will get the complete list of vars in all script files from 0 to 40.
The log file is created at map loading and called as "ERMVarsUsed.log". If such file exists, it will be completely overwritten.

We recommend to use Y and N section to check your own script for vars/timers/functions that are used in your script and in other scripts.
For this you should set a number for your script file to higher than any other scripts, log vars in all scripts and use Y and N section in your script file.
Example:
You have scripts number 0,1,2,3,4,5...50 and want to check your script for cross-reference with them.
1. Number your script as script99.erm (condition: 99 > 50).
2. Add "start logging" in the beginning of the first script file (script00.erm):
!#VC:CB;
3. Add "start cross-reference checking" in the beginning of your script file (script99.erm):
!#VC:Y;
4. Add "stop cross-reference checking" in the end of your script file (script99.erm):
!#VC:N;
5. Add "stop logging and write" in the end of your script file (script99.erm):
!#VC:EWC;
Now, if your script uses variables/triggers/functions that were used in the scripts 0...50, all of them will be marked in the log file with '*'.
If you want to make the same for your internal map scripts, assume scripts number as a day of Timed Events and do the same.