These are cool (and it’s good to know that there are techniques for executing arbitrary strings).
Unfortunately, both versions only work for images in the top-level directory. This:
put (“imagedir1/image1”, “imagedir2/image2”) into foo
if value(“anyImageFound” & foo) then
put “whee!”
end if
gives the error:
STInvalidNumberException Value is not a number: IMAGEDIR1
Is there a way to force SenseTalk to see these items as strings rather than expressions? I could change the working directory, but then I’d be back to searching for each item individually, and since all my code is based on building the path strings I’d rather keep it that way.
Yes. The problem is that when SenseTalk creates a text representation of the list (in order to concatenate it with the name of the function) it doesn’t put quotes around your image names. You can force it to do this by setting the listPrefix, listSeparator, and listSuffix properties, like this:
put ("imagedir1/image1", "imagedir2/image2") into foo
set the listPrefix to <<(">>
set the listSeparator to <<",">>
set the listSuffix to <<")>>
if value("anyImageFound" & foo) then
put "whee!"
end if