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 03-11-2020, 03:20 PM
ttrebing ttrebing is offline
Registered User
 
Join Date: Mar 2020
Posts: 3
How to break out of a while loop

According to the docs, crt.Screen.WaitForKey(1) should return False if timeout is triggered and True if key was pressed. The following code is not working. I simply wish to break out of the while loop and end the script on any keypress:
Code:
# $language = "python"
# $interface = "1.0"

def Main():
	while not crt.Screen.WaitForKey(1):
		crt.Screen.Synchronous = True
		crt.Screen.SendSpecial("VT_CURSOR_UP")
		crt.Screen.Send("\r")
		crt.Screen.WaitForString("#")
	# end 'while crt.Screen.WaitForKey(1)'

Main()

Last edited by jdev; 03-11-2020 at 04:52 PM. Reason: wrap code in [code][/code] blocks to preserve indentation
Reply With Quote
  #2  
Old 03-11-2020, 04:57 PM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
 
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 1,016
Quote:
Originally Posted by ttrebing View Post
The following code is not working.
When you say "not working"... what does this look like for you?

Does the script even run? (I had to fix your script code because your 'def' was munged with the script header being inserted in between the 'd' and the 'e' in 'def')

When I run the script, it works as desired... I simply press ESC and the loop terminates, ending the script.

If the script does run when you launch it, what behavior do you see when it's running and you press the ESC key for example to terminate the loop?

Which version of SecureCRT are you running?

On which operating system (and version) do you have SecureCRT installed in this specific case?

--Jake
__________________
Jake Devenport
VanDyke Software
Technical Support
YouTube Channel: https://www.youtube.com/vandykesoftware
Email: support@vandyke.com
Web: https://www.vandyke.com/support
Reply With Quote
  #3  
Old 03-12-2020, 09:54 AM
ttrebing ttrebing is offline
Registered User
 
Join Date: Mar 2020
Posts: 3
Script runs just fine. It's just that when I press a key, it simply loops back immediately. The only way to stop it is by cancelling it.

I'm running SecureCRT version 8.1.1 (build 1319) on macOS Catalina v 10.15.3

It works fine on version 8.5.2 x64 build 1799 on Windows 10...
Reply With Quote
  #4  
Old 03-12-2020, 09:58 AM
ttrebing ttrebing is offline
Registered User
 
Join Date: Mar 2020
Posts: 3
Update

Upgraded to Version 8.5.4 (build 1942) and it is working now!!!

Thanks!
Reply With Quote
  #5  
Old 03-12-2020, 10:09 AM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
 
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 1,016
Quote:
Originally Posted by ttrebing View Post
I'm running SecureCRT version 8.1.1 (build 1319) on macOS Catalina v 10.15.3
The first version of SecureCRT that is supported on macOS Catalina is version 8.7.
__________________
Jake Devenport
VanDyke Software
Technical Support
YouTube Channel: https://www.youtube.com/vandykesoftware
Email: support@vandyke.com
Web: https://www.vandyke.com/support
Reply With Quote
  #6  
Old 03-12-2020, 10:14 AM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
 
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 1,016
Quote:
Originally Posted by ttrebing View Post
Upgraded to Version 8.5.4 (build 1942) and it is working now!!!
Glad to know that your script works for you in a newer version.

Note:
Because SecureCRT version 8.5.4 is not designed to work on macOS Catalina, there may be other issues you encounter. Should additional issues arise for you, then the next step would be to upgrade to a version of SecureCRT that is supported on macOS Catalina (e.g. SecureCRT 8.7).

--Jake
__________________
Jake Devenport
VanDyke Software
Technical Support
YouTube Channel: https://www.youtube.com/vandykesoftware
Email: support@vandyke.com
Web: https://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 02:06 PM.