Liberty BASIC Community Forum
« for/next loop »

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


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


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: for/next loop  (Read 104 times)
Chester
New Member
Image


member is offline

Avatar




PM


Posts: 6
xx for/next loop
« Thread started on: Jan 3rd, 2018, 5:07pm »

a$ = "chester jeanette malachi michelle"
for b = 1 to len(a$)'Count the letters in a$ string
if b = 5 then exit for
print b
next b
end
-----------------------------------------------------------------
what is a easy way to count the words in this a$ string? using the for/next loop if you do not how many words the user will type in.
------------------------------------------------------------------
this is the File Name

a$ = "chester jeanette malachi michelle"
for b = 1 to len(a$)'Count the letters in a$ string
c$ = word$(a$,b) 'Count the words in a$ string
if c$ = "" then exit for
print b; " ";c$
next b
end

-------------------------------------------------------------
'This program will print the below output:
1 chester
2 jeanette
3 malachi
4 michele
'What I was trying to do:
'print the numbers without the names using this for/next loop
1
2
3
4

« Last Edit: Jan 4th, 2018, 4:56pm by Chester » User IP Logged

tsh73
Board Moderator

member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1732
xx Re: for/next loop
« Reply #1 on: Jan 4th, 2018, 3:35pm »

Search turned this

word counting
User IP Logged

damned Dog in the Manger
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