Re: text returned to record
Re: text returned to record
- Subject: Re: text returned to record
- From: "Stockly, Ed" <email@hidden>
- Date: Thu, 11 Nov 2010 13:08:05 -0600
- Acceptlanguage: en-US
- Thread-topic: text returned to record
Title: Re: text returned to record
You may need to provide an actualy snippet of your script, but here’s a few thoughts:
Dialogs aren’t really designed to return multiple values. To convert this text into a record would take a fair amount of parsing.
Based on the record labels I’m assuming that those labels are predetermined, which is good because you can’t define record labels at runtime in appleScript.
So, here’s an example of doing what you asked for....
display dialog "For the record" default answer "ORDER_ID:\"61\", ITEM_ID:\"36\", ORDER_NUMBER:\"223-0044\", PROPERTY_ID:\"223\""
set userResponse to the text returned of the result
log userResponse
set recordDefault to {ORDER_ID:"", ITEM_ID:"", ORDER_NUMBER:"", PROPERTY_ID:""}
set AppleScript's text item delimiters to {"\""}
set recordData to text items of userResponse
set ORDER_ID of recordDefault to item 2 of recordData
set ITEM_ID of recordDefault to item 4 of recordData
set ORDER_NUMBER of recordDefault to item 6 of recordData
set PROPERTY_ID of recordDefault to item 8 of recordData
return recordDefault
But I wouldn’t do it this way. Ever. It’s relying on the user to flawlessly enter complex data with correct delimiters. It’s bound to fail.
Instead I would use choose from list in combination with dialogs to arrive at a more bulletproof result.
If you want to see an example, let me know.
HTH,
ES
On 11/11/10 10:54 AM, "Paul Abney" <email@hidden> wrote:
I am trying get a record from the text returned of a dialog box. The text is formated as such:
ORDER_ID:"61", ITEM_ID:"36", ORDER_NUMBER:"223-0044", PROPERTY_ID:"223"
I want to paste it into a dialog box a get a proper record, however I am completely stumped. Any clues on how to do this would be greatly appreciated.
Paul
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden