Hello,
I know what it does, but I don't know what I could need it for. Has anyone ever used that, and why?
What do I need MacroExpandedCount for?
What do I need MacroExpandedCount for?
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Re: What do I need MacroExpandedCount for?
I use this to auto-generate DataSection elements:
Code: Select all
;-{ MACROS
Macro HASH
#
EndMacro
Macro DQ ; Required in Macros since leading '#' conflicts with #DQ$ constant
"
EndMacro
Macro QM ; Required in Macros
?
EndMacro
Macro PC ; Required in Macros
%
EndMacro
Macro ds_MakeLabel(Label)
QM#Label
EndMacro
Macro ENUM_RESET(n=0)
Enumeration n
EndEnumeration
EndMacro
Macro ds_PtrToLabel_Img(Label_Num)
; Create a pointer to an identical label named later.
; Enables automatically referencing the label in code since PB creates a pointer to the actual label.
nImagesToLoad = MacroExpandedCount ; Running count of images to load.
DataSection
Data.i QM#Label_Num ; ?Label_Num
EndDataSection
EndMacro
Macro ds_InclBin_Img(Label_Num, File)
DataSection
Label_Num: : IncludeBinary File
;Label_Num#Q: ;FYI; No closing label since CatchImage() determines when to stop reading.
EndDataSection
EndMacro
;-} MACROS
;-{ IMAGES:
; May also create #img_xxx constants for referencing if desired. Ex. #img_LOGOe = 3
ds_START(ds_ImagesToLoad) ;-! ds_img()
ds_PtrToLabel_Img(Image_1)
ds_PtrToLabel_Img(Image_2)
; CREATE IMAGE LIST AND LABELS. Image_0 reserved for no image.
ds_InclBin_Img(Image_1, "..\img\blah.ico")
ds_InclBin_Img(Image_2, "..\img\blah2.png")
;-} IMAGES
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Re: What do I need MacroExpandedCount for?
That's...very specific and very cool. Thanks for sharing! Never thought about using datasections dynamically.
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD