Applescript buttons returned from display dialog

Hi!
I have been learning Applescript for about a month and found the following issue which I thought was an easy implementation.
On the "text returned" I get the error condition described. Do not understand!
Any help would be appreciated.
display dialog ("ENTER COMPANY NAME") with title ("TOTAL SHARE SPECIFICATION")
buttons {"Cancel", "Company"} default button "Company" default answer ""
  set BUTTON_Returned to button returned of the result
  set CompanyName to text returned of the result
error "Can’t get text returned of \"Company\"." number -1728 from text returned of "Company"
MacBook 6.1     OS X Yosemite     Vn 10.10.1
Script Editor  Vn. 2.7 (176)
Applescript 2.4
Regards

No question that Applescript can be frustrating to learn. Many things about it have to be figured out by trial and error and when dealing with scripting applications all bets are off. The application designer can pretty much do as they want so what works in one app might not work in another even though you are using the same and correct applescript
I find Introduction to AppleScript Language Guide by Apple to be a good source of answers and usually always have it open when I'm scripting  for quick reference.
Spend some time getting familiar with the script editor. It is intelligent and can usually steer you in the right  direction when it comes to debugging.  Especially get use to and pay attention to the colors it assigns to items in your script.
For example in your original script notice the colors of Button_Returned and CompanyName (your variables) and compare those to result and button returned. Also notice how text returned is a different color from button returned even though both are essentially the same thing. This is an indication that something is not right and it is where the error message occurred. (for a list of the default colors used open the Script Editors preferences and look at the Formatting tab).
Notice  also how the editor formats your scripts, again the way the script gets formatted can tell you a lot if there is an error.
Finally the error messages while cryptic can offer some clues. In your case the error message was
error "Can’t get text returned of \"Company\"." number -1728 from text returned of "Company"
generated by the line
set CompanyName to text returned of the result
The last part of the error message is essentially the line that caused the error after evaluation. So here result evaluated to “Company” which doesn't seem right, display dialog returns a record.
Finally there is the log statement which will print its value to the log window
Hope this helps
regards

Similar Messages

  • ADF FACES: how to make a page re-render after returning from a dialog

    Using EA15.
    I am using a process to display a confirmation dialog to the user. However, when the dialog exits, the previous page is not re-rendered. The result of the operation that was confirmed by the dialog makes numerous changes to the underlying model that affect the layout of the original page. All these changes are made in the return listener.
    How can I force the original page (the one that launched the process) to fully re-render upon return?
    Thanks.

    Thanks Adam, but no luck.
    My situation is slightly different then the original poster's. I have a table with a 'add row' button in the header, and a 'modify row' button in each row. They both point at the same dialog to enter multiple data attributes about that row of data from a collection in the model. The 'modify row' pops a dialog and modifies item fine, but doesn't re-render the table automatically on return. If user performs any action on the page, the resulting table will then show the correct data. The 'add row' button on the header, but otherwise identical, modifes and re-renders correctly.
    I would think this is a fairly common use case. Anyone have example code of this that can be shared? The ADF dialog demo only modifies a single uicomponent, not the entire row or table. And we have other code which demonstrates that works fine.
    Is there a problem with a row button return listener adding a partial target of the table in which is resides? Whereas the header button (being outside of the table?) is capable of adding the table as a partial target?
    Table.jsp:
    <af:table value="#{formBean.dataBean.collection}" var="row" binding="#{formBean.table}">
    <af:column>
    <af:outputText value="#{row.attr1}"/>
    </af:column>
    <af:column>
    <af:outputText value="#{row.attr2}"/>
    </af:column>
    <af:column>
    <af:commandButton text="Modify..." action="#{formBean.modifyAction}" partialSubmit="true" useDialog="true" returnListener="#{formBean.dialogReturned"/>
    </af:column>
    <f:facet name="actions">
    <af:commandButton text="Add Row..." action="#{formBean.addAction}" partialSubmit="true" useDialog="true" returnListener="#{formBean.dialogReturned"/>
    </f:facet>
    </af:table>
    FormBean.java
    public void dialogReturned(ReturnEvent event) {
    Item item = (Item) event.getReturnValue();
    if (! dataBean.collection.contains(item) {
    dataBean.collection.add(item);
    table.setValue(dataBean.collection);
    AdfFacesContext.getCurrentInstance().addPartialTarget(table);
    DialogForm.java
    public String submitAction() {
    // perform some work against the row item AdfFacesContext.getCurrentInstance().returnFromProcess(item);
    ...

  • Applescript button returned of list

    Hi
    Here is my script:
    set firstList to {"Sincronizza proprietà avanzate", "Escludi proprietà avanzate"}
    set listchoice1 to choose from list firstList with prompt "Le proprietà avanzate di una cartella sono l'icona della cartella, la posizione degli elementii al suo interno e l'icona delle cartelle al suo interno." with title "Fai una selezione" without multiple selections allowed
    At the end of the list there are two buttons, "Ok" and "Cancel", if I select "Ok" it goes ahed, if I select "Cancel" it still goes ahed.
    Instead I want that if the button "Cancel" is selected, regardless of the choice made, the application must close.
    How can I do that?

    Returend result from choose from list
    Result
    If the user clicks the OK button, returns a list of the chosen number and/or text items; if empty selection is allowed and nothing is selected, returns an empty list ({}). If the user clicks the Cancel button, returns false
    So check to see if the result returned is false and if it is exit.
    Something like (there are other ways to do this)
    if listchoice1 is false then
         tell me to quit
    end

  • External display resolution changes after returning from display sleep

    I often use an external display as a second screen with my Macbook Pro (OS X 10.8.2)  However, when I return to the computer after the display has gone to sleep, the external display resolution changes when the display reappears.  Then I have to go into System Preferences > Display and "Detect Displays" in order to return the external display to the proper resolution.
    Does anybody know of a way for me to avoid having to do this every time my display sleeps?
    Thank you,
    Adam

    I have the exact same problem.
    I found the key combination ⌘ alt F2 also restores the proper resolution on both displays, however it's still a bit annoying

  • Returns from file dialog to be caught?

    first of all i ll brief you about my code ,my file contains two cloumns first col is taken as x-axis and other is my y-axis .so i have succeded in doing so but my prob now is each and every time i need to read diff files for doing so i should write the full path in my prog if it is not the same file,this prog is called by other prog which in turn is called by click of button .now all these things are working but i need it to b automated ,in the sense when i click a button i need to open a file dialog where i can choose a appropriate file and all the other functions should b taken care.so plssss let me know wat can i do for this sir plss its little urgent.
    waiting for your reply .

    Well Jussi should really love you.
    Did it ever occur to you to post some formatted code? Did you ever think of putting a few line breaks in your posts? I don't know what your question is although it might be how to use a FileChooser.

  • Display dialog, getting both text returned and button returned

    I am most of the way through my first major project in applescript. I want to get both the text returned of and the button returned of a dialog box. Is this possible?
    So basically i want to do the below without having the dialog box run twice.
    set thebutton to the button returned of (display dialog "Already Assigned!" & return & "Please assign a new letter" default answer "…" buttons {"Cancel", "Delete Previous Location for this Letter", "OK"} default button "OK")
    set theLetter to the text returned of (display dialog "Already Assigned!" & return & "Please assign a new letter" default answer "…" buttons {"Cancel", "Delete Previous Location for this Letter", "OK"} default button "OK")
    Rich

    Well thanks for the fast response, both work fine, cheers. That problem is now sorted.
    However while i was waiting for the responses i came across another problem, i would like to delete a specified item from a list. This is not the actual script but i was using it to test the syntax. So basically how would i go about deleting the the letter P from a list PQ
    set letterlist to {}
    display dialog letterlist as string
    set namep to "P"
    copy (namep) to end of letterlist
    set nameq to "Q"
    copy (nameq) to end of letterlist
    display dialog letterlist as string
    set theKeyPressed to "P"
    repeat with each_item in letterlist
    if each_item contains theKeyPressed then
    delete each_item
    end if
    end repeat
    display dialog letterlist as string
    Rich

  • AppleScript Display dialog if clause

    What I'm trying to do now is have a pop up trigger from a calendar event(already know that part) and ask a user if they are ready to launch another workflow. If they select NO I want there to be a 5 minute delay and then have the same question asked again. I cant figure out how to loop the original question back through and I know there has to be a way to do it.
    Heres my code so far...
    set question to display dialog "If you're ready to clock in, punch for lunch, or clock out click YES. If you are stuck on a chat cancel this bad boy." buttons {"No", "Yes"} default button 2
    set answer to button returned of question
    if answer is equal to "Yes" then
              tell application "Finder" to activate
              tell application "System Events"
      keystroke "c" using {command down, control down, option down}
              end tell
    end if
    if answer is equal to "No" then
              display dialog "Automator will snooze for 5 minutes" buttons {"Snooze", "Snooze"} default button 2
    delay 300
    display dialog question
    end if
    Thanks in advanced for any input!

    You can also just put the whole thing in another repeat statement:
    repeat -- forever
      set answer to button returned of (display dialog "If you're ready to clock in, punch for lunch, or clock out click YES. If you are stuck on a chat cancel this bad boy." buttons {"No", "Yes"} default button 2)
      if answer is equal to "Yes" then
        tell application "Finder" to activate
          tell application "System Events"
            keystroke "c" using {command down, control down, option down}
          end tell
        exit repeat
      else
        display dialog "Automator will snooze for 5 minutes" buttons {"Snooze"} default button 1 giving up after 10
        delay 300
      end if
    end repeat

  • Display Dialog button misbehavior

    -- This is not an earth-shattering matter, but I've wondered if others have encountered some inconsistent button behavior with 'Display dialog'
    -- For example, consider the following, which wasn't misbehaving when I posted this
    display dialog "Go" buttons {"OK", "Quit"} default button 1 cancel button 2
    --What happens sometimes is that button 1, although properly highlighted in the display, won't respond to the return button (must be clicked on directly). This behavior is usually consistent for a given display, while other displays in the same script may behave properly.
    -- Other Info:
    -- I've tried using the button name rather than number (no difference).
    -- I can't be certain, but I think displays with default answers have never misbehaved for me.
    -- This is something I've observed on and off for months, but have never really pursued it.
    -- I've found nothing about the affected displays that seems unusual or atypical.
    -- I'm not expecting a work-around (although that would be great), just wondering if others see this.
    --TIA

    The simplest way to do this is to create a stay-open applescript application with the following code:
    on quit
              display dialog "Please Backup Your Data
    There is a risk of data loss if the machine experiences a hardware failure or an accident occurs" buttons {"Log Out", "Cancel"} default button "Cancel" with icon stop
              if button returned of result is "Log Out" then
                        continue quit
              end if
    end quit
    and then run it at startup.  when the user tries to logout, the on quit handler will run and the program won't quit unless they choose logout; otherwise the program won't quit and the logout will be canceled.

  • Applescript: display dialog / saving to . . .

    The following script always has the document folder selected in the "save as" window
    How do I designate another locaiton  such as the desktop
    or even  create a folderat the desk top and have it selected as the save to
    (G5 PPC OS X 10.5.8 Applescript)
    Thank you
    say (text returned of (display dialog ¬
        "Enter what you would like synthesized into a file." default answer ¬
        "Welcome to Mac OS X.")) saving to (choose file name with prompt ¬
        "Choose where you would like to to save the file." default name "say.aiff")

    The choose file / defaul location is a reference to a folder which is useful
    But how do I change the locaiton from the documents folder to the desktop
    The desktop is not a folder and won't work with this comand
    I googled and come up with  a solution:
    say (text returned of (display dialog ¬
        "Enter what you would like synthesized into a file." default answer ¬
        "Welcome to Mac OS X.")) saving to (choose file name with prompt ¬
        "Choose where you would like to to save the file." default name "say.aiff" default location path to desktop)
    Thanks for pointing me in the right direction

  • Multiple entries by user in display dialog?

    Looking to prompt a user of an applescript to enter two variables in that I will then export to Excel. Can I display a dialog box that prompts the user for two pieces of data? I've heard of Applescript studio or something like that name...is this more in that realm? Here is the script I have so far for prompting the user for the info, except that it is a series of dialog boxes. Looking to make it concise and have all the info entered at once.
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px;
    color: #000000;
    background-color: #FFDDFF;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    set slots to {"A", "B", "C", "D", "E", "F"}
    set rooms to {"1 ", "2", "3", "4", "5", "6", "7", "8", "9", "10"}
    set chosenslot to (choose from list slots with prompt "What slot does your first class go into?  Choose one." without multiple selections allowed) as text
    if chosenslot is not "false" then
    display dialog "You chose " & chosenslot & ". Next choose the course to go into this slot"
    set chosencourse to (choose from list rooms with prompt "What course will go into slot " & chosenslot & "?   Choose one." without multiple selections allowed) as text
    display dialog "So " & chosenslot & " will be put into " & chosencourse & " CORRECT??"</pre>
    dan

    If the default answer of a dialog contains a return, then you can +use a return in the answer+ (in this case, the return key won't be used for the default button, although the enter key will still be used). Going a little bit further than casdvm, but using the same idea (using a return as a delimiter between items), you can fake a multiple input dialog. I have a general purpose handler that will get multiple input items (it is a bit long but has a lot of options):
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px; height: 340px;
    color: #000000;
    background-color: #FFEE80;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    on run -- example
    set {Slot, Course} to (InputItems for {"• Class slot", "• Course"} with Prompt given Title:"Data Entry")
    display dialog "Slot:  " & (quoted form of Slot) & return & "Course:  " & (quoted form of Course) with title "results"
    end run
    to InputItems for SomeItems given Title:TheTitle, Prompt:ThePrompt
    displays a dialog for multiple item entry - a carriage return is used between each input item
      for each item in SomeItems, a line of text is displayed in the dialog and a line is reserved for the input
        the number of items returned are padded or truncated to match the number of items in SomeItems
    to fit the size of the dialog, items should be limited in length (~30) and number (~15)  
    parameters - SomeItems [list/integer]: a list or count of items to get from the dialog
    TheTitle [boolean/text]: use a default or the given dialog title
    ThePrompt [boolean/text]: use a default or the given prompt text
    returns [list]: a list of the input items
    if ThePrompt is in {true, false} then -- "with" or "without" prompt
    if ThePrompt then
    set ThePrompt to "Input the following items separated by returns:" & return & return -- default
    else
    set ThePrompt to ""
    end if
    else -- fix up the prompt a bit
    set ThePrompt to ThePrompt & return & return
    end if
    if TheTitle is in {true, false} then if TheTitle then -- "with" or "without" title
    set TheTitle to "Multiple Input Dialog" -- default
    else
    set TheTitle to ""
    end if
    if class of SomeItems is integer then -- no item list
    set {TheCount, SomeItems} to {SomeItems, ""}
    if ThePrompt is not "" then set ThePrompt to text 1 thru -2 of ThePrompt
    else
    set TheCount to (count SomeItems)
    end if
    if TheCount is less than 1 then error "InputItems handler:  empty input list"
    set {TheItems, TheInput} to {{}, {}}
    repeat TheCount times -- set the number of lines in the input
    set the end of TheInput to ""
    end repeat
    set {TempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
    set {SomeItems, TheInput} to {SomeItems as text, TheInput as text}
    set AppleScript's text item delimiters to TempTID
    set TheInput to paragraphs of text returned of (display dialog ThePrompt & SomeItems with title TheTitle default answer TheInput) -- with icon caution with hidden answer)
    repeat with AnItem from 1 to TheCount -- pad/truncate entered items
    try
    set the end of TheItems to (item AnItem of TheInput)
    on error
    set the end of TheItems to ""
    end try
    end repeat
    return TheItems
    end InputItems
    </pre>
    If you are looking at easier error handling or an entry box for each item, then yes, AppleScript Studio is what you want.
    Message was edited by: red_menace

  • Applescript & Automator- display dialog title

    I'm trying to make an Automator service. For one of the steps I would like to use an Applescript that looks something like the one below.
    set dpaste to "Enter a title, press tab, add some text, and click Continue when you're done."
    set dialog_title to "Post To Blog"
    set dpastedialog to display dialog dpaste with title dialog_title with icon 1 buttons {"Cancel", "Continue"} default button 2
    if button returned of dpastedialog is "Continue" then
    tell application "System Events"
    activate
    keystroke "v" using command down
    end tell
    end if
    However, the line "set dpastedialog to display dialog dpaste with title dialog_title" seems to be giving Automator some trouble. Whenever I try to compile/run the script, I get the following error message from Automator: "Expected end of line, etc. but found identifier" with the variable "dialog_title" selected.
    When I run this script from Applescript Editor I get no trouble.
    Thanks!

    Test the script in the AppleScript Editor until you resolve the issue. Alternatively, post to the AppleScript forum under OS X Technologies.

  • AppleScript Newbie - Display dialog box when quitting an application

    Hello.
    I was wondering if it's possible to write a script that displays a dialog box (in this case one saying "BACK UP!!!!") everytime i quit Final Draft.
    Thanks.
    F.

    A regular AppleScript does not have the ability to get system notifications, so you would have to do something like have the script continually check (poll) for applications that are running.  A Cocoa-AppleScript does have the ability to do Cocoa-y stuff such as register for system notifications, so you can create a new applet (AppleScript Editor > File > New from Template > Cocoa-AppleScript Applet), paste in the following, and save it as an application (uncheck the option to show the startup screen):
    property theApps : {"Final Draft"} -- a list of applications to watch for
    on run -- example
      # add observers for workspace notifications
      tell current application's NSWorkspace's sharedWorkspace's notificationCenter
        addObserver_selector_name_object_(me, "appQuit:", current application's NSWorkspaceDidTerminateApplicationNotification, missing value)
      end tell
      -- tell application "Final Draft" to activate
    end run
    on appQuit_(aNotification) -- an application quit
      # aNotification's userInfo record contains an NSRunningApplication instance that we can get properties from
      set theApplication to (aNotification's userInfo's NSWorkspaceApplicationKey's localizedName()) as text
      if theApplication is in theApps then
      tell current application -- me
        beep 3
        activate -- make sure dialog comes to front
        display dialog "BACK UP!!!!" with title "Final Draft quit notice" buttons {"OK"} default button 1
        quit
      end tell
      end if
    end appQuit_
    When the application is run it will sit there and receive notifications when other applications quit, and checks to see if it was the application you want.

  • Display dialog in applescript

    Using the 'Display Dialog command with default answer "" returns two results; Button pressed and text.
    I want to isolate the text to use in an application. Does anybody know the syntax to allow me to do this. until upgrade to Mavericks the text appears to have been the default return, now its the button.
    Thanks

    For those of you who may be experiencing the same problem I have manged to resolve the issue with the following lines:
         Set mvar to (display dialog "add data" default answer "")
         set mvar to text returned of mvar
    This leave mvar with the text only to be used in an application etc, in my case numbers.
    refer to page 161 of the Applescript Language Guide

  • Applescript: display dialog until memory card is inserted

    I'm developing an applet to automate the process of copying video footage from my camera's memory cards onto my hard drive. It works perfectly, except that I cannot quit it. Here is the part of the code that needs help. It checks every 5 seconds for a memory card and, if one is inserted, continues to copy everything off it.
    repeat
         set cardIn to 1
              with timeout of 86400 seconds
                        tell application "Finder"
                                  repeat while cardIn is 1
                                            if exists disk "EOS_DIGITAL" then
                                                      set cardIn to 0
                                            else
                                                      delay 5
                                            end if
                                  end repeat
                        end tell
              end timeout
         (the rest of the code)
    end repeat
    The problem is that there is no way I can find to quit once it is in this wait loop. The menu command to quit and the Command-Q hotkey both do nothing so I have to force quit when done. What I'd like is to be able to have a dialog displayed asking this user if they want to quit while it's waiting, but I don't know how to do that without it having to "give up after 5 seconds". That makes a new dialog display again every 5 seconds when it rechecks for memory cards, which would get very annoying for anyone using the computer.
    I wish something like this would work...
    repeat until (list disks) contains "EOS_DIGITAL"
         display dialog "Waiting for card..." buttons {"Quit"}
         tell me to quit
    end repeat
    ...but it still waits for a button to be clicked in the dialog. I want this to be a truly automatic process, where plugging in a memory card triggers the whole copy process (which is already done and works perfectly) so I would rather not have to click a button to continue.
    Is there any way to have a dialog displayes with a quit button that automatically goes away once a memory card is inserted without using "giving up after x seconds"?

    Keeping a script or application locked up inside delays or repeat loops will keep it from responding to system events.  There are a few ways to monitor when a volume gets mounted:
    Write your application using AppleScript in Xcode to watch for a workspace notification;
    Use launchd or a folder action to watch the /Volumes folder (an alias is added to the folder when a volume is mounted);
    Make your script into a stay-open application and use an idle handler to periodically check.

  • Applescript Display Dialog Default Answer Rendering Issue

    After I installed Lion, I started having issues with Applescript rendering a dialog with a textbox.
    This is the sort of thing I end up seeing:
    The text box in the dialog doesn't render properly, and it's not possible to enter anything into it.  I've played with the display dialog parameters but it doesn't matter if I give an empty string for the default answer or other text, the behaviour is always the same.
    Does anyone have any ideas as to what the issue might be?  I suspect I might need to reinstall Lion, but I'm not sure that's even going to clear up the issue.
    Thanks in advance.

    Tried replacing 'Standard Additions' osax, dumping editor prefs, dumping ALL user prefs (not recommended for faint of heart), using a different copy of Script Editor. Nothing helped.
    The user account displaying the bug is an old one; likely updated continuosly from the days of Tiger or earlier.
    A std account on the same drive, which merely went through the Snow Leopard -> Lion transition, does not exhibit the edit-text display bug.
    So I bit the bullet, and used Migration Assistant to move to a new account on a clean install of Lion on a spare hard drive. 3.5 hours later, the Applescript edit text display bug is gone.
    As far as I can tell, all docs, Apps etc. made it through intact.
    If that continues to look true over the next few days, I'll try using SuperDuper! to copy the new drive back to the older, faster HD.
    Perhaps some other Lion bugs'll also go away now that I've got a cleaner install.

Maybe you are looking for

  • How do I change my voice mail recording on my iphone 4S

    how do I change my voice mail recording on my 4S iphone

  • Using GPO to deploy Acrobat 9.1

    I am ttying to deploy Acrobat Reader 9.1 using GPO as I have in the past for previous versions however this new version has two annoyances that I and probably my users will hate. I have got rid of things like the EULA using an MST but these 'problems

  • Search MessageSelector sample for complex boolean express with AND, OR, NOT

    As far as I know I can specify in the "Message Selector" field of a JMS-PartnerLink a boolean expression. How are AND, OR and NOT written here? Can I use brackets? Can I use blanks inside the boolean expression? Assume I would like to specify: ((myfi

  • Cant view files on ipod thru itunes.

    I have two 8g nanos synced to my library. I can view the music on the first one but on the second i cant view the music already on it. All i see is the original options like i havent synced it but i have. What do I need to do to fix this and view the

  • [HOWTO] ROOT 4.2.1 beta / CM 10.1 (4.2.2) on K860/860i [Rev2]

    Old HOW-TO: https://forums.lenovo.com/t5/Lenovo-Phones/HOWTO-CM-on-K860-860i-LePhone-update-11-03/td-p/1056045 It has been a great time so far seeing the community growing and Lenovo development going on strong on this platform, it gets better and be