now i increment the first of the 96 counters in a chain of counters
c(0,0)+=1
if it overruns reset it and increment then next counter
Code: Select all
if c(0,0)=6 then
c(0,0)=0:c(0,1)+=1 ...
if c(0,1)=6 then
c(0,1)=0:c(0,2)+=1 ...
if c(0,2)=6 then ' ...
end if
end if
how to replace all the "if then" blocks with macros or loops ?
Thank you
Joshy
Code: Select all
' 16x6=96 counters
dim as integer c(15,5)
print "increment 16x6 = 96 counters in a chain! ..."
do
#if 0
cls
for y as integer = 0 to 15
for x as integer = 0 to 5
' do something with the 16x6 counters
'doit(c(y , x))
next
next
#endif
' increment first counter
c(0,0)+=1
' if it overruns reset it and increment next counter and so one
if c(0,0)=6 then
'print "c(0,0) overrun"
c(0,0)=0:c(0,1)+=1
if c(0,1)=6 then
'print "c(0,1) overrun"
c(0,1)=0:c(0,2)+=1
if c(0,2)=6 then
'print "c(0,2) overrun"
c(0,2)=0:c(0,3)+=1
if c(0,3)=6 then
'print "c(0,3) overrun"
c(0,3)=0:c(0,4)+=1
if c(0,4)=6 then
'print "c(0,4) overrun"
c(0,4)=0:c(0,5)+=1
if c(0,5)=6 then
'print "c(0,5) overrun"
c(0,5)=0:c(1,0)+=1
if c(1,0)=6 then
'print "c(1,0) overrun"
c(1,0)=0:c(1,1)+=1
if c(1,1)=6 then
'print "c(1,1) overrun"
c(1,1)=0:c(1,2)+=1
if c(1,2)=6 then
'print "c(1,2) overrun"
c(1,2)=0:c(1,3)+=1
if c(1,3)=6 then
'print "c(1,3) overrun"
c(1,3)=0:c(1,4)+=1
if c(1,4)=6 then
'print "c(1,4) overrun"
c(1,4)=0:c(1,5)+=1
if c(1,5)=6 then
print "c(1,5) overrun"
beep
c(1,5)=0:c(2,0)+=1
' and so one
'...
'if c(15,5)=5 then exit do
exit do
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
loop
print "done ..."
sleep