For-Next INSIDE While - Wend


Results 1 to 4 of 4

Threaded View

  1. #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 10:40. Reason: typo correction

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, 14:46
  2. HSEROUT and Commas, What? Help Me Understand
    By altech6983 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 20th July 2009, 19:12
  3. Regarding WHILE...WEND
    By Security in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 8th September 2008, 09:31
  4. LOTS of questions....
    By reaper0995 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 22nd March 2008, 17:00
  5. Pulsin versus While Wend
    By Toley00 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 7th March 2006, 20:08

Members who have read this thread : 0

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