Regarding WHILE...WEND


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default

    Code:
    WHILE number < 3000
     number = number + 1
    WEND
    Code:
    REPEAT
     number = number + 1
    UNTIL number = 3000
    If you entered each above code sections with number < 3000, these two conditional loops would operate identically, and number would be incremented until number = 3000.

    BUT, if you entered with number > 2999 Then...
    - The WHILE..WEND would not execute, and number would remain the same.
    - The REPEAT..UNTIL loop would execute 1 time, and number would be incremented by 1.

    HTH,
    SteveB
    Last edited by SteveB; - 7th September 2008 at 06:50. Reason: Amplifacation of first sentence.

  2. #2
    Join Date
    Sep 2008
    Posts
    19


    Did you find this post helpful? Yes | No

    Exclamation

    Quote Originally Posted by SteveB View Post
    Code:
    WHILE number < 3000
     number = number + 1
    WEND
    Code:
    REPEAT
     number = number + 1
    UNTIL number = 3000
    If you entered each above code sections with number < 3000, these two conditional loops would operate identically, and number would be incremented by 1.

    BUT, if you entered with number > 2999 Then...
    - The WHILE..WEND would not execute, and number would remain the same.
    - The REPEAT..UNTIL loop would execute 1 time, and number would be incremented by 1.

    HTH,
    SteveB
    The first one is what my experience also showed. So everything is fine.

    The code will see 2999 as less than 3000, therefore it will increment as per the next line, so when the loop ends you have number=3000.
    That is what I experienced.

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink

    Hi, Security

    Just remember the "number" is checked at WHILE and UNTIL lines ( where you write the test ) and it bails out ( if test true ) just after.

    Alain

    Mikroelektronika manuals ( basic and C ) have a very nice explanation of that ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4
    Join Date
    Sep 2008
    Posts
    19


    Did you find this post helpful? Yes | No

    Wink

    Hi, Acetronics

    Just remember the problem is solved.

    Security

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink

    Hi,

    Ok, well noted ...

    Read you soon... new member.

    Alain
    Last edited by Acetronics2; - 8th September 2008 at 14:38.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

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. LOTS of questions....
    By reaper0995 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 22nd March 2008, 18:00
  4. While Wend
    By DJEE in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 8th July 2007, 09:34
  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 : 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