While Wend


Closed Thread
Results 1 to 10 of 10

Thread: While Wend

  1. #1
    Join Date
    Jun 2007
    Posts
    7

    Default While Wend

    can a While statement only have one condition or can it have more than one condition?

    example

    While A = 1 AND B < 10
    B = B + 1
    Wend

  2. #2
    Join Date
    Feb 2006
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    I am not sure if you can have more than one condition in a WHILE WEND (although it would be easy enough to find out with a test program). If you can't have more than one condition then you could try to nest more than one WHILE WEND.

    Ex:

    WHILE A = 1
    WHILE B < 10
    LET B = B + 1
    WEND
    WEND

    Just an idea

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by DJEE View Post
    can a While statement only have one condition or can it have more than one condition?

    example

    While A = 1 AND B < 10
    B = B + 1
    Wend
    The manual says 'Condition may be any comparison expression.'. So, while it doesn't specifically say that you can, it doesn't specifically say that you can't...use multiple expression's....or even nested While/Wend statements.
    I think I'd still put the comparison inside parenthesis to avoid confusing the compiler.

  4. #4
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Here is how I would do it (which wasn't your question). The nested WHILE WEND loops to simulate the AND condition can be tricky and are not as straight forward as they appear.
    Code:
    Loop:
    If A=1 THEN
    	IF B < 10 THEN
    		B=B+1
    		GOTO Loop
    	ENDIF
    ENDIF
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  5. #5
    Join Date
    Jul 2007
    Posts
    53


    Did you find this post helpful? Yes | No

    Default Yhis is working for me

    while (selected = tag) and (tmr < duration)

    ...
    wend

  6. #6
    Join Date
    Feb 2006
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by paul borgmeier View Post
    Here is how I would do it (which wasn't your question). The nested WHILE WEND loops to simulate the AND condition can be tricky and are not as straight forward as they appear.
    Code:
    Loop:
    If A=1 THEN
    	IF B < 10 THEN
    		B=B+1
    		GOTO Loop
    	ENDIF
    ENDIF
    Or just

    Loop:
    IF A = 1 AND B < 10 THEN
    B = B + 1
    GOTO Loop
    ENDIF

  7. #7
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Hey, a question from Melanie at last!!! Aimed at Paul though, being an avid sci-fi fan, I feel I should recognise your Avatar as Klingon or Cylon or something?

  8. #8
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    nice eye - my name tells all
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  9. #9
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    another hint for Melanie (attached)
    (you are now 8 of 9)

    Or just

    Loop:
    IF A = 1 AND B < 10 THEN
    B = B + 1
    GOTO Loop
    ENDIF
    certainly more readable but

    1) takes longer to evaluate in PIC time
    2) takes more code space

    {!r]
    Attached Images Attached Images  
    Last edited by paul borgmeier; - 8th July 2007 at 07:08. Reason: color adjust
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  10. #10
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    *laughs* I didn't need the hint...

    But I did think the Borg having a Logo is kinda illogical. Logo's are really a projection of power or identity... so, Klingon's yes, Romulans yes, even Starfleet, but for a bunch of bio-mechanical automatons that assimillated everything they came across, I didn't think they would need (or even collectively recognise the need for) a logo for 'brand awareness'. Next they'll be having a "mission statement"...

    Hmmm... interesting accessory for the cat-suit... female Borg in tight leather... oh, they've already done that...

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 : 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