View Single Post
  #2  
Old 05-08-2019, 08:27 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,636
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