Ask the SIMUL8 Community

error treatment

umbirussuumbirussu
Created at
in Community support
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


Comments

  • Was this answer helpful?


    0
    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.
  • Was this answer helpful?


    0
    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.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Attach file
Attach image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file