Files, always files...

BlitzPlus Forums/BlitzPlus Programming/Files, always files...

Crystal Noir(Posted 2003) [#1]
Hello again lol :)

Imagine : You have some datas to save to a file.

Let's take an example : You want to records some products properties (price, name, shop..etc..)

You can do a TYPE to store all the information for the product. But into a file :

How to store all products with their differents properties, in one file, and after, how to make B+ differentiate them ? (because all products will be stored with their properties, in one unique file).

Thx in advance :)


Anthony Flack(Posted 2003) [#2]
To write:


file=writefile("products.dat")

for p.product=each product
  writestring(file,p\name$)
  writestring(file,p\shop$)
  writeint(file,p\price)
next

closefile file



To read:


file=readfile("products.dat")

repeat

  p.product=new product
  p\name$=readstring(file)
  p\shop$=readstring(file)
  p\price=readint(file)

until eof

closefile file




Crystal Noir(Posted 2003) [#3]
thx ! a lot :)