FutureBasic Logo

<<    Index    >> FutureBasic

write dynamic   statement



Syntax
write dynamic deviceID, arrayName

Description
write dynamic sends the contents of a dynamic array to an open disk file. Data written to a file in this manner can be read back into memory with read dynamic.

Example
CFURLRef desktopURL, url
long j
dynamic myAry(1) as long

//Construct URL for file access
desktopURL = fn FileManagerURLForDirectory( NSDesktopDirectory, NSUserDomainMask )
url = fn URLByAppendingPathComponent( desktopURL, @"Test Read_Write Dynamic" )

//== Load Array ==
for j = 0 to 9
myAry(j) = j
next

//== Write Array To File ==
open "O", 1, url
write dynamic 1, myAry
close 1
kill dynamic myAry

//== Read File Contents into Array ==
open "I", 1, url
read dynamic 1, myAry
close 1

//== Prove File contents are available ==
for j = 0 to 9
print myAry(j)
next
WorkspaceRecycleURL( url ) // trash test file

See also
dynamic; read dynamic