Results 1 to 3 of 3

Thread: Usage of DO/LOOP, DO WHILE/LOOP, DO / LOOP UNTIL

  1. #1
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    Usage of DO/LOOP, DO WHILE/LOOP, DO / LOOP UNTIL

    Hi,

    another loop related stuff
    [code=thinbasic]
    uses "Console"

    dim CountSheep as byte

    Console_Writeline("Pure DO/LOOP")

    ' -- Classic infinite loop
    ' -- NOTE: To leave loop you must use EXIT statement
    CountSheep = 0
    do

    incr CountSheep

    Console_Writeline("-- Sheep :"+STR$(CountSheep))

    if CountSheep = 10 then exit do

    loop

    Console_Writeline("Press ENTER...")
    console_Readline

    Console_Writeline("Test DO WHILE/LOOP")

    ' -- Loop with condition which must be TRUE to PERFORM cycle
    ' -- NOTE: If the condition does not equal to TRUE on start, NO cycle is performed
    ' - try to change "CountSheep = 0" to "CountSheep = 10"
    CountSheep = 10
    do WHILE CountSheep < 10 ' -- Valid for CountSheep = 0 ... 9

    incr CountSheep

    Console_Writeline("-- Sheep :"+STR$(CountSheep))

    loop

    Console_Writeline("Press ENTER...")
    console_Readline

    Console_Writeline("Test DO/LOOP UNTIL")

    ' -- Loop with condition on end which must be TRUE to LEAVE cycle
    ' -- CAUTION ! This way at least one loop is performed always
    CountSheep = 0
    do

    incr CountSheep

    Console_Writeline("-- Sheep :"+STR$(CountSheep))

    loop until CountSheep = 10 ' -- If this is true we leave loop

    Console_Writeline("End of demonstration, press ENTER to quit...")
    console_Readline
    [/code]

    Bye,
    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: Usage of DO/LOOP, DO WHILE/LOOP, DO / LOOP UNTIL

    Substituted
    [code=thinbasic]
    ' - try to change "CountSheep = 0" to "CountSheep = 10"
    CountSheep = 10
    [/code]
    with
    [code=thinbasic]
    ' - try to change "CountSheep = 0" to "CountSheep = 10"
    CountSheep = 0
    [/code]

    Thanks
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  3. #3
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    Re: Usage of DO/LOOP, DO WHILE/LOOP, DO / LOOP UNTIL

    Thanks Eros,

    I had probably testing version in clipboard :-[


    Bye,
    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

Similar Threads

  1. Repeat or loop
    By Henry in forum thinBasic General
    Replies: 1
    Last Post: 30-11-2007, 14:24

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

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