For-Next INSIDE While - Wend
I have spent the last 2 days trying to get a For-Next to work Inside a While-Wend. But I keep getting a BLOCK MISMATCH error. The manual for PBP V2.50b offered little to no help and I can't find it here on the Forum. So where do I look?
Thanks ONE and All
Terry K9HA
For Next within While Wend
Here is some code from a working program that has a FOR ... NEXT within a WHILE .... WEND. I did not throw up any problems when I wrote it or since. It runs on an 18F4620 and is compiled in PBPL.
Code:
SendPacket:
txchksum = 0
msgloops = 0
txmsglen = txchar[3]
while ack = 0 'destination has not yet got a clean copy
msgloops = msgloops + 1
if msgloops > 63 then msglooperror ' send packet maximum of 64 times
for commsctr = 0 to precnt
serout2 msg, 32, [prechar] 'send preamble
next commsctr
serout2 msg, 32, ["$"] 'send Start Of Message
for commsctr = 0 to 255 'send rest of message - won't get to 255
if commsctr = txmsglen then sendeom
serout2 msg, 32, [txchar[commsctr]]
txchksum = txchksum + txchar[commsctr]
'active message length is 0~(TxMsgLen - 1)
'EOM is at position TxChar[TxMsgLen]
next commsctr
SendEOM: 'plus the SendChkSum:
serout2 msg, 32, ["*",txchksum]
txchar[txmsglen] = "*"
txchar[txmsglen + 1] = txchksum
wend
HTH
BrianT