Liberty BASIC Community Forum
« Chopping off the first name in the output file: »

Welcome Guest. Please Login or Register.
Feb 18th, 2018, 3:41pm


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


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Chopping off the first name in the output file:  (Read 56 times)
Chester
New Member
Image


member is offline

Avatar




PM


Posts: 12
xx Chopping off the first name in the output file:
« Thread started on: Feb 10th, 2018, 11:31am »

#1 'GETitDONE-OUTPUT.bas
#2 dim folksName$ (5)
#3 print " GETitDONE-OUTPUT.bas"
#4 print " Enter up to (5) names."
#5 print " A zero or blank entry ends the input."
'*********************************************
#6 [rightOn]
#7 print
#8 print " Entry "; index + 1
#9 input " Key in folks's name:"; folksName$
#10 if folksName$ = "" then [endSeries]
#11 if folksName$ = "0" then [endSeries]
#12 folks$(index) = folksName$
#13 index = index + 1
#14 if index < 5 then [rightOn]
'**************************
#15 [endSeries]
#16 xxxcount = index
#17 if xxxcount = 0 then print "No entries. " : end
#18 print "Entries completed."
#19 print
#20 print "---------------------------------------"
#21 for index = 0 to xxxcount - 1
#22 print folks$(index)
#23 next index
'******NEW CODES START HERE******
#24 open "cgjwmp.dat" for output as #xxxcg
#25 for index = 1 to xxxcount
#26 print #xxxcg, folks$(index)
#27 next index
#28 close #xxxcg
#29 end
'***************************************"
Can anyone look thru line #1 - line #29 and see why this only save (4) names instill of (5), it is chopping off the first name in the output file?
'***************************************"
User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5655
xx Re: Chopping off the first name in the output file
« Reply #1 on: Feb 10th, 2018, 1:49pm »

When you open the file for output you are starting at 1 not 0. But you are still saving the first name to index 0.

Always start index at 1, everywhere in your code, that way life is easier and you never get it wrong.
« Last Edit: Feb 10th, 2018, 1:54pm by Rod » User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5655
xx Re: Chopping off the first name in the output file
« Reply #2 on: Feb 10th, 2018, 4:07pm »

dim folks$ (5)
print " Enter up to (5) names."
print " A zero or blank entry ends the input."
index=1

[rightOn]
print " Entry "; index
input " Key in folks's name:"; folksName$
if folksName$ = "" then [endSeries]
if folksName$ = "0" then [endSeries]

folks$(index) = folksName$
index = index + 1
if index < 6 then [rightOn]

[endSeries]
xxxcount = index -1
if xxxcount = 0 then print "No entries. " : end
print "Entries completed."
print
print "---------------------------------------"
for index = 1 to xxxcount
print folks$(index)
next index

'open "cgjwmp.dat" for output as #xxxcg
for index = 1 to xxxcount
print folks$(index)
print #xxxcg, folks$(index)
next index
close #xxxcg
end
« Last Edit: Feb 10th, 2018, 4:09pm by Rod » 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