I am having trouble opening a data file as a binary stream. I have the file name and path and do not want a dialog. I have been unable to find adequate documentation for Xojo 2019r2. Running OSX 10.15.6 and Xojo 2019r3.1.
Thanks for help on this simple operation.
from there you open a binary stream
http://documentation.xojo.com/api/files/binarystream.html#binarystream-open
Thanks, Norman. I could not figure out how to open the file except using the old way:
instream is global binary stream declared in Properties,
dataFile is the folder,
so the old way works:
instream = dataFile.OpenasBinaryFile(false)
This old way is no longer documented in the Language Reference and whatever is the new way in 2019r2-3 is unclear or missing.
See New Project>Examples>Files>BinaryStream>BinaryStream.xojo_binary_project
Thanks, Julian. But I want the data in the binary stream to be accessible globally (the data must be accessible by two methods), and I have been unable to declare it in Properties as a global folder item. The old way works with
Dim instream As Binary Stream. (public)
Oh sorry I thought you wanted to open a file without using a dialog box.
If you want to access it globally then the easiest method is to create a Module, then add instream as a BinaryStream Property to that. See https://documentation.xojo.com/getting_started/using_the_xojo_language/modules.html for more info on that.
Where is the file? Modern versions of macOS include “Security” features which make it harder to arbitrarily open files from certain places.
Below is a code snippet I use to open a binarystream in a class, while having the stream as a property of said class (so that subclasses and children of that class can access it). This method closes a read-only stream and opens a read/write stream so the data can be modified.
Public Function edit(byref errorMessage as string) as boolean
stream.close
Try
stream = binaryStream.open( folderitem, true )
Catch err as IOException
errorMessage = err.message
return false
End try
meditmode = true
return true
End Function