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 05-07-2019, 10:18 PM
christopherchiu christopherchiu is offline
Registered User
 
Join Date: Sep 2008
Posts: 1
Python handle crt.Dialog.Prompt handling

In SecureCRT, i have a script that display 2 dialog boxes for inputs. i want to exit out when either (a) user hit <cancel>, or (b) user hit <ok> but nothing was entered.

When in VB, there is a system variable Err.Number. How is it in python? Thanks
Reply With Quote
  #2  
Old 05-08-2019, 08:27 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,635
Hi christopherchiu,
Quote:
In SecureCRT, i have a script that display 2 dialog boxes for inputs. i want to exit out when either (a) user hit <cancel>, or (b) user hit <ok> but nothing was entered.
There's an example in the SecureCRT Help topic for Dialog Object / Prompt Method (Scripting / Script Objects Reference):

Quote:
Python
Syntax
crt.Dialog.Prompt(message [, title [, default [, isPassword ]]])
Example
password = crt.Dialog.Prompt("Enter your password:", "Logon Script", "", True)
if password == "":
# User clicked Cancel button
else:
# User added data
The if == "" would cover both a cancel or empty scenario. To exit out, use return or break.

Quote:
When in VB, there is a system variable Err.Number. How is it in python? Thanks
As I told you in email, I don't know that there is a direct equivalent. If you wrap code in a try/except block there are built-in exceptions available in Python but that's more a Python inquiry than it is SecureCRT.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
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 04:07 AM.