0

I am trying to do some math using the "date" command. But fist i need to turn text input if a date "MM/DD/YY" into something I can work with. In applescript I can do this:

    set MyTempTextInfo to "12/12/12"
    set MyTempTextInfo to (date MyTempTextInfo) as string
    display dialog MyTempTextInfo -- just to confirm another way of my answer

No issues and gives me the answer: "Wednesday, December 12, 2012 at 12:00:00 AM"

If I do this in Xcode cocoa app:

on buttonPresson_(sender)
    set MyTempTextInfo to (date "12/12/12") as string
    display dialog MyTempTextInfo
end buttonPresson

No issues and gives me the pop-up answer: "Wednesday, December 12, 2012 at 12:00:00 AM"

Now if I try to give it a variable in Xcode cocoa app... no go.

on buttonPresson_(sender)
    set MyTempTextInfo to "12/12/12"
    set MyTempTextInfo to (date MyTempTextInfo) as string
    display dialog MyTempTextInfo
end buttonPresson

* -[AppDelegate buttonPresson:]: Can’t make «script» into type string. (error -1700)

What am I missing. I have tried making MyTempTextInfo as text / string and still errors. Anyone have any idea?

Update

I also found this version has the same error

on buttonPresson_(sender)
    set MyTempTextInfo to (date ("12/12/12")) as string
    display dialog MyTempTextInfo
end buttonPresson

* -[AppDelegate buttonPresson:]: Can’t make «script» into type string. (error -1700)

1 Answer 1

1

I found a working solution for the moment. If I am wrong feel free to let me know.

on buttonPresson_(sender)
    set MyTempTextInfo to "12/12/12" as text
    set MyTempTextInfo to (current application's date MyTempTextInfo as date) as string
    display dialog MyTempTextInfo
end buttonPresson
Sign up to request clarification or add additional context in comments.

1 Comment

"as string" only needed if you need a string for things like display dialog. Works other wise as needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.