VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Scripting (https://forums.vandyke.com/forumdisplay.php?f=14)
-   -   WaitForStrings TypeError in Python (https://forums.vandyke.com/showthread.php?t=13523)

Ginfizz 05-02-2019 09:10 AM

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?

Ginfizz 05-02-2019 09:34 AM

Clarification, the issue still persists even with the int() removed from the code.

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

berdmann 05-02-2019 10:54 AM

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.

Ginfizz 05-02-2019 11:45 AM

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.

Ginfizz 05-02-2019 12:41 PM

Here is a screen shot of the error I am receiving.

https://i.imgur.com/8QlkV9m.png

https://i.imgur.com/4F6OoFk.png

As you can see, the same error occurs with and without the variable being assigned.

berdmann 05-02-2019 02:26 PM

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?

Ginfizz 05-02-2019 02:48 PM

Thanks a ton! This works perfectly, I appreciate the help.


All times are GMT -6. The time now is 01:37 PM.