getAllImages

Below I have pasted a section of a function with corresponding console output in bold. I am having problems with the everyimagelocation funciton. the result is giving me no information. I could really use some help to tell me why this is happening.

Mike

to findAllChars char_folder, label, rect
put “IIA::findAllChars - ENTER - char_folder=” & char_folder
put “IIA::findAllChars - ENTER - label=” & label
put “IIA::findAllChars - ENTER - rect=” & rect

IIA::findAllChars - ENTER - char_folder=inputFieldChars
IIA::findAllChars - ENTER - label=DEFAULT
IIA::findAllChars - ENTER - rect=(95,280,259,294)

Utilities.GoHome()
setoptions searchrectangle, rect
repeat with each character of label
	if it is equal to space then delete it from label
end repeat
put "IIA::findAllChars - label=" & label

IIA::findAllChars - label=DEFAULT

set string to empty
repeat with i =1 to the number of characters in label
	if string contains character i of label  then 
		//put "contains " && character i of label && label 
	else
		//put "characters/" & character i of label into item i of listOfCharacters
		put "" & char_folder & "/" & character i of label into item i of listOfCharacters
	end if
	put character i of label after string
end repeat
put "IIA::findAllChars - listOfCharacters=" & listOfCharacters

IIA::findAllChars - listOfCharacters=inputFieldChars/D,inputFieldChars/E,inputFieldChars/F,inputFieldChars/A,inputFieldChars/U,inputFieldChars/L,inputFieldChars/T

set temp1 to item 1 of listOfCharacters
repeat with i = 2 to the number of characters in label
	put item i of listOfCharacters into temp2
	put temp1 &&& temp2 into finalListOfChars
	put finalListOfChars into temp1
end repeat
put "IIA::findAllChars - finalListOfChars=" & finalListOfChars

IIA::findAllChars - finalListOfChars=(inputFieldChars/D,inputFieldChars/E,inputFieldChars/F,inputFieldChars/A,inputFieldChars/U,inputFieldChars/L,inputFieldChars/T)

put everyimagelocation(finalListOfChars) into coords
put "IIA::findAllChars - coords=" & coords

IIA::findAllChars - coords=((99,287),(106,287),(113,287),(120,287),(127,287),(134,287),(141,287))

insert the result into imageDetails
put "IIA::findAllChars - imageDetails=" & imageDetails

IIA::findAllChars - imageDetails=()

I should have titled the thread… Problems with everyimagelocation()

I just figured out the problem. You can’t have the “put” line between the “everyimagelocation” line and the “the result” line. Doing so invalidates the results.

Mike

Yes, that’s the way ‘the result’ works – it always gives the result (if any) from the immediately preceding command. For situations where you would like to access an earlier result, SenseTalk also remembers a list of the most recent non-empty results, which you can access through the resultHistory global property.

On a side note, I noticed a couple of things in your script that could be simplified. This loop:

repeat with each character of label 
if it is equal to space then delete it from label 
end repeat 

could be simplified to just

delete space from label

which is equivalent to

delete every occurrence of space from label

Also, these two lines:

put temp1 &&& temp2 into finalListOfChars 
put finalListOfChars into temp1 

could be replaced by

insert temp2 into temp1

Neither of those is really significant, but less code is always nice so I thought I’d mention them. :slight_smile: