Hi Folks-
I am trying to split up a string (1.456789.100) and pull the middle 6 digits out, by changing the text item delimter to “.” This works in a test scenario:
to split(fullitemcode, vdelimiter)
set AppleScript's text item delimiters to vdelimiter
set fullitemcode to fullitemcode's text items --turns foundtext into a list
set AppleScript's text item delimiters to {""} --returns delimiter to apple's default
return fullitemcode
end split
set foundText to {"1.343455.100", 3333}
set fullitemcode to first item of foundText
display dialog fullitemcode
set itemcode to second item of split(fullitemcode, ".")
display dialog itemcode
but when I place it into the growing actual script, the split fails, and returns the whole string again. It doesn’t seem to matter if I put the split function at the beginning or just before the actual function.
to split(fullitemcode, vdelimiter)
set AppleScript's text item delimiters to vdelimiter
set fullitemcode to fullitemcode's text items --turns foundtext into a list
set AppleScript's text item delimiters to {""} --returns delimiter to apple's default
return fullitemcode
end split
tell application "Adobe InDesign CS2"
set foundText to {}
tell document 1
set searchResults to search text frames for "1.^9^9^9^9^9^9.^9^9^9"
repeat with x from 1 to count of searchResults
repeat with y from 1 to count of item x of searchResults
try
set selection to item y of item x of searchResults
end try
try
set end of foundText to text of selection
end try
end repeat
end repeat
end tell
end tell
if (count of foundText) is 0 then
display dialog "A code was not found in the current document (1.xxxxxx.xxx)" buttons {"Cancel"} with icon stop
end if
set fullitemcode to first item of foundText --pulls first instance of itemcode from returned list
display dialog fullitemcode
fullitemcode as string
set itemcode to first item of split(fullitemcode, ".")
display dialog itemcode
thanks for any help in advance,
Ralph