Need help reading/writing multiple variables to/from a file - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Need help reading/writing multiple variables to/from a file

perro76perro76 Posts: 1Member
I'm working on a program that will store several variables (one user-defined structure, a 2-d integer array, a 1-d string array, and a handful of other basic variables). I'm having trouble figuring out hw to put all of those into a single text file and then read them back out into the appropriate variables. Is there a good demo or walkthrough for doing this anywhere?

Any help would be much appreciated.

Thanks,

Perro

Comments

  • Armani20Armani20 Posts: 32Member
    to write:
    open filename as output as #1
    for i =1 to nr
    write, var(1,i), var(2,i), var(3,i), var(4,i), var(5,i), var(6,i)
    next i
    close #1

    to read:
    dim i as integer
    open filname as input as #1
    do while not eof (1)
    input #1,var(1,i), var(2,i), var(3,i), var(4,i), var(5,i), var(6,i)
    i=i+1
    loop
    close #1
  • weirdmixweirdmix Posts: 27Member
    if the numbers of variables is fix, for instance 10, you also might use FileSystemObject, is very simple, you can even check is a path exists and create that path if don't exists, and for writing the file, there's one method for write strings and put the line terminator at the same time, that would be Writeline(string).

    Search for it in MSDN, is very simple to use..

    : I'm working on a program that will store several variables (one user-defined structure, a 2-d integer array, a 1-d string array, and a handful of other basic variables). I'm having trouble figuring out hw to put all of those into a single text file and then read them back out into the appropriate variables. Is there a good demo or walkthrough for doing this anywhere?
    :
    : Any help would be much appreciated.
    :
    : Thanks,
    :
    : Perro
    :

Sign In or Register to comment.