Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Access to data
#2
Code:
DECLARE SUB UpdateMatrix (FileName$)
DECLARE SUB LoadMatrix (FileName$)
DECLARE SUB MakeMatrix (FileName$)
DIM SHARED Matrix$(60, 60)


SUB LoadMatrix (FileName$)
        OPEN FileName$ FOR INPUT AS #1
        FOR y = 1 TO 60
        FOR x = 1 TO 60
        INPUT #1, Matrix$(x, y)
        NEXT
        NEXT
        CLOSE #1
END SUB

SUB UpdateMatrix (FileName$)
        OPEN FileName$ FOR OUTPUT AS #1
        FOR y = 1 TO 60
        FOR x = 1 TO 60
        m$ = m$ + Matrix$(x, y) + ","
        NEXT
        PRINT #1, LEFT$(m$, LEN(m$) - 1)
        m$ = ""
        NEXT
        CLOSE #1
END SUB

SUB MakeMatrix(FileName$)
        OPEN FileName$ FOR OUTPUT AS #1
        FOR y = 1 TO 60
        FOR x = 1 TO 60
        m$ = m$ + "Empty!,"
        NEXT
        PRINT #1, LEFT$(m$, LEN(m$) - 1)
        m$ = ""
        NEXT
        CLOSE #1
END SUB


Okay! that's not too hard.

Before you do anything, you have to have a matrix created. Just call:
Code:
MakeMatrix "Matrix.txt"
Now remember, after a Matrix is created, if you call this sub again it will erase everything in the matrix. Once you have a matrix made, you have to load it.
Code:
LoadMatrix "Matrix.txt"
Once it is loaded, all you have to do to change a value is this:
Code:
Matrix$(10, 10) = "Yay!!"
That will change the value of the 10 by 10 of the matrix to "Yay!!" Now, even though it is changed in the program, it isn't saved. The last thing you do before you close the program is:
Code:
UpdateMatrix "Matrix.txt"
And that's it!

I hope this will suffice, but if not i'll be right here!
Reply


Messages In This Thread
Access to data - by brucem - 04-01-2004, 06:37 AM
Access to data - by Pyrodap - 04-01-2004, 07:24 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)