To control a process step by step, you usually need these elements:
A timer, a select case structure and a step variable.
The secuence is something like this:
You start the process clicking a button.
Inside the button click event, you set the step variable to 1, for example, and enable the timer. This click also runs the first step of the process.
In the case 1 section of the select case structure (inside the tick event of the timer) you check if the first step of the process is over.
If affirmative, you set the step variable to 2, and start step 2, and so on.
The timer interval should be set to the proper value, depending of the reaction time of the controlled process, in order to check for a response with a reasonable frequency
<code>
Sub timer1_tick
timer1.enabled=False
select case stepX
case 1
if login_ok then
stepX=2
timer1.enabled=True
ProcessCtrl("show alarms")
end if
case 2
if alm>"" then
sendemail(alm05)
end if
stepX=3
timer1.enabled=True
ProcessCtrl("new data")
case 3
if load_ok then
ProcessCtrl("report")
stepX=9
else
ProcessCtrl("alm77")
stepX=4
end if
case 4
....
End Select
End Sub
</code>