Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Notices

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 02-15-2018, 01:31 PM
djvj djvj is offline
Registered User
 
Join Date: Oct 2011
Posts: 13
Why doesn't this For loop work?

Trying to automate a simple login process before I expand it to work on multiple devices that have different prompts, but I keep getting an Unexpected 'Next' error when it's ran and not sure why:

Code:
	For x = 0 To 2	' Loop this code 2 times (once for username, and again for password)
		result = crt.screen.waitforstrings ("ACS5.5 username:", "ACS5.5 password:", "password:", 5)	' wait 5 seconds for each try
		Select Case result
			Case 0
				msgbox "timeout occurred"
			Case 1
				crt.Screen.Send usr & VbCr	' Send your username followed by a carriage return
			Case 2
				crt.Screen.Send pw & VbCr	' Send your password followed by a carriage return
			Case 3
				crt.Screen.Send pw & VbCr	' Send your password followed by a carriage return
		Crt.Sleep 1000	' wait 1 second
	Next
The error might be obvious but not used to coding in VBS.
Reply With Quote
  #2  
Old 02-15-2018, 02:24 PM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 654
Hi djvj,

It looks like the For loop error may be a bit of a red herring.

I think it just a matter of your Select Case missing the End Select.

Code:
Select Case result
    Case 0
        msgbox "timeout occurred"
    Case 1
        crt.Screen.Send usr & VbCr
    Case 2
        crt.Screen.Send pw & VbCr
    Case 3
        crt.Screen.Send pw & VbCr
End Select
Does making this change get you the behavior you're looking for?
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 02-15-2018, 03:39 PM
djvj djvj is offline
Registered User
 
Join Date: Oct 2011
Posts: 13
Thank you! Yes that worked.
Reply With Quote
Reply

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 07:58 PM.