VanDyke Software Forums

Go Back   VanDyke Software Forums > Scripting
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-05-2010, 12:51 PM
WesR WesR is offline
Registered User
 
Join Date: Mar 2005
Location: USA
Posts: 118
Dialog.Prompt

Hi,

Is there a way to tell the difference between a user clicking on cancel vs not filling out the field and just clicking return when using the Dialog.Prompt command? The Manual just states that the string entered is returned if OK is clicked. It looks like it returns a null string if either cancel is clicked or nothing is entered and ok is clicked.

I would like the script to exit if Cancel is clicked, but for this prompt, a null string would be a valid entry...

Thanks,

Wes
Reply With Quote
  #2  
Old 03-05-2010, 02:11 PM
cr1275 cr1275 is offline
Registered User
 
Join Date: Feb 2008
Posts: 182
I recently had a issue like this. I have to defer to Vandyke support for the real answer.

However, I think you could pre-fill the answer with a blank or some other information. Then if someone accidentally hits return it will not return a null value.

btw, my notes to enable a cancel button:

Put this after every dialog and replace variable with the dialog variable

If variable = "" Then
Exit Sub
Else
End If

Hope that helps
Reply With Quote
  #3  
Old 03-05-2010, 03:44 PM
miked's Avatar
miked miked is offline
VanDyke Customer Support
 
Join Date: Feb 2004
Posts: 1,321
Hello Wes,

Currently Dialog.Prompt does not return the value of which button was pressed so you cannot tell in a direct way. I've added your post to our request database and if Dialog.Prompt offers a direct way to know which button was clicked in a future release of SecureCRT, we'll post a follow up message here. Let us know if you'd like to be notified via e-mail should this be added, and please refer to forum 5079.

There are a couple of possible workarounds:
  • Use a default value in Dialog.Prompt
  • Use the Internet Explorer object to build a custom dialog
If you use a default value in the input box then compare what is returned. Here is a short example of how this might look.
Code:
#$Language="VBScript" #$Interface="1.0" Sub Main strMessage = "Type a new password." & vblf & vblf &_ "Leave default value for empty string." & vblf & vblf &_ "Click Cancel to exit the script." strTitle = "Example" strDefault = "<empty string>" 'strDefault = " " bIsPassword = false strResult = crt.Dialog.Prompt(strMessage, strTitle, strDefault, bIsPassword) If strResult = strDefault Then MsgBox "Default value means send empty string" ElseIf strResult = "" Then MsgBox "An empty string means user clicked Cancel button" Else MsgBox "User entered " & strResult End If End Sub

Alternatively, you may want to use the Internet Explorer object to build a custom dialog. This could be preferable if there are many fields of data to enter. The SecureCRT Scripting Manual section 6.3 discusses Building Custom Dialogs or Forms.

Do you think either of these ideas will help serve as a workaround?
__________________
Michael Decker
VanDyke Software
Technical Support
http://www.vandyke.com

Last edited by miked : 03-05-2010 at 03:53 PM.
Reply With Quote
  #4  
Old 03-05-2010, 05:28 PM
WesR WesR is offline
Registered User
 
Join Date: Mar 2005
Location: USA
Posts: 118
Thanks Michael and cr1275,

In this case I do pre-fill the most common value, so I was just hoping the users could hit delete and then OK, but I guess not. I could go with the IE dialog, but I don't think I want to put that much into this script, at least not at this time.

I will probably go with a keyword like "Enter 'All' to get a full list". This shouldn't be too hard and fairly obvious.

Wes
Reply With Quote
  #5  
Old 03-05-2010, 06:21 PM
cr1275 cr1275 is offline
Registered User
 
Join Date: Feb 2008
Posts: 182
Not sure what the script does. However, you may be able to use CASE instead of the if ?
Reply With Quote
  #6  
Old 03-05-2010, 10:03 PM
WesR WesR is offline
Registered User
 
Join Date: Mar 2005
Location: USA
Posts: 118
Nah, not in this 'case'... It's really just used as a filter for a large directory listing. Entering nothing would give the whole directory, entering for example ab would give all files starting with ab.

Wes
Reply With Quote
  #7  
Old 03-06-2010, 03:43 PM
WesR WesR is offline
Registered User
 
Join Date: Mar 2005
Location: USA
Posts: 118
Thanks,

I ended up keeping the portion of code to treat a null string as a cancel and added a prompt for the user to enter "all" for the full list.

Wes
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

vB 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 09:46 PM.


© copyright 1995-2010 VanDyke Software, Inc.