Applescript doesn't understand replace_chars

Discussion in 'Mac Programming' started by blackboxideas, Oct 27, 2015.

  1. blackboxideas macrumors member

    Joined:
    Oct 17, 2012
    #1
    I was attempting to figure out a way to strip out text from the 'calendar summary' action within Automator.
    (Attempting to answer an old question raised on the Automator G+ group).

    Currently my workflow grabs the weeks calendar events, attempts to strip out the information from the summary action to just leave the event names, then sends these to notification event.

    I figured I'd be able to use Applescript to replace the text I didn't need but when I run the action I get the error:

    <<script>> doesn't understand the "replace_chars" message.

    Now I may be trying to pass Applescript something in a format it doesn't like, but I'm not too familiar with how this works...

    Here's a link to my workflow (can't seem to attach a zip of it!), but does anyone know what I may be doing wrong, or can point me in the right direction?
     
  2. Red Menace macrumors 6502

    Red Menace

    Joined:
    May 29, 2011
    Location:
    Littleton, Colorado, USA
    #2
    You need to include the code for the replace_chars handler.
     
  3. superscape macrumors 6502a

    superscape

    Joined:
    Feb 12, 2008
    Location:
    East Riding of Yorkshire, UK
    #3
    Yup.

    To expand on what Red Menace says, "replace_chars" is a handler (or function, if you prefer). Think of it as a user-defined command that takes some parameters. If you haven't defined that function in your code then you'll get an error like the one you see.

    There should be something in your code like this:

    Code:
    on replace_chars(something)
    --some stuff here
    end
    

    More info about handlers here:

    https://developer.apple.com/library...LangGuide/conceptual/ASLR_about_handlers.html
     
  4. blackboxideas thread starter macrumors member

    Joined:
    Oct 17, 2012
    #4
    Brilliant, thank you guys. I'd been doing some googling and had assumed replace_chars was something I could just call, rather than needing to define the function.
    Cheers for the link to the docs too - somehow I'd missed that, should help massively!
     

Share This Page