PDA

View Full Version : For-Next INSIDE While - Wend



Sneaky-geek
- 13th March 2009, 01:17
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

nemesis
- 13th March 2009, 01:47
Please post some code

BrianT
- 13th March 2009, 10:38
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.



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

Sneaky-geek
- 15th March 2009, 14:01
Thank you BRIAN!!,,
Brian your code example was a real help. In my code I had a conditional If Then, some how
during the marathon coding session I had dropped a EXTRA endif in. The compilier knew that there was a problem, told me there was a problem, but did not tell me WHAT the problem. So, I think I will "borrow" a programming trick from Skimask, DT, etal. SWITCH TO COKE! The DRINK that is!

Again, I want thank ONE AND ALL, for their help.