Reputation: 61
I have a code like this
tell application "app"
set 1 to something
repeat with some in 1
set refpdf to field "File Attachments" of record 1
on findAndReplaceInText(theText, theSearchString, theReplacementString)
set AppleScript's text item delimiters to theSearchString
set theTextItems to every text item of theText
set AppleScript's text item delimiters to theReplacementString
set theText to theTextItems as string
set AppleScript's text item delimiters to ""
return theText
end findAndReplaceInText
set refpdf1 to findAndReplaceInText(refpdf, "some", "some2")
set libh to findAndReplaceInText(libraryname, "test", "test2")
end repeat
end tell
It gives me an error, But I should change text with the on findAndReplaceInText command, what I have done wrong?
Upvotes: 0
Views: 37
Reputation: 285074
Three issues:
some
is a reserved word, use something
elsemy
tell application "app"
set 1 to something
repeat with somethingElse in 1
set refpdf to field "File Attachments" of record 1
set refpdf1 to my findAndReplaceInText(refpdf, "some", "some2")
set libh to my findAndReplaceInText(libraryname, "test", "test2")
end repeat
end tell
on findAndReplaceInText(theText, theSearchString, theReplacementString)
set AppleScript's text item delimiters to theSearchString
set theTextItems to every text item of theText
set AppleScript's text item delimiters to theReplacementString
set theText to theTextItems as string
set AppleScript's text item delimiters to ""
return theText
end findAndReplaceInText
Upvotes: 2