Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
best file mode
#1
what is the best file mode for accessing as saving, using intigers and strings
Reply
#2
I always use BINARY, and save TYPE arrays. It's the most structured way of accessing.
am an asshole. Get used to it.
Reply
#3
Yeah it is a structured way of accessing and storing data. But be warned that you want to handle strings so when you create a data structure which contains strings you have to specify a length. So after you completely store everything in the binary file and you realise that you want to change the length of the strings then it will be troublesome to do that.
Reply
#4
Or you could save your data in a text file if you have to store only little amount of data like this:

Australia, 2563511
USA, 45687
Canada, 8798724
China, 44678
...

I mean just some string and then some integer data. Then you dont have to worry about the length of strings. But then again you wouldnt be able to randomly access any record unless you store the data in an array Big Grin
Reply
#5
using binary records not only lets you store integers, but you can store simple fixed length flatfile databases because every record only takes up a certain amount of space.

the only problem is that it pads fixed length strings with null characters so they are a certain length. if you want to compare strings, pull them out and run them through this:

Code:
function denull$ (text$)
  for x = 1 to len (text$)
    a$ = mid$(text$, x, 1)
    if a$ <> chr$(0) then temp$ = temp$ + a$
  next x
  denull$ = temp$
end function
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Reply
#6
You can also use LTRIM$ on the fixed length string before doing a standard comparison....
Antoni
Reply
#7
d'oh... thanks antoni, the "easy" solution didn't even cross my mind.
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Reply
#8
I was gonna say... toonski, you did a "whitetiger"! :lol: (he made an INSTR function :lolSmile
Reply
#9
Byte (BINARY/RANDOM) is best for speed and smaller size.

It's more difficult than OUTPUT/INPUT because you can't edit it in a text file program (notepad). If you figure out what you're going to put, you can make a special program for your manual file I/O...
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#10
Quote:I was gonna say... toonski, you did a "whitetiger"! :lol: (he made an INSTR function :lolSmile
Gah! I've done that. I've made a LEFT$, RIGHT$, INSTR, SPACE$, and STRING$ functions before realising that there were built-in functions. Tongue
url=http://www.spreadfirefox.com/?q=affiliates&id=60131&t=79][Image: safer.gif][/url]
END OF LINE.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)