Page 1 of 1

Expressions in DataSection: Length: Data.i ?End - ?Start

Posted: Fri Nov 04, 2016 2:20 pm
by Kurzer
Hello,

I have no idea, if this is a bug or simply not supported.

It would be nice, if one can use simple expressions also in DataSections, such as like in the normal program code.
Here is a little example which tries to encode the length of an included binary file as Data.i entry within the DataSection itself. But this is not allowed (syntax error), althought the same expression is allowed if used as command parameter (see line 2):

Code: Select all

Debug "Length of file: " + Str(PeekI(?Len))
Debug "Length of file: " + Str(?Len - ?Start)

DataSection
	Start:
	IncludeBinary #PB_Compiler_Home +"Examples\3D\Data\Siren.ogg"
	Len:
	Data.i ?Len - ?Start  ; <-- Why this is disallowed? Comment this line for a second test
	Len2:
	Data.i ?Len
EndDataSection