Good evening all,
Is it possible to pass a Variable to "IndudeBinary"?
I get the following error when writing below code. "Only a literal string can be put after IndudeBinary".
IncludeBinary is executed at compile time, so you can use a variable for it. That said you can use a Macro instead of the procedure and it should work.
file$ = OpenFileRequester("Select a file","","Text (.txt)|*.txt|All files (*.*)|*.*",0)
If file$
If ReadFile(0, file$)
length = Lof(0) ; get the length of opened file
*MemoryID = AllocateMemory(length) ; allocate the needed memory
If *MemoryID
bytes = ReadData(0, *MemoryID, length) ; read all data into the memory block
Debug "Number of bytes read: " + Str(bytes)
EndIf
CloseFile(0)
EndIf
EndIf
Norm
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari
Fred wrote: Sun Dec 10, 2023 5:59 pm
IncludeBinary is executed at compile time, so you can use a variable for it. That said you can use a Macro instead of the procedure and it should work.
Hi Fred!
Yes, it worked in a Macro, however it doesn't work in the following case:
BEFORE your code compiles, the Macro's are expanded to their actual code representation.
Variables are undefined or empty, so Include's cannot act correctly.
If your Macro uses a literal string, then it will be seen when Include's are executed.
DataSection's are also available before compile.
That is why it was suggested to put your data or filenames there.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum