Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 152
  • Last Modified:

saving text and data arrays to a disk file

ok what is the cleanest and quickest way to save the contents of an three dimensional variant array to disk (preferable as a binary file not ASCII)
0
spg01
Asked:
spg01
1 Solution
 
zivfCommented:
No clean way but to create a special function for it?
Don't you know the data type of the array items?
In MFC you have serialization, but it is internally managed, and to say gently, not the easiest thing in the world to design and program...
0
 
gikamCommented:
declare the variabile say xxx as 3d array type
use PUT #1,xxx
0
 
fguerreiro_inixCommented:
Instead of an tridimentional array, make an array of a userdefined type.

This example uses the Put statement to write data to a file. Five records of the user-defined type Record are written to the file.

Type Record      ' Define user-defined type.
      ID As Integer
      Name As String * 20
End Type

Dim MyRecord As Record, RecordNumber      ' Declare variables.
' Open file for random access.

Open "TESTFILE" For Random As #1 Len = Len(MyRecord)

For RecordNumber = 1 To 5      ' Loop 5 times.
    MyRecord.ID = RecordNumber      ' Define ID.
    MyRecord.Name = "My Name" & RecordNumber   ' Create a string.
    Put #1, RecordNumber, MyRecord      ' Write record to file.
Next RecordNumber

Close #1      ' Close file.

if you want to encrip your data, use Xor operator

Hope this helps
Regards
0
 
lawnrangerCommented:
How about back to (Visual) Basics?
I respectfully submit the following...

Dim a(1 To 10, 1 To 10) As Integer
Dim b(1 To 10, 1 To 10) As Integer
Dim i As Integer, j As Integer
For i = 1 To 10
  For j = 1 To 10
    a(i, j) = i * j
  Next j
Next i
Open "C:\Test.bin" For Binary As #1
Put #1, , a
Close #1
Open "C:\Test.bin" For Binary As #2
Get #2, , b

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now