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

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Kurzer
Enthusiast
Enthusiast
Posts: 670
Joined: Sun Jun 11, 2006 12:07 am
Location: Near Hamburg

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

Post 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
PB 6.02 x64, OS: Win 7 Pro x64 & Win 11 x64, Desktopscaling: 125%, CPU: I7 6500, RAM: 16 GB, GPU: Intel Graphics HD 520, User age in 2024: 56y
"Happiness is a pet." | "Never run a changing system!"