For-Next INSIDE While - Wend


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2007
    Location
    Lake Villa Il.
    Posts
    40

    Red face 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

  2. #2
    Join Date
    Feb 2009
    Posts
    26


    Did you find this post helpful? Yes | No

    Default

    Please post some code

  3. #3


    Did you find this post helpful? Yes | No

    Default 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
    Last edited by BrianT; - 13th March 2009 at 11:40. Reason: typo correction

  4. #4
    Join Date
    Nov 2007
    Location
    Lake Villa Il.
    Posts
    40


    Did you find this post helpful? Yes | No

    Smile

    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.

Similar Threads

  1. Can't read sequential addresses in external EEPROM
    By tjkelly in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th February 2010, 15:46
  2. HSEROUT and Commas, What? Help Me Understand
    By altech6983 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 20th July 2009, 20:12
  3. Regarding WHILE...WEND
    By Security in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 8th September 2008, 10:31
  4. LOTS of questions....
    By reaper0995 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 22nd March 2008, 18:00
  5. Pulsin versus While Wend
    By Toley00 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 7th March 2006, 21:08

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts