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-02-2019, 09:10 AM
Ginfizz Ginfizz is offline
Registered User
 
Join Date: Feb 2019
Posts: 5
WaitForStrings TypeError in Python

This is occurring in Python. When trying to use WaitForStrings I keep receiving a TypeError which reads as follows:
Error: an integer is required
Line 6
My code is as follows:

result = int(crt.Screen.WaitForStrings(">","#"))
crt.Screen.Send(str(result))

the first line is line 6, the offending line. The error persists if I add a timeout value as well.

Does anyone know why this is happening?
Reply With Quote
  #2  
Old 05-02-2019, 09:34 AM
Ginfizz Ginfizz is offline
Registered User
 
Join Date: Feb 2019
Posts: 5
Clarification, the issue still persists even with the int() removed from the code.

result = crt.Screen.WaitForStrings(">","#")
Reply With Quote
  #3  
Old 05-02-2019, 10:54 AM
berdmann berdmann is offline
VanDyke Technical Support
 
Join Date: Aug 2017
Posts: 261
Hi Ginfizz,

Would it be possible for you to provide more of your code? It is difficult to determine what is causing this error based on the small snippet of code that you have provided.

If you do not feel comfortable sharing the script here, please send me an email to support@vandyke.com with "ATTN: Brittney, Forum Thread 13523" in the subject line.
__________________
Thanks,
--Brittney

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #4  
Old 05-02-2019, 11:45 AM
Ginfizz Ginfizz is offline
Registered User
 
Join Date: Feb 2019
Posts: 5
My code is actually just that snippet as I was testing to see what was causing the issue. WaitForStrings works fine in VBS but Python seems to be working differently, though its likely just me not understanding.

Here is the full code.

Code:
#$language = "python"
#$interface = "1.0"

def main():
	result = crt.Screen.WaitForStrings(">","#", 5)
	crt.Screen.Send(result)
	
	
main()
I was trying to see what value it was outputting once it timed out. Received the error and then tried the following:

Code:
#$language = "python"
#$interface = "1.0"

def main():
	result = crt.Screen.WaitForStrings(">","#")
	crt.Screen.Send(result)
	
main()
That also gives the exact same error, a TypeError asking for an Integer. Normally this script above should just sit there indefinitely. But instead it returns an error and doesn't run.


Code:
#$language = "VBScript"
#$interface = "1.0"

Sub Main

result = crt.Screen.WaitForStrings(">","#", 5)
crt.Screen.Send(result)

End Sub
The VBScript works fine and returns 0 at the end of the timeout.

Seems to only be an issue with Python.
Reply With Quote
  #5  
Old 05-02-2019, 12:41 PM
Ginfizz Ginfizz is offline
Registered User
 
Join Date: Feb 2019
Posts: 5
Here is a screen shot of the error I am receiving.





As you can see, the same error occurs with and without the variable being assigned.
Reply With Quote
  #6  
Old 05-02-2019, 02:26 PM
berdmann berdmann is offline
VanDyke Technical Support
 
Join Date: Aug 2017
Posts: 261
Hi Ginfizz,

In Python, [ ]s are required to designate what strings you would like WaitForStrings to well, wait for. The first argument must either be a single string, or an array of multiple strings. The second argument must be an integer representing the timeout value.

For example:

Code:
 result = crt.Screen.WaitForStrings([">","#"], 5)
Does that work for you?
__________________
Thanks,
--Brittney

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #7  
Old 05-02-2019, 02:48 PM
Ginfizz Ginfizz is offline
Registered User
 
Join Date: Feb 2019
Posts: 5
Thanks a ton! This works perfectly, I appreciate the help.
Reply With Quote
Reply

Tags
python , typeerror , waitforstrings


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 12:19 PM.