Liberty BASIC Community Forum
« Sequential File »

Welcome Guest. Please Login or Register.
Jun 25th, 2017, 05:29am


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


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Sequential File  (Read 204 times)
johnatuna
Senior Member
ImageImageImageImage


member is offline

Avatar

Oh cool! My computer comes with a coffee cup holder!


PM

Gender: Male
Posts: 287
xx Sequential File
« Thread started on: Jun 12th, 2016, 6:03pm »

I have a file that holds names and scores in it. I want to be able to tell how many lines are in the file so I can limit them to ten. Then I want to locate the scores in the file and arrange each line according to score value.
When the game ends it will look at the list and see if the score is higher than any other high score and allow it to be listed in the high scores file.
I have a file being created using:

Code:
if score > 0 then
prompt "What is your name?"; Name$
NameLength = len(Name$)
spaces = 35 -  NameLength
open "highScore.dat" for append as #hs
print #hs, Name$; space$(spaces); score
close #hs
end if
 


I am at a loss on creating high score routines.
User IP Logged

Johnatuna = John at UNA(University of North Alabama)
cundo
Guru
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 620
xx Re: Sequential File
« Reply #1 on: Jun 12th, 2016, 6:33pm »

See if this code helps
Code:
if fileExists(DefaultDir$, "highScore.dat") then
    open "highScore.dat" for input as #f
        While not(eof(#f))
            Line Input #f, txt$
            idx=idx+1
            print  txt$
        Wend
    close #f
    Else
    Print "file doesn't exist!"
end if
print "n of lines",idx

end

function fileExists(path$, filename$)
    dim fileExistsInfo$(10,10)
  files path$, filename$, fileExistsInfo$()
  fileExists = val(fileExistsInfo$(0, 0)) 'non zero is true
end function

 
User IP Logged

cundo
johnatuna
Senior Member
ImageImageImageImage


member is offline

Avatar

Oh cool! My computer comes with a coffee cup holder!


PM

Gender: Male
Posts: 287
xx Re: Sequential File
« Reply #2 on: Jun 13th, 2016, 04:58am »

I want to create a high scores file that only allows 10 lines. Remember the old video games with top ten scores? That is what I am trying to figure out? I am lost.
User IP Logged

Johnatuna = John at UNA(University of North Alabama)
MKnarr
Senior Member
ImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 427
xx Re: Sequential File
« Reply #3 on: Jun 13th, 2016, 08:41am »

Code was a mistake.
« Last Edit: Jun 14th, 2016, 07:47am by MKnarr » 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