Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 06-09-2009, 11:17 AM
djaschke djaschke is offline
Registered User
 
Join Date: Jun 2009
Posts: 4
Using crt.Dialog.Prompt

When using crt.Dialog.Prompt the dialog box displays an entry field, the OK and the Cancel buttons. When an entry is entered in the entry field and the OK button is clicked, the value in the entry field is returned.
When the Cancel button is clicked, no value is returned. Is there a result status and value associated with the Cancel button?
When using MessageBox, the result has a value baised on the button that was clicked. Where is the Prompt status/result placed when Cancel is clicked?
Reply With Quote
  #2  
Old 06-09-2009, 11:50 AM
miked's Avatar
miked miked is offline
Registered User
 
Join Date: Feb 2004
Posts: 2,040
Quote:
Is there a result status and value associated with the Cancel button?
The result is an empty string. You cannot distinguish between a user clicking the Cancel button, or not entering any text and clicking the OK button.
Code:
' If the user clicks OK, Prompt returns the entered string.  
' If the user clicks Cancel, an empty string is returned.
Dim pass
pass = crt.Dialog.Prompt("Enter your password:", "Logon Script", "", True)
if pass = "" then
    msgbox "User clicked Cancel or didn't enter text"
else
    msgbox "pass = " & pass
end if
Quote:
When using MessageBox, the result has a value baised on the button that was clicked. Where is the Prompt status/result placed when Cancel is clicked?
MessageBox doesn't need to return text that a user entered. Prompt does. The result of Cancel is "". The status ("Err.Number") is 0, which is again the same as pressing the OK button with an empty string. The Crt.Dialog.Prompt and Crt.Dialog.MessageBox are the same as VBScript's InputBox and MsgBox in their behavior, so you wouldn't be able to use VBScript functions to get around the behavior you describe.

Does your application need to distinguish whether a user presses OK with an empty string or clicks the Cancel button, or can you treat an empty string as the Cancel button having been clicked?
__________________
Mike
VanDyke Software
Technical Support
[http://www.vandyke.com/support]
Reply With Quote
  #3  
Old 06-09-2009, 12:53 PM
djaschke djaschke is offline
Registered User
 
Join Date: Jun 2009
Posts: 4
crt.dialog.prompt no input

For the project that I am working on, the user is required to enter text. As a result if they do not enter text then I can treat it as if they clicked the Cancel button.
Thanks for the reply.
Reply With Quote
  #4  
Old 06-09-2009, 01:19 PM
miked's Avatar
miked miked is offline
Registered User
 
Join Date: Feb 2004
Posts: 2,040
Excellent - I'm glad the empty-string check will work for you!
__________________
Mike
VanDyke Software
Technical Support
[http://www.vandyke.com/support]
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 06:44 AM.