Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg As Dword, MyArray() As Long
Function PBMain() As Long
Dialog New Pixels, 0, "Array Read/Write Test Code",300,300,240,200, %WS_OverlappedWindow To hDlg
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local i As Long
Select Case Cb.Msg
Case %WM_InitDialog
ReadArray 'or, you app loads the array somewhere
Case %WM_Destroy
SaveArray
End Select
End Function
Sub SaveArray
'this time, your app may have modified the size of the array
Local i as Long
i = UBound(MyArray)
Open "myarray.dat" For Binary As #1
Put #1,, i 'size of array
Put #1,, MyArray() 'save the entire array
Close #1
? "Array saved!"
End Sub
Sub ReadArray
Local i As Long
Open "myarray.dat" For Binary As #1
Get #1,, i 'get size of array
Dim MyArray(i) 'DIM array to that size
Get #1,, MyArray() 'read in the entire array
Close #1
? "Array read!"
End Sub
'gbs_00766
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm