MattJayC

Q: Pass variable to tell handle

I have a tell handle that is in handler and after the tell I can't pass a variable into it. How can I do this?

 

Many Thanks

Matt

In Short

 

on findNameInCsv(f, BrandName)

tell _split(",", t)

--do something

log {BrandName} --I can't get this line to appear after the last tell?

end tell

end findNameInCsv


on _split(d, t)

  return tt

end _split

iMac, OS X Mavericks (10.9.4)

Posted on Aug 26, 2016 1:09 AM

Close

Q: Pass variable to tell handle

  • All replies
  • Helpful answers

  • by Hiroto,Solvedanswer

    Hiroto Hiroto Aug 26, 2016 7:00 AM in response to MattJayC
    Level 5 (7,276 points)
    Aug 26, 2016 7:00 AM in response to MattJayC

    Hello

     

    It seems a little too short for a description of the problem... I'd guess you're getting an error such as:

     

     

    tell {1, 2, 3}
        log "abc" --> error -1708 OSAMessageNotUnderstood : "{1, 2, 3} doesn’t understand the log message."
    end tell
    

     

     

     

    in which case, you need to tell me to log or tell current application to log, such as:

     

     

    tell {1, 2, 3}
        tell me to log "abc"
    end tell
    
    tell {1, 2, 3}
        tell current application to log "abc"
    end tell
    

     

     

     

    In your script, use log command like this:

     

     

    on findNameInCsv(f, BrandName)
        tell _split(",", t)
            --do something
            tell me to log BrandName
        end tell
    end findNameInCsv
    

     

     

     

    Regards,

    H

  • by Camelot,

    Camelot Camelot Aug 26, 2016 11:30 AM in response to MattJayC
    Level 8 (47,233 points)
    Mac OS X
    Aug 26, 2016 11:30 AM in response to MattJayC

    What is it you're trying to do?


    I don't know if you've stripped your code to the level where it doesn't make sense, but as far as I can tell, your expectations over how the handler works are a little off.

     

    For one:

     

    tell _split(",", t)

     

    What is 't' in this context? It's not defined or assigned prior to your script.

     

    log {BrandName} --I can't get this line to appear after the last tell?

     

    Since this is inside the 'tell _split()' block, the log message is sent to _split, which doesn't know what to do with it. Ostensibly, 'tell me to log...' could be one solution, but it's not clear to me what your goal is.

     

    As for the _split() handler,

     

      return tt


    What are you expecting this to do? I expect it to fail since 'tt' isn't defined anywhere - there is no value to return since the script doesn't know what 'tt' is.

  • by Hiroto,

    Hiroto Hiroto Aug 27, 2016 3:36 AM in response to Camelot
    Level 5 (7,276 points)
    Aug 27, 2016 3:36 AM in response to Camelot

    Hello Camelot,

     

    I believe this is a sequel to the following discussions.

     

    Adding Keywords

    https://discussions.apple.com/thread/5611159

     

     

    Yes, the code snippet presented here is a plain residue of which I had hard time to guess the current problem not to mention the original intent.

     

    Hiroto

  • by MattJayC,

    MattJayC MattJayC Aug 27, 2016 11:13 AM in response to Hiroto
    Level 1 (5 points)
    Mac OS X
    Aug 27, 2016 11:13 AM in response to Hiroto

    Hi

    IM away from computer at the moment so can't show my current working.

     

    Yes hiroto it follows on to that thread. I'm trying to alter the suffix of specific brand.

    If brand = "brandC" then

    If the suffix = ""

    Change to "_main"

    Else if it ="_n" --n being the number

    Then change n to n-1 and then change whole suffix to "_altn"

     

     

    I.e "_2" becomes "_alt1"

  • by MattJayC,

    MattJayC MattJayC Aug 30, 2016 1:58 AM in response to MattJayC
    Level 1 (5 points)
    Mac OS X
    Aug 30, 2016 1:58 AM in response to MattJayC

    (RETRACTED)

  • by MattJayC,

    MattJayC MattJayC Aug 31, 2016 1:07 AM in response to MattJayC
    Level 1 (5 points)
    Mac OS X
    Aug 31, 2016 1:07 AM in response to MattJayC

    All working now, thanks for all your help the

     

    tell me

    line was the answer,

    My other problem was from the original checklist I overlooked those that were already checked, so removed the checks as if from the beginning and now all fine.