error treatment

error treatment

Postby umbirussu » Thu Sep 06, 2018 11:03 pm

Hello people.
How can I introduce a error treatment im my VL?
I wold like show a dialog message and end simulation.

The first part I do. In any points of VL I put an IF, like:
-------------------------------------------------
IF lcColuna = -1
SET nErro = 1
Display Message "Erro1:não encontrou prateleira vazia"
Stop Simulation
-------------------------------------------
But I need to cancel the simulation. Using "Stop simulation" when I click the "OK" button in the display message, the logic continues to run.

Thanks in advance
João Umbiruçu

Re: error treatment

Postby Simulater92 » Tue Sep 11, 2018 10:27 am

The "Stop Simulation" command should actually already do what you need, i.e. just stop the simulation - maybe something else restarts it? Otherwise, you can also add the line "Reset Clock 0" after the stopping message as this will reset your simulation so it will definitely not keep running.

I hope this helps.

Re: error treatment

Postby Kiki123 » Wed Sep 19, 2018 5:03 pm

Hello,

What happens is that SIMUL8 will continue running the current block of logic. This is probably so that you can still perform some calculations before you stop the simulation, but the simulation itself will stop.
To prevent this you can use additional IF statements to only run the remainder of the logic if you are not stopping the simulation.

For example:

IF lcColuna = -1
SET nErro = 1
Display Message "Erro1:não encontrou prateleira vazia"
Stop Simulation
set gblDoNotRunRestOfCode = 1

IF gbldoNotRunRestOfCode = 0
'then run the rest of your code as you would normally.
'because we changed the global variable above, this IF statement will no longer be true and so will not run after you stop the simulation.

I hope this helps.


Return to “SIMUL8 Cafe”