0

I am getting the error:

error "GarageSale 7.0.21 got an error: Can’t continue replaceText." number -1708

This part of the code is highlighted by the error:

replaceText(FindText, "", des)

I have dialog box for entering search text. I then want a loop to go through through each title and remove the search text if found by replacing it with a blank string.

set theReply2 to (display dialog "Enter new replacement text" default answer "" buttons {"Cancel", "Continue"} default button "Continue")
set FindText to text returned of theReply2


tell application "GarageSale 7.0.21"
    repeat with theListing in (get selected ebay listings)
        set des to get the title of theListing
        set the title of theListing to replaceText(FindText, "", des)
    end repeat
end tell

on replaceText(find, replace, textString)
    set prevTIDs to AppleScript's text item delimiters
    set AppleScript's text item delimiters to find
    set textString to text items of textString
    set AppleScript's text item delimiters to replace
    set textString to "" & textString
    set AppleScript's text item delimiters to prevTIDs
    return textString
    
end replaceText
1
  • When calling a handler from within a tell statement, you need to use the terms my or of me to target the script - see the AppleScript Language Guide.
    – red_menace
    Jun 4, 2022 at 13:11

1 Answer 1

2

Thank you for the suggestion.

Added "my" and it now works.

set theReply2 to (display dialog "Enter new replacement text" default answer "" buttons {"Cancel", "Continue"} default button "Continue")
set FindText to text returned of theReply2


tell application "GarageSale 7.0.21"
    repeat with theListing in (get selected ebay listings)
        set des to get the title of theListing
        set the title of theListing to my replaceText(FindText, "", des)
    end repeat
end tell

on replaceText(find, replace, textString)
    set prevTIDs to AppleScript's text item delimiters
    set AppleScript's text item delimiters to find
    set textString to text items of textString
    set AppleScript's text item delimiters to replace
    set textString to "" & textString
    set AppleScript's text item delimiters to prevTIDs
    return textString
    
end replaceText

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .