# init flags, counters
# A action loop count
creg CX0=3
# A iterations
creg CX1=3
# A<-B signal
freg FX1=0

# start script B
println "A starting B"
scr load b.scr
scr run b.scr

# main loop
:loopA

# clear A->B signal
freg FX0=0

# do stuff…
println "A CX0[$CX0] CX1[$CX1] FX0[$FX0]"

# decrement CX0
creg CX0--
if [ CX0 != 0 ] goto loopA

println "A signaling B..."

# notify script B
freg FX0=1

println "A waiting for B..."

# wait for script B 
:waitB
println "A FX1 $FX1"
if [ ! FX1 ] goto waitB

# decrement CX1
creg CX1--
If [ CX1 == 0 ] goto quit

println "A restart CX1[$CX1]"

# restart
# reset cx0, fx1
freg FX1=0
creg CX0=3
goto loopA

:quit

println "A stopping B"
scr kill b.scr
println "A done"
end

