suggestions needed for my app

kunfuzed1
08-31-2003, 03:09 PM
please take a look at the attached picture...
In this app, there are two things i need to do, i may need to redo the layout, which is fine.

In the SSTab control, I have an array of these controls in each "table" (1-9).
What I'd like to do is two things..
First, I'd like to be able to take data from say Table 1, Player 1 and move it to Table 4, Player 2 or whatever the user defines.. I'd like to prompt the user with an option to take it from wherever and stick it some place else. The data to be moved is the start time, and or end time basically...
What should i be looking at to make this happen? i'm not really sure the right way to set it up..

Secondly, I'd like to make a .dat file that keeps track of all the totals and puts them somewhere that i can pull them up at the end of the business day and show total playing times and total costs for each table, 1-9. (players are cleared and added to all day long, i just want something to keep total minutes and cost for each player and then total that at the end of the day)
I've posted a similar question to this before and got suggestions to use a database, but i was really hoping to avoid that, just using simple write and read statements to a dat file if at all possible, but again, not sure if i should create a dat file for each table or what. Or if i must stay away from this and learn to use database stuff right now. I'd like to keep it confined to things i am already familiar with since i am under time constraints to finish this. i can go back and make it pretty later.

If anyone can answer these questions in part or in whole, it would be much appriciated, i'm not really sure where to go next for either of these problems.

passel
08-31-2003, 07:32 PM
Since you don't want to use a database, I would define a couple User
Defined Types(UDTs). One to use for your dynamic data in memory, and the
other to define your records to be stored to your .dat file.

As a minimum, the UDT for use in memory would only contain Start and
End Time.
I would create a two dimentional array of this type. dimensioned by
player and table. ie.

Private Type udtTime
startTime As Single
endTime As Single
End Type

Constant NumOfTables = 9
Constant NumOfPlayers = 6

Dim stats(NumOfPlayers,NumOfTables) as udtTime


Then whatever times you entered on your controls, you would just index
into the array by player, and table, and update the times.

To copy the data from table/player to another just provide a way to
specify the from, to and then copy.
Your example:
stats(2,4) = stats(1,1) 'copies from table 1, player 1 to playr 2, table 4

I would have another UDT defined that had a minimum of 4 fields
Table
Player
StartTime
EndTime

Whenever you pressed Add Record, for a particular player, on a particular
table, you would fill in the 4 pieces of data, and write it to your .dat file.

At the end of the day, you could provide a key that you hit, which would
simply read through the records, and calculate and accumlate total time
and total costs (which should be total time * cost per minute unless you
have different rates, in which case you may want to add a rate field to
the data you store).

You could expand the UDT for the file to include the totals, or to only
have the totals, if that is all you want. Then you would have less to
calculate when you read them back in, but this is not going to be a long
process, with the limited number of records you will have, in any case.

For simplicity, I would use a file open for Random access. I would write the
number of records, in the first record, then write the data in records 2
to whatever. I would update the file, and close the file with each
transaction, in case the computer crashed for some reason, you wouldn't
loose the days work. Which also suggest, it might be nice to create a
second file that holds the current data for your tables and players, so
in the event of a crash, you could recover the current data (start times)
for all the tables and players after you rebooted.

So the code would go something along these lines:
You press "Add Record"

Dim recPtr as Long

rec.Table = tableNum
rec.Player = playerNum
rec.StartTime = stats(playerNum,TableNum).StartTime
rec.EndTime = stats(playerNum,TableNum).EndTime

Open "c:\TodaysStats.dat" for random as #1
get #1, 1, recPtr 'number of records stored in first record
recPtr = recPtr + 1
put #1, recPtr, rec 'write this stat to the next record
put #1, 1, recPtr 'write the number of records back to the first record
Close #1


Since I didn't declare the len of the random records, it defaults to 128 bytes. Depending on how big you UDT is, you will probably want to add
a len argument to the Open statement to reduce the size of your records
to just however many bytes you need to hold the UDT. In the example
above, I could have used a Len=16 since I only have 4, 4 byte values
defined in the UDT.

Play with this, and you should be able to expand on it to do whatever
you need.

kunfuzed1
08-31-2003, 08:12 PM
Thanks Passel, you are heading me in the right direction. I was losing hope for a little while there. You put that twinkle back in my eye heh
Thanks for such a detailed reply, it was badly needed and I appriciate it very much. hope I can return the favor someday.

Thanks,
Jim

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum