Liberty BASIC Community Forum
« Loop »

Welcome Guest. Please Login or Register.
Jan 22nd, 2018, 5:59pm


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Loop  (Read 159 times)
Chester
New Member
Image


member is offline

Avatar




PM


Posts: 6
smiley Loop
« Thread started on: Dec 18th, 2017, 6:52pm »

[startOver]
input "Try again y/n";tryAgain$
if tryAgain$ = "y" then
goto [startOver]
else
end if
end

'How to make this loop back to [startOver] if the user key anything else but "y". If the user key anything beside "y" the program will end. What I meant if the user forget and type anything but a "y" the program will end, I want it to loop back and ask again until the user type "n"
« Last Edit: Dec 18th, 2017, 8:14pm by Chester » User IP Logged

alincon2001
Guru
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 510
smiley Re: Loop
« Reply #1 on: Dec 18th, 2017, 7:36pm »

Check help file on 'for - next' loops and also the confirm command

r.m.
User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5618
smiley Re: Loop
« Reply #2 on: Dec 19th, 2017, 03:07am »

Look for y or n then branch.


Code:
[start]


[startover]
decision=0
while not(decision)
    input "Try again y/n :";tryAgain$
    if lower$(tryAgain$) = "y" then decision=1
    if lower$(tryAgain$) = "n" then decision=2
wend

if decision = 2 then goto [quit]
if decision = 1 then goto [start]

[quit]
end
 
User IP Logged

tooanalytical


member is offline

Avatar




PM


Posts: 1165
smiley Re: Loop
« Reply #3 on: Dec 19th, 2017, 11:56pm »

Some of us used multiple conditions as string functions applied to the user's answer input. I do not have code to share right now. You want to let the program accept anything which is "yes", or "YES", or "Yes", or " Y", or " y", but to reject almost anything else.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls