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.
HTHCode: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
BrianT




Bookmarks