Is there a way to send different array type parameters for this in QB?
This can be used with Integer, Single, Double, Long, fixed length Strings or TYPE arrays:
Code: Select all
DECLARE SUB LoadArray (Array() AS ANY, filename$)
DECLARE SUB SaveArray (Array() AS ANY, filename$)
CLS
DIM Image(1 to 1000) AS String * 1 ' try fixed strings, single, integer, double, long, TYPE arrays
RANDOMIZE TIMER
FOR i = 1 TO 1000
Image(i) = CHR$(int(RND * 100 + 33)) ' change this calculation for the type used
NEXT
PRINT Image(10), Image(50), Image(100)
filename$ = "TestBSV.BSV"
SaveArray Image(), filename$
ERASE Image
PRINT Image(10), Image(50), Image(100)
LoadArray Image(), filename$
PRINT Image(10), Image(50), Image(100)
sleep
SUB LoadArray (Array(), filename$)
DEF SEG = VARSEG(Array(0))
BLOAD filename$, VARPTR(Array(LBOUND(Array)))
DEF SEG
END SUB
SUB SaveArray (Array(), filename$)
LB% = LBOUND(Array)
bytes% = LEN(Array(LB%))
filesize& = (UBOUND(Array) - LB%) + 1) * bytes%
DEF SEG = VARSEG(Array(0))
BSAVE filename$, VARPTR(Array(LB)), filesize&
DEF SEG
END SUB
Thanks,
Ted