Random Access File Hint for me....
Posted: Sun Dec 03, 2006 4:14 pm
Hello again...
Here is what I am trying to do...
I run a BBS ... You know, one of them old timey things from 1990's...
Anyway, I have DoorGames... I want to track usage for these doors... Here is my vision...
I would like to create a program that will track the usage of each door. I have a method by which I can call my program (I will call it DOORGRAF for our discussion) and send the name of the game as a parameter... Thanks to the earlier help... COMMAND$ is great... so anyway....
The call to my program would be like DOORGRAF.EXE MYGAME
When it is called, I want it to search my Random access file to determine if the game exists in the records... If not, then create a new record... If it does exist then add one to the number of times the game has been accessed as well as record the date of the file access...
As for the Graphs I think I can do what needs to be done to create graphs... At least I have an idea on what I want it to look like...
ANOTHER THOUGHT/QUESTION
For the Graphs section, I want it to be in order from Largest # of times played to Least Number of Times played... How can I search through XX Number of records and arrage it (not changing the actual data file) order for my graph... Seems like a tedious process to go though for a large number of records to arrange them in that type of order.... Err any type of order for that matter...
-----------------Start of Code Here --------------------
WHATGAME$ = ltrim$(rtrim$(command$)) 'find location of space delimiter between filenames.
NUMOFRECORDS =5 'Number of records in file 1 to 32000
DEBUG = 1 'Set to 1 for debugging
TYPE GAMERECORD
GAMENAME AS STRING * 30 'Name of Game
GAMEPLAYS AS INTEGER 'How Many Times is has been played
GAMELASTPLAY AS STRING * 10 'When was it last accessed
END TYPE
DIM GAME as GAMERECORD
If WHATGAME$ = "MAINT" Then
'ENTER THE DATABASE MAINT MODE
ELSEIF WHATGAME$ = "MAKEGRAF" Then
'Make the Graphs
ELSEIF WHATGAME$ = "RESET" Then
GAME.GAMENAME = "EMPTY"
GAME.GAMEPLAYS = 0
GAME.GAMELASTPLAY = "NEVER"
OPEN "DOORSTAT.DAT" AS #1 LEN = LEN(GAME)
FOR RECORD = 1 to NUMOFRECORDS
PUT #1, RECORD, GAME
NEXT RECORD
CLOSE #1
ELSEIF WHATGAME$ = "SHOWRECORDS" THEN
OPEN "DOORSTAT.DAT" AS #1 LEN = LEN(GAME)
FOR RECORD = 1 to NUMOFRECORDS
GET #1, RECORD, GAME
IF DEBUG = 1 THEN 'DEBUG ONLY
PRINT GAME.GAMENAME
PRINT STR$(GAME.GAMEPLAYS)
PRINT GAME.GAMELASTPLAY
SLEEP 1
END IF
NEXT RECORD
ELSE
'SEARCH FOR THE RECORD IN THE FILE
CURRENTGAME$ = WHATGAME$
OPEN "DOORSTAT.DAT" AS #1 LEN = LEN(GAME)
For Record = 1 to NUMOFRECORDS
Get #1, RECORD, GAME
IF LTRIM$(RTRIM$(GAME.GAMENAME)) = CURRENTGAME$ THEN 'RECORD FOUND
GAME.GAMEPLAYS = GAME.GAMEPLAYS + 1
GAME.GAMELASTPLAY = DATE$
PUT #1, RECORD, GAME
RECORD = NUMOFRECORDS
ELSEIF GAME.GAMENAME = "EMPTY" THEN 'EMPTY RECORD FOUND
GAME.GAMENAME = CURRENTGAME$
GAME.GAMEPLAYS = 1
GAME.GAMELASTPLAY = DATE$
PUT #1, RECORD, GAME
RECORD = NUMOFRECORDS
END IF
NEXT RECORD
CLOSE #1
END IF
Here is what I am trying to do...
I run a BBS ... You know, one of them old timey things from 1990's...
Anyway, I have DoorGames... I want to track usage for these doors... Here is my vision...
I would like to create a program that will track the usage of each door. I have a method by which I can call my program (I will call it DOORGRAF for our discussion) and send the name of the game as a parameter... Thanks to the earlier help... COMMAND$ is great... so anyway....
The call to my program would be like DOORGRAF.EXE MYGAME
When it is called, I want it to search my Random access file to determine if the game exists in the records... If not, then create a new record... If it does exist then add one to the number of times the game has been accessed as well as record the date of the file access...
As for the Graphs I think I can do what needs to be done to create graphs... At least I have an idea on what I want it to look like...
ANOTHER THOUGHT/QUESTION
For the Graphs section, I want it to be in order from Largest # of times played to Least Number of Times played... How can I search through XX Number of records and arrage it (not changing the actual data file) order for my graph... Seems like a tedious process to go though for a large number of records to arrange them in that type of order.... Err any type of order for that matter...
-----------------Start of Code Here --------------------
WHATGAME$ = ltrim$(rtrim$(command$)) 'find location of space delimiter between filenames.
NUMOFRECORDS =5 'Number of records in file 1 to 32000
DEBUG = 1 'Set to 1 for debugging
TYPE GAMERECORD
GAMENAME AS STRING * 30 'Name of Game
GAMEPLAYS AS INTEGER 'How Many Times is has been played
GAMELASTPLAY AS STRING * 10 'When was it last accessed
END TYPE
DIM GAME as GAMERECORD
If WHATGAME$ = "MAINT" Then
'ENTER THE DATABASE MAINT MODE
ELSEIF WHATGAME$ = "MAKEGRAF" Then
'Make the Graphs
ELSEIF WHATGAME$ = "RESET" Then
GAME.GAMENAME = "EMPTY"
GAME.GAMEPLAYS = 0
GAME.GAMELASTPLAY = "NEVER"
OPEN "DOORSTAT.DAT" AS #1 LEN = LEN(GAME)
FOR RECORD = 1 to NUMOFRECORDS
PUT #1, RECORD, GAME
NEXT RECORD
CLOSE #1
ELSEIF WHATGAME$ = "SHOWRECORDS" THEN
OPEN "DOORSTAT.DAT" AS #1 LEN = LEN(GAME)
FOR RECORD = 1 to NUMOFRECORDS
GET #1, RECORD, GAME
IF DEBUG = 1 THEN 'DEBUG ONLY
PRINT GAME.GAMENAME
PRINT STR$(GAME.GAMEPLAYS)
PRINT GAME.GAMELASTPLAY
SLEEP 1
END IF
NEXT RECORD
ELSE
'SEARCH FOR THE RECORD IN THE FILE
CURRENTGAME$ = WHATGAME$
OPEN "DOORSTAT.DAT" AS #1 LEN = LEN(GAME)
For Record = 1 to NUMOFRECORDS
Get #1, RECORD, GAME
IF LTRIM$(RTRIM$(GAME.GAMENAME)) = CURRENTGAME$ THEN 'RECORD FOUND
GAME.GAMEPLAYS = GAME.GAMEPLAYS + 1
GAME.GAMELASTPLAY = DATE$
PUT #1, RECORD, GAME
RECORD = NUMOFRECORDS
ELSEIF GAME.GAMENAME = "EMPTY" THEN 'EMPTY RECORD FOUND
GAME.GAMENAME = CURRENTGAME$
GAME.GAMEPLAYS = 1
GAME.GAMELASTPLAY = DATE$
PUT #1, RECORD, GAME
RECORD = NUMOFRECORDS
END IF
NEXT RECORD
CLOSE #1
END IF