Author Topic: Random Access Files  (Read 10344 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Random Access Files
« Reply #15 on: August 31, 2018, 06:15:46 pm »
Yeah, Steve's looks easier, specially since it's already written! ;)

I was trying to accommodate stats between players because rivalries are a big thing with players, usually!

5 files, 500 files, we are leaving it up to the OS to do the file (playerName.dat) searching, = 0 things to code, don't let number of files scare you.


So Steve is saying one file, and one record for each player and that record will only contain the current status of stats of each player.

I have advised one data base file for each player with dates and opponents you can code all sorts of questions to ask your data base files. BTW Getting a list of files is not so hard either specially if the all end in".DAT". Yes, a little more complex but we do love to code don't we?  ;-))
« Last Edit: August 31, 2018, 06:26:40 pm by bplus »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Random Access Files
« Reply #16 on: August 31, 2018, 06:38:52 pm »
Yeah, Steve's looks easier, specially since it's already written! ;)

I was trying to accommodate stats between players because rivalries are a big thing with players, usually!

5 files, 500 files, we are leaving it up to the OS to do the file (playerName.dat) searching, = 0 things to code, don't let number of files scare you.

My little example still lets you track stats between players (though I'd probably tweak it to store Win-Loss-Draw instead of just Wins), as long as you know the player's record number.  (That info should probably be displayed along with the name, but I just tossed that little demo together while eatting supper and taking a break from my little map maker...)

(And 500 files scare me, personally; I'm always afraid I'll leave a crapload out if I ever need to zip them up and port them to another machine.  Which, if I'm being honest, is why I created QBDbase and have huge databases much to large to load/run in a 32-bit OS.  I'd personally rather have one massive database than 500 small ones.)

There's a lot of things I think should be added/expanded upon, if someone was going to use it for a serious data base project.  My first suggestions for improvement would be:

1) Error Check user input.  Make names ALL CAPS to avoid input/search issues.  Make certain somebody doesn't enter -14 for games played...

2) Display the record number with each record, for user ease of knowing who's who.

3) Display name as well as number when displaying, or asking for, "Games against", "Wins against", "Loss against"...

4) Change from "auto-update ALL" to a menu system so you can choose what elements to update.  Why change/renter stats for all 10 players, when you just played one of them?

I'd definitely want to make some alterations to make the demo a little more foolproof and user-friendly, but it should be a nice "core" to help show you how to get started for the project.  ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Random Access Files
« Reply #17 on: August 31, 2018, 07:49:03 pm »
Steve:
Quote
My little example still lets you track stats between players...

Yes, I see that now very nice! Go with Steve's example!

Offline pinology

  • Newbie
  • Posts: 17
    • View Profile
Re: Random Access Files
« Reply #18 on: September 01, 2018, 01:19:48 am »
ya mcneil that just like what I was trying to do and got close a couple times on my trial runs ya looks like what I was questioning when I put all those rems on that post trying to figure out how to use that recordpos function thanks guys this forum way cool.  I could stop by and help out the people that have the really easy questions but you guys are pretty good


Offline pinology

  • Newbie
  • Posts: 17
    • View Profile
Re: Random Access Files
« Reply #19 on: September 01, 2018, 01:23:29 am »
ya and I won't have any problems hopefully taking care of those notes you left. but actually the game is going to be writing all the stats players will be able to fix some misclicks during the game but not go edit there own stats, gonna have it so they can zero them out and start over every few months if they want to