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

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.