Read images added to project

Dear Forum,

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”.


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

Any comments will be much appreciated!

FolderItem will be the best way. Construct the filename, get a FolderItem, and open it as a Picture.

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…

dim f as folderitem=app.executablefile.parent.parent.child("resources").child(textfield.text)

It may not be EXACTLY that, but search this forum and you will find other references, this was off the top of my head

You might want to have a look at in particular the getresource method.

There are quite a few methods you can use here:

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 . 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.