Global and module level variables are not cleared when tasks are run from VB
Symptoms
When SPEL+ tasks are run from VB, SPEL+ global and module level variables are not cleared. When tasks are run in the RC+ environment, all variables are cleared when the Start button is clicked from the Run window or Operator window. When tasks are run from VB, variables are not cleared. Causes This is the current design. Remedy If you need to clear SPEL+ variables, you can execute "Erase All" from VB using the SPELCom method ExecSPELCmd. If you are using Global Preserve variables, these will also be cleared, so you must temporarily save the values and then restore them after clearing the variables. For example:
SPEL Code Example Sub ClearSPELVars()
Dim savVar As Long With SPELCom1
' Save Global Preserve variable
savVar = .GetSPELVar("g_CycleCount") ' Clear all SPEL+ variables
.ExecSPELCmd "ERASE ALL" ' Restore Global Preserve variable .SetSPELVar("g_CycleCount", savVar) End With End Sub |

