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)

Tim Joe
  • 475
  • 8
  • 18

1 Answers1

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
Tim Joe
  • 475
  • 8
  • 18
  • "as string" only needed if you need a string for things like display dialog. Works other wise as needed. – Tim Joe Sep 15 '14 at 22:04