Counting Items in the DataSection?
Just starting out? Need help? Post your questions and find answers here.
Re: Counting Items in the DataSection?
In the meantime, I no longer understand what it's all about.
Some things are far too complicated. Best as it says in the PB help ...
Some things are far too complicated. Best as it says in the PB help ...
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
- Michael Vogel
- Addict
Addict - Posts: 2823
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Re: Counting Items in the DataSection?
Post by Michael Vogel »
I need to add tons of images into a datasection and catch these images, so labels are needed. But how to create an IncludeBinary using a filename similar to the label?
The result should be something like this:
Did some tries with no success. I was generating Data.s code instead of IncludeBinary which is easier to test):
The result should be something like this:
Code: Select all
Label_01:
IncludeBinary Path# + "Image_01.png"
Label_02:
IncludeBinary Path# + "Image_02.png"
:Code: Select all
#Q=#DOUBLEQUOTE$
Macro Label(part1,part2)
part1#part2:
EndMacro
Macro Image(part1,part2)
IncludeBinary part1 + #Q+part2.jpg+#Q
EndMacro
Macro Datax(label)
Data.s "label"
EndMacro
#ImagePath= "."
Macro LabelData(Index)
;Label(Label_,MacroExpandedCount)
Label(Label_,Index)
;IncludeBinary #ImagePath + #Q+Index.jpg+#Q
;Image(#ImagePath,Index)
Datax(Index)
Data.s #Q+Index+#Q
EndMacro
DataSection
LabelData(ab)
LabelData(cd)
EndDataSection
Restore ab:
Read.s a.s
Debug aRe: Counting Items in the DataSection?
[引用]
viewtopic.php?t=52586
Michael Vogel wrote: Fri Nov 07, 2025 6:55 pm
I need to add tons of images into a datasection and catch these images, so labels are needed. But how to create an IncludeBinary using a filename similar to the label?
The result should be something like this:
Did some tries with no success. I was generating Data.s code instead of IncludeBinary which is easier to test):
That's where you use a packer like ezpack so you can extract a single file or multiple files or all files to memory from the pack dynamically. The result should be something like this:
Code: Select all
Label_01:
IncludeBinary Path# + "Image_01.png"
Label_02:
IncludeBinary Path# + "Image_02.png"
:Code: Select all
#Q=#DOUBLEQUOTE$
Macro Label(part1,part2)
part1#part2:
EndMacro
Macro Image(part1,part2)
IncludeBinary part1 + #Q+part2.jpg+#Q
EndMacro
Macro Datax(label)
Data.s "label"
EndMacro
#ImagePath= "."
Macro LabelData(Index)
;Label(Label_,MacroExpandedCount)
Label(Label_,Index)
;IncludeBinary #ImagePath + #Q+Index.jpg+#Q
;Image(#ImagePath,Index)
Datax(Index)
Data.s #Q+Index+#Q
EndMacro
DataSection
LabelData(ab)
LabelData(cd)
EndDataSection
Restore ab:
Read.s a.s
Debug aviewtopic.php?t=52586
Re: Counting Items in the DataSection?
@Michael Vogel
you need my CodeCreation Modul from
https://github.com/Maagic7/PureBasicFra ... reation.pb
This is the outout
DataSection
File_0: : IncludeBinary "File_0.jpg"
File_1: : IncludeBinary "File_1.jpg"
File_2: : IncludeBinary "File_2.jpg"
File_3: : IncludeBinary "File_3.jpg"
File_4: : IncludeBinary "File_4.jpg"
File_5: : IncludeBinary "File_5.jpg"
File_6: : IncludeBinary "File_6.jpg"
File_7: : IncludeBinary "File_7.jpg"
File_8: : IncludeBinary "File_8.jpg"
File_9: : IncludeBinary "File_9.jpg"
EndDataSection
I use CodeCreation functions to do such things, especally to create Data Sections.I need to add tons of images into a datasection and catch these images, so labels are needed. But how to create an IncludeBinary using a filename similar to the label?
you need my CodeCreation Modul from
https://github.com/Maagic7/PureBasicFra ... reation.pb
Code: Select all
; UseModule CC
;
NewList lstFiles.s()
Define I, code$
For I = 0 To 9
AddElement(lstFiles())
lstFiles() = "File_" + Str(I) + ".jpg"
Next
; CREATING the DataSection
I=0
CC::ClearCode()
CC::ADD("DataSection", CC::#CC_SHR_AFTER)
ForEach lstFiles()
code$ = GetFilePart(lstFiles()) ; get only the Filename
code$ = Left(code,ドル FindString(code,ドル ".")-1)
code$ = code$ + ": : IncludeBinary " + Chr('"') + lstFiles() + Chr('"')
Debug code$
CC::ADD(code$)
Next
CC::ADD("EndDataSection", CC::#CC_SHL_BEFORE)
CC::CopyToClipBoard()
DataSection
File_0: : IncludeBinary "File_0.jpg"
File_1: : IncludeBinary "File_1.jpg"
File_2: : IncludeBinary "File_2.jpg"
File_3: : IncludeBinary "File_3.jpg"
File_4: : IncludeBinary "File_4.jpg"
File_5: : IncludeBinary "File_5.jpg"
File_6: : IncludeBinary "File_6.jpg"
File_7: : IncludeBinary "File_7.jpg"
File_8: : IncludeBinary "File_8.jpg"
File_9: : IncludeBinary "File_9.jpg"
EndDataSection
Re: Counting Items in the DataSection?
[引用]
Michael Vogel wrote: Fri Nov 07, 2025 6:55 pm
I need to add tons of images into a datasection and catch these images, so labels are needed. But how to create an IncludeBinary using a filename similar to the label?
The result should be something like this:
The result should be something like this:
Code: Select all
Label_01:
IncludeBinary Path# + "Image_01.png"
Label_02:
IncludeBinary Path# + "Image_02.png"Code: Select all
; Path and index must be literal strings or constants, AND FILES MUST EXIST
Macro dq : "
EndMacro
Macro IncludeBin(z=)
Label_#z#MacroExpandedCount: ; starts with 1
IncludeBinary #binpath + "Image_"+dq#z#dq+MacroExpandedCount+".jpg"
EndMacro
#binpath = "/Users/Michael/Desktop/"
DataSection
IncludeBin(00)
IncludeBin(00)
EndDataSection- Michael Vogel
- Addict
Addict - Posts: 2823
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Re: Counting Items in the DataSection?
Post by Michael Vogel »
Perfect! Thank you!
Don't think your solution can be topped...
My code will look a little bit like this...
Don't think your solution can be topped...
Code: Select all
; Piero's code, I just added Data.s for testing...
Macro dq : "
EndMacro
Macro Label(counter)
Label_#counter:
EndMacro
Macro IncludeBin(z=)
Label(z)
Data.s #binpath + "Image_"+dq#z#dq+".jpg"; only for testing
;IncludeBinary #binpath + "Image_"+dq#z#dq+".jpg"
EndMacro
#binpath = "/Users/Michael/Desktop/"
DataSection
IncludeBin(001)
IncludeBin(yep)
EndDataSection
; Quick Check
Restore Label(yep)
Read.s s.s
Debug s
My code will look a little bit like this...
Code: Select all
Macro dq : "
EndMacro
Macro Label(counter)
Label_#counter:
EndMacro
Macro IncludeBin(z=)
; Label(z)
Label(MacroExpandedCount)
; Data.s #binpath + "Image_"+dq#z#dq+".jpg"
; Data.s #binpath + "Image_"+dq#MacroExpandedCount#dq+".jpg"
; IncludeBinary #binpath + "Image_"+dq#z#dq+".jpg"
IncludeBinary #binpath + "Image_"+dq#MacroExpandedCount#dq+".jpg"
EndMacro
Macro MultiInclude()
IncludeBin()
IncludeBin()
IncludeBin()
IncludeBin()
IncludeBin()
IncludeBin()
IncludeBin()
IncludeBin()
IncludeBin()
IncludeBin()
EndMacro
#binpath = "/Users/Michael/Desktop/"
DataSection
MultiInclude()
MultiInclude()
MultiInclude()
MultiInclude()
MultiInclude()
MultiInclude()
MultiInclude()
MultiInclude()
IncludeBin()
IncludeBin()
IncludeBin()
EndDataSection
; Then I need 83 lines to catch the images, cool would be something like this (doesn't work of course)...
For i=1 To 83
CatchImage(i,?Label(i))
Next i
Jump to
- PureBasic
- ↳ Coding Questions
- ↳ Game Programming
- ↳ 3D Programming
- ↳ Assembly and C Programming in PureBasic
- ↳ The PureBasic Editor
- ↳ The PureBasic Form Designer
- ↳ General Discussion
- ↳ Feature Requests and Wishlists
- ↳ Tricks 'n' Tips
- Bug Reports
- ↳ Bugs - Windows
- ↳ Bugs - Linux
- ↳ Bugs - Mac OSX
- ↳ Bugs - C backend
- ↳ Bugs - 3D Engine
- ↳ Bugs - IDE
- ↳ Bugs - Documentation
- OS Specific
- ↳ AmigaOS
- ↳ Linux
- ↳ Windows
- ↳ Mac OSX
- ↳ Raspberry PI
- Miscellaneous
- ↳ Announcement
- ↳ Off Topic
- Showcase
- ↳ Applications - Feedback and Discussion
- ↳ PureFORM & JaPBe
- ↳ TailBite