Display dialog ... giving after integer
After updating to Mountain Lion I experienced some problems with the AppleScript scripts I use in a Filemaker Pro environment.
This necessitated me to change from QTP to QTP 7.
The following script reflects the FMP environment; when I try to abstract from the FMP environment, I encounter other problems.
tell application "QuickTime Player 7" to launch
tell application "FileMaker Pro"
activate
set url_path to cell "bestandspad" of current record
end tell
set tekst to ""
tell application "QuickTime Player 7" to getURL url_path
delay 0.1
tell application "System Events"
set visible of process "QuickTime Player 7" to false
repeat until visible of process "QuickTime Player 7" is false
end repeat
end tell
tell application "QuickTime Player 7" to set doc1Exists to (exists document 1)
if not doc1Exists then
set tekst to "next"
else
tell application "QuickTime Player 7" to play document 1
end if
set the clipboard to tekst
set tekst to ""
repeat
display dialog "Interrupt" buttons {"Stop", "Pauze"} giving up after (my secLeft())
set {b, fin} to {button returned, gave up} of result
if fin then exit repeat
if b = "Stop" then
set tekst to "Stop"
exit repeat
else
tell application "QuickTime Player 7" to pause document 1
display dialog "Verder gaan ?" with title "" buttons {"Stop", "Hervat"} default button 2
set b to button returned of result
if b = "Hervat" then
tell application "QuickTime Player 7"
tell document 1
if duration = current time then exit repeat
play
end tell
end tell
else
set tekst to "Stop"
exit repeat
end if
end if
end repeat
set the clipboard to tekst
on secLeft()
tell application "QuickTime Player 7"
tell document 1
set d to (duration - current time)
end tell
end tell
set d to round d rounding up
if d < 1 then set d to 1
return d
end secLeft
tell application "QuickTime Player 7" to close document 1 saving no
tell application "QuickTime Player 7" to quit
Everything works fine, but.
The problem is with the 'display dialog ... giving up after (my secLeft())'
This is supposed to return fin=true when current time equals duration or when my secLeft=0; it always returns fin=false
This program runs fine on the AppleScript editor; 'current time' sometimes poses a problem in other programs.
Any idea how to correct 'dispaly dialog (without moving back to QTP)?
To induce you to a response I submit the program in a simplified form, so that you can run it in the AppleScript editor after copying; you only have to fill in the url_path.
tell application "QuickTime Player 7" to launch
set url_path to "/Users/your name/Desktop/song title.mp3"
set tekst to ""
tell application "QuickTime Player 7" to open url_path
tell application "QuickTime Player 7" to set doc1Exists to (exists document 1)
if not doc1Exists then
set tekst to "next"
else
tell application "QuickTime Player 7" to play document 1
end if
set the clipboard to tekst
set tekst to ""
repeat
display dialog "Interrupt" buttons {"Stop", "Pause"} giving up after my secLeft()
set {b, fin} to {button returned, gave up} of result
if fin then exit repeat
if b = "Stop" then
set tekst to "Stop"
exit repeat
else
tell application "QuickTime Player 7" to pause document 1
display dialog "Continue ?" with title "" buttons {"Stop", "Resume"} default button 2
set b to button returned of result
if b = "Resume" then
tell application "QuickTime Player 7"
tell document 1
if duration = current time then exit repeat
play
end tell
end tell
else
set tekst to "Stop"
exit repeat
end if
end if
end repeat
set the clipboard to tekst
on secLeft()
tell application "QuickTime Player 7"
tell document 1
set d to (duration - current time)
end tell
end tell
set d to round d rounding up
--if d < 1 then set d to 1
return d
end secLeft
tell application "QuickTime Player 7" to close document 1 saving no
tell application "QuickTime Player 7" to quit
It seems, that 'repeat' is not working. The value of secLeft() is not refreshed while playing.
I tried repeat while and repeat until, but to no avail.
Comment please.
Similar Messages
-
How to don't display dialog after send data on BPC for Excel?
Dear experts,
I don't want to display dialog after send data on BPC for Excel, how can I do that?
OS: MS XP SP2
OFFICE : 2003
BPC : 7.5 NWHi,
You need to change the macro assigned to the standard button. There are few macros available. You can try them and see which one suits you the best.
MNU_eSUBMIT_REFSCHEDULE_BOOK_CLEARANDREFRESH: Sends workbook and clears data and refreshes workbook.
MNU_eSUBMIT_REFSCHEDULE_BOOK_NOACTION: Sends data without clearing or refreshing the worksheet.
MNU_eSUBMIT_REFSCHEDULE_BOOK_NOACTION_SHOWRESULT: Sends data without clearing or refreshing the worksheet, and shows the result in a window upon successful send.
MNU_eSUBMIT_REFSCHEDULE_BOOK_NODIALOG_SHOWRESULT: Sends active book without any dialog and show result box.
MNU_eSUBMIT_REFSCHEDULE_BOOK_REFRESH: Sends workbook and refreshes data.
MNU_eSUBMIT_REFSCHEDULE_SHEET_CLEARANDREFRESH: Sends data and clears and refreshes the worksheet.
MNU_eSUBMIT_REFSCHEDULE_SHEET_NOACTION: Sends data without clearing or refreshing.
MNU_eSUBMIT_REFSCHEDULE_SHEET_REFRESH
Hope it helps. -
How to don't display dialog after send data?
Dear experts,
I don't want to display dialog after send data on BPC for Excel, how can I do that?
OS: MS XP SP2
OFFICE : 2003
BPC : 7.5 NWI have moved this thread to the BPC NW forum. Notice the sticky [note|Please do not post BPC, SSM or FI/CO questions here!; at the top of the FPM - General (PCM, FC, Other) Forum whereby we announced new dedicated forums for BPC which are the proper place to post your questions regarding BPC in the future.
[Jeffrey Holdeman|http://wiki.sdn.sap.com/wiki/display/profile/Jeffrey+Holdeman]
SAP Labs, LLC
BusinessObjects Division
Americas Applications Regional Implementation Group (RIG) -
Currently, my script displays a dialog and plays a sound. I can hit Ok and the sound stops and the script quits - that's all good. However, I would also like the script to automatically quit after a set number of seconds if no one hits Ok. Here's what I've got:
tell application "Play Sound"
activate
play soundAlias repeat 3
display dialog "Currensys Alert" buttons {"OK"}
stop
quit
end tell
I can't figure out exactly how to put the delay into this. Do I need an if/then conditional?Here:
display dialog "Currensys Alert" buttons {"OK"} giving up after 1--time in seconds
(50598) -
Display dialog, await user input how to get no timeout?
I have a script i run on login, it brings up a dialog that requests user input, how can I stop it timing out if nothing happens?
Sorry long delay to get back to my question that I asked,
Still having issues, original I used the timeout action, and that keeps the script working.... However it still times out and then when I use the
giving up after 150
I've not tested it to see if it prevents an early timeout, but clicking a the dialog and my script, just stops working there and does nothing else.
--These files need to change on boot.
--:Applications:Adobe Photoshop CS6:Presets:Scripts:SAVEAS.jsx
--:Applications:Adobe Photoshop CS6:Presets:Scripts:SaveOnly.jsx
--:Volumes:StudioC:Users:StudioC:Workflow:Folder Actions:0_HeliconHotFolder.scpt
set CS6Applications to ((path to applications folder as text) & "Adobe Photoshop CS6:Presets:Scripts")
set HeliconLabeler to ((path to home folder as text) & "Workflow:Folder Actions")
set HeliconAbdul to ((path to me as text) & "Contents:Resources:Scripts:abdul:0_HeliconHotFolder.scpt")
set HeliconMatt to ((path to me as text) & "Contents:Resources:Scripts:matt:0_HeliconHotFolder.scpt")
set HeliconShah to ((path to me as text) & "Contents:Resources:Scripts:shah:0_HeliconHotFolder.scpt")
set PS6SaveAsAbdul to ((path to me as text) & "Contents:Resources:Scripts:abdul:SAVEAS.jsx")
set PS6SaveOnlyAbdul to ((path to me as text) & "Contents:Resources:Scripts:abdul:SaveOnly.jsx")
set PS6SaveAsMatt to ((path to me as text) & "Contents:Resources:Scripts:matt:SAVEAS.jsx")
set PS6SaveOnlyMatt to ((path to me as text) & "Contents:Resources:Scripts:matt:SaveOnly.jsx")
set PS6SaveAsShah to ((path to me as text) & "Contents:Resources:Scripts:shah:SAVEAS.jsx")
set PS6SaveOnlyShah to ((path to me as text) & "Contents:Resources:Scripts:shah:SaveOnly.jsx")
tell application "System Events"
if name of current user is equal to "StudioA" then ¬
set MacName to "true"
if name of current user is not equal to "StudioA" then ¬
set MacName to "false"
end tell
with timeout of (60 * 61) seconds
display dialog "Who is using the Computer?" buttons {"Abdul", "Matt", "Shah"} with icon caution
if result = {button returned:"Abdul"} then
if MacName = "true" then
tell application "Finder"
duplicate file PS6SaveAsAbdul to folder CS6Applications with replacing
duplicate file PS6SaveOnlyAbdul to folder CS6Applications with replacing
end tell
else if MacName = "false" then
tell application "Finder"
duplicate file HeliconAbdul to folder HeliconLabeler with replacing
duplicate file PS6SaveAsAbdul to folder CS6Applications with replacing
duplicate file PS6SaveOnlyAbdul to folder CS6Applications with replacing
end tell
display alert "Turn Camera on"
delay 1
tell application id "breezesys.com.dslrremotepro" to activate
menu_click({"DSLRRemotePro", "Camera", "Set date/time and owner string..."})
delay 1
tell application "System Events"
keystroke "a" using command down
delay 1.5
keystroke "Shot_By_Abdul"
delay 1.5
keystroke return
end tell
end if
else if result = {button returned:"Matt"} then
if MacName = "true" then
tell application "Finder"
duplicate file PS6SaveAsMatt to folder CS6Applications with replacing
duplicate file PS6SaveOnlyMatt to folder CS6Applications with replacing
end tell
else if MacName = "false" then
tell application "Finder"
duplicate file HeliconMatt to folder HeliconLabeler with replacing
duplicate file PS6SaveAsMatt to folder CS6Applications with replacing
duplicate file PS6SaveOnlyMatt to folder CS6Applications with replacing
end tell
display alert "Turn Camera on"
delay 1
tell application id "breezesys.com.dslrremotepro" to activate
menu_click({"DSLRRemotePro", "Camera", "Set date/time and owner string..."})
delay 1
tell application "System Events"
keystroke "a" using command down
delay 1.5
keystroke "Shot_By_Matt
delay 1.5
keystroke return
end tell
end if
else if result = {button returned:"Shah"} then
if MacName = "true" then
tell application "Finder"
duplicate file PS6SaveAsShah to folder CS6Applications with replacing
duplicate file PS6SaveOnlyShah to folder CS6Applications with replacing
end tell
else if MacName = "false" then
tell application "Finder"
duplicate file HeliconShah to folder HeliconLabeler with replacing
duplicate file PS6SaveAsShah to folder CS6Applications with replacing
duplicate file PS6SaveOnlyShah to folder CS6Applications with replacing
end tell
display alert "Turn Camera on"
delay 1
tell application id "breezesys.com.dslrremotepro" to activate
menu_click({"DSLRRemotePro", "Camera", "Set date/time and owner string..."})
delay 1
tell application "System Events"
keystroke "a" using command down
delay 1.5
keystroke "Shot_By_Shah"
delay 1.5
keystroke return
end tell
end if
end if
end timeout
--handlers
on menu_click(mList)
local appName, topMenu, r
-- Validate our input
if mList's length < 3 then error "Menu list is not long enough"
-- Set these variables for clarity and brevity later on
set {appName, topMenu} to (items 1 through 2 of mList)
set r to (items 3 through (mList's length) of mList)
-- This overly-long line calls the menu_recurse function with
-- two arguments: r, and a reference to the top-level menu
tell application "System Events" to my menu_click_recurse(r, ((process appName)'s ¬
(menu bar 1)'s (menu bar item topMenu)'s (menu topMenu)))
end menu_click
on menu_click_recurse(mList, parentObject)
local f, r
-- `f` = first item, `r` = rest of items
set f to item 1 of mList
if mList's length > 1 then set r to (items 2 through (mList's length) of mList)
-- either actually click the menu item, or recurse again
tell application "System Events"
if mList's length is 1 then
click parentObject's menu item f
else
my menu_click_recurse(r, (parentObject's (menu item f)'s (menu f)))
end if
end tell
end menu_click_recurse -
Display dialog count down in sec's
Hey all
I need a script that would use a display dialog to count down before next part of script runs.
is this possible
I need about 1 min count down in sec'sYou could put something like this in the script. I suggest adjusting the interval (perhaps to 5 seconds) as I would guess the precision will drift according to system load:
<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;">
set theCounter to 60
set theInterval to 1
repeat until theCounter is 0
display dialog "Time Remaining: " & theCounter & " seconds" as text buttons {"Wait"} giving up after theInterval
set theCounter to theCounter - theInterval
end repeat </pre> -
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 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 -
Yoga display turns off after 1 minute
I'm having an annoying problem with my new Yoga related to the display and have not seen any other posts with a similar complaint so perhaps this is a simple fix that I'm just not able to sort out on my own. My display turns off after 1 minute of inactivity. The only means for changing behavior like this that I am aware of is through the Control Panel Power Options. My settings for "turn off the display" are 10 minutes on battery and Never while plugged in (note screen shot attached). Regardless of my settings, the screen turns off after 1 minute. I've changed the settings to multiple configurations and restarted with no change in behavior. Perhaps there's some other settings area, maybe something specific to Lenovo that I'm not aware of (since this is my first Lenovo laptop). Anyone with similar problems or insight?
This may be a Windows 8 issue. I finally fixed this problem by identifying the screen saver as the issue (and I wasn't using a screen saver). Type "lock the computer" into the search box after clicking the search charm, which brings up the screen saver dialog box. Mine was set to 1 minute, though I'd never set it myself. If you can't change it, choose a screen saver and you should be able to do so (and can then switch back to no screen saver). BUT, here's the problem. Other things you install (or settings within things you install) can apparently change and override whatever you type in for the delay time. Try applying your new time and exiting from the dialog box, then open it back up again. I was finding that it kept going back to 1 minute. To reset things so that you can get control again, type "user accounts" into the search box and when the dialog box comes up, choose "Reset Security Policies". Then you can go back to the screen saver dialog and successfully change the delay time. See http://social.technet.microsoft.com/Forums/windows/en-us/ace4085a-b0ba-4a98-898d-cd92d9e88e13/window... for some detail.
-
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
RegardsNo 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 -
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. -
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.
-
Exception Aggregation (Average) displaying incorrect values after EHP1 Upgr
Hi All,
Exception Aggregation (Average) displaying incorrect values after EHP1 Upgrade in our BW system
We have recently upgraded the system to EHP1. After the upgrade some of the queries where we are using Exception Aggregation (Average) started giving the incorrect values.
Eg. We are displaying three Key Figures KF1, KF2 and KF3 (=KF1 %A KF2) against Store Hierarchy. In KF3 we are using Exception Aggregation (Average) on a characteristic 0PLANT.
There are 14 rows against 0PLANT and out of those 2 rows are blank for KF1, so for KF3. When it is calculating the average of these key figures its dividing the total value by 12 instead of 14 which is not correct in our case. Earlier it was dividing the total by 14.
So in this case 'Average' and "Average of all values <>0" are behaving the same way.
Kindly provide some inputs on this.
Best Regards,
Sachin Verma
+44 7506740018Hi,
Thanks for viewing the thread. And happy to let you know that the issue was resolved.
The solution was:
Two formulas (local) were created, one including the formula variable with replacement path for ZD1, with exception aggregation on ZD1, and the other with formula variable with replacement path for ZD2, with exception aggregation on ZD2. Both these formulas are hidden.
Another formula (local) was created for u2018time takenu2019 = formula with ZD1 u2013 formula with ZD2, with exception aggregation total on u2018ZDOCNOu2019.
For the second instance, when one requires exception aggregation on records that has multiple values for keys, a nesting of formulas can be done displaying only the ones required.
For e.g. a formula with exception aggregation on say characteristic u2018item no.u2019 can be hidden, and included in another formula for exception aggregation on characteristic u2018document no.u2019. This is a typical case where one can achieve calculation before aggregation for a calculated key figure, formula or a counter.
Hope it might help someone, and saves time and effort for a similar issue posted.
Also would like to keep this thread open for exploring better solutions.
Regards,
Vijay -
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>
danIf 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 -
How do I use Display Dialog to get back a date?
Can anyone tell me how to use Display Dialog to get back a date?
I am using the following code that does not work. It does not accept anything. And I have searched high and low for an answer to my question and found nothing.
repeat
display dialog "When should I remind you (date)?" default answer ""
try
if the text returned of the result is not "" then
set the requested_text to the date returned of the result as date
exit repeat
end if
on error
beep
end try
endrepeat
display dialog requested_text
The code is based on what I found in AppleScript 1-2-3 (page 300). It shows examples for getting text and numbers but not one for dates.
For what it is worth, my goal is to create a script that will convert an email from Evernote into an iCal Reminder. To do so, I want to ask the user (myself) for the reminder's date and time. I am assuming I need to ask for each separately. I also assume that once I get the date and time for the reminder, it should be relatively straightforward to 'make' a 'todo' with an alarm.
Thanks in advance.
-DavidHi David,
Try this:
repeat
set theCurrentDate to current date
display dialog "When should I remind you (date)?" default answer (date string of theCurrentDate & space & time string of theCurrentDate)
set theText to text returned of result
try
if theText is not "" then
set theDate to date theText -- a date object
exit repeat
end if
on error
beep
end try
end repeat
display dialog (date string of theDate & space & time string of theDate)
You might also have a look at this page of the AppleScript Language Guide.
Message was edited by: Pierre L.
Maybe you are looking for
-
I'm ready to burn a DVD of a ten minute video edited in FCE HD and show it to a small group. I've been reading and searching this forum and want to see if these are valid conclusions. a) my client wants to show it on her LCD projector fed by the DVD
-
Browsers do not remember realm authentication details
Hello, When I try to access pages in a protected realm, I sometimes have to enter the username nad password 5 or more times. Sometimes just twice. Even if I tell my browser to remember the password/username, it still prompts me to authenticate later
-
How to enable servers and services?
Currently when i go to the personalization screen of my publications i get the following msg: Unable to find servers in CMS and cluster with kind and service . All such servers could be down or disabled by the administrator. (FWM 01014) Kindly let me
-
Unable to release the higher level WBS
Hi, at my system am having a user status 'review' and 'release' at wbs level. Unless i review and release the subordinate WBS, am unable to release the higher level WBS. is there a possibility to directly review and release my higher level WBS whic
-
Need Cooling Fan For MSI FX5200-T128
Can anyone suggest a cooling fan to fit the MSI FX5200-T128.