Loading files.0001...

Dubbsta

Active member
Joined
Jul 13, 2017
Messages
199
I saw an example long ago don't know where and can't figure it out. I know I need a string of 0s. But how do I load images with numbers 001 and so on. Thx
 

Dubbsta

Active member
Joined
Jul 13, 2017
Messages
199
Loading multiple images at once with name img.001, img.002 keeping the zeros
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
3,135
There is not command to do this but you can easily achieve this with a FOR loop and inside build the string to represent the file name. Then store the image inside an array.
 

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
878
The example in examples/mojo/gerryq/picpuzzle.cxs shows how to load pic000 pic001 etc automatically, you can use that for saving as well.
 

Dubbsta

Active member
Joined
Jul 13, 2017
Messages
199
that was it thanks jimmy must have overlooked it
appreciate you doing some digging
 

dawlane

Well-known member
CX Code Contributor
Joined
Jun 21, 2017
Messages
840
A more compact version.
Code:
Strict

Function Main:Int()
    Local fileName:="myfile"
    For Local fileNo:=0 To 1000
        Print fileName+"0000"[.."0000".Length()-String(fileNo).Length()]+fileNo+".png"
    Next
    Return 0
End Function
 

Gerry Quinn

Active member
Tutorial Author
Joined
Jun 24, 2017
Messages
151
I was trying to keep it simple and flexible for the example; in real life I'd probably do:

For Local fileNum:Int = 0 Until maxFiles Print "pic" + String( 1000 + fileNum )[ 1 .. 4 ] + ".png" Next
 
Top Bottom