Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
clearing a record question
#1
type teamrecord
teamid as string * 15
....
.....
end type
dim team as teamrecord



I have a masterfile program that inputs and changes data. I have written it so that if it is decided to change data and the return key is pressed, that data field is not changed. My problem is, after one record is entered, and you go into adding another record, the data from the previous record is still in the type record (team). What is the best way to clear out the teamrecord?? Should I erase team and then dim it again after I put it??
Reply
#2
Why do you need to physically delete it? Just mark it as empty and overwrite its contents when new DATA is required to be added.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#3
Sorry for the ignorance, but what do you mean mark it as empty?? Set each field to "" ? Some of my records have a lot of fields. I set currentvalue$=race.teamname ect... before you input the field, so that when you are changing fields and you just hit the enter key the value does not change it gets set to what currentvalue$ is equal to.
Reply
#4
I can check to see if it is a new record or existing record. If existing then set the currentvalue$ else don't set it. I was just looking for other ideas.

thanks
Reply
#5
To mark a record add a field "Status" or something like that, then use symbollic values, for example "0" = empty, "1" = not empty, "2" = deleted... etc

That way you can always mark as "empty" when "deleting", and on writing just ask if it is "empty". If so, write. That way you are saving time to physically delete it. That's what's made on disk drives, for example. Time is precious and you don't have to physically delete the data, just overwrite it if it is not longer needed.

And you can always use those markers to compact your data, i.e. when requested you just process the array and get rid of entries marked "empty" or "deleted" or whatever you want. You can do this for example when writing to disk to save space. Writing to disk is not a critical task so you can afford the time conspution.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#6
Most programs use RAM to do all the operations and then periodically dump their data onto the HDD. But this is dangerous if you have a power failure. The other method is doing all the operations in a BINARY file. Incase of QB you can use either of the methods.

Also, when you delete a record the other records should shift up. So what you could do is:

Arr = element of the array
Data = value at the offset

Code:
Arr     0   1   2   3   4   5   6   7   8   9
Data    a   b   c   d   e   f   g   h   i   j
So if you want to delete record 3. Then just copy the next elements of the data to be deleted to the previous record like this:

Code:
Arr     0   1   2   3   4   5   6   7   8   9
Data    a   b   c   d<--e<--f<--g<--h<--i<--j

Finally,
Code:
Arr     0   1   2   3   4   5   6   7   8   9
Data    a   b   c   e   f   g   h   i   j '\0'

'\0' = null or ""

After doing all these operations you can overwrite your binary file to keep it up to date =).
Reply
#7
These are Random Access files. Some of them I use the index number as one of the fields. They are just for personal use and they are not large files, thus space and time are really not issues.
Reply
#8
Exactly, so you can do all the operations directly with the BINARY(Random Access Files) =P
Reply
#9
Don't really no anything about going binary, so I'll have to look into that. But I think everyone is missing my question.

type teamrecord
teamid as string * 12
teamname as string * 25
.......
.......
end type
dim team as teamrecord

I input data put as team
I can also change data
if I am changing data..say teamname
I set currentvalue$=team.teamname
if input ="" then team.teamname=currentvalue$..stays the same
else team.teamname=input

now if I am on a new record, the team record still has the data from the previous record. So if "" is entered, the value is set from the previous teamrecord. My question is how do you empty the teamrecord? Is there a statement that will emtpy it? I know I can check to see if this is a new record and not let the currentvalue$=team.teamname but I was wondering if there was another way around this.
Reply
#10
Have you read my post, before TBBQ's ? What I say will help you. Those are ancient techniques when dealing with data.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)