After struggling with this problem in the past weeks, I decided to post it here. I’m working on an app which uses about 400 images with systematically named files as follows. I need to read any of these images by using TextField input from users, which will be a filename in String format, “a0001.jpg”.
a0001.jpg
a0002.jpg
a0003.jpg
…
First I tried FolderItem approach to read these images. However, I wondered if I can drag these images into a folder in my project (I learned that the images are converted to Picture format) and read using TextField input and put it into Canvas. I learned that I can do “Canvas.Backdrop=a0001” and it works. But can I do something like the followings?
Dim a As String
a=TextField.Text
Canvas.Backdrop=a
I tried that approach but I need to have those 400 images in the same folder with the execution file after build. I thought that by including all picture files into the project, I can have a single execution file (on Mac) which would be simple and handy…
a) Add all images to the project, then use the images by name.
b) use a CopyFiles step to get all images to the built app. On the Mac this images should be copied to the Recources folder. Then access the names with the code that Dave mentioned.
I would use one of these approaches if the number of images is relatively low and the images don’t change.
c) If you have a lot of small images you could use a packer like https://www.codeandweb.com/texturepacker . I’ve used this for the web, but I’m not sure how you could use this in Xojo.
d) for a lot of large images you could use a database or a virtual volume.
If you have problems don’t wait 2 weeks. Make a reasonably simple example and we could have a look.