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 07-14-2014, 11:54 PM
surezae surezae is offline
Registered User
 
Join Date: Jul 2014
Posts: 8
For .. Next scripting

Hi,
I'm having problem on my script.
I have a data after printout that I need to filter :




I want in the next command it will printout only number under data 3, in this example is 1.2 until the lowest 1.0.
I've made following script :

For cell=crt.Screen.Currentrow-22 to crt.Screen.Currentrow-3
hostvalue=crt.Screen.Get(cell,34,cell,37)
If hostvalue < 60 Then
crt.Screen.Send hostvalue
crt.Screen.WaitForString promptXYZ
End If
Next

Unfortunately I got this when running the script :
ERROR : type mismatch "hostvalue"

Please help guys.
Reply With Quote
  #2  
Old 07-15-2014, 08:37 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,305
Hi surezae,

Thanks for the post. I have run tests, and don't see the issue. Maybe there is something different in the way I am testing.

What line number is indicated when you see the error?

What version of SecureCRT are you using?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #3  
Old 07-15-2014, 04:16 PM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,305
Hi surezae,

When I first ran my tests, I didn't look at the specifics of your code. I just tested part of the output and didn't see the problem.

I have since looked at your Get() call, and it would appear that the columns you have hard coded do not match with the output in the screenshot.

The error you are seeing can be the result of trying to run a mathematical operation on a string and a number. In this case, I think that is the issue.

A good way to troubleshoot this type of problem is to use a message box to display the data of the variable to see if it contains what you expect. Pages 47 and 48 of the scripting manual also discuss how to determine what rows and columns you would need to use to capture specific data. You can find the scripting manual at the following location:
http://www.vandyke.com/support/tips/...ing/index.html
The scripting manual may actually be a good place to start to get exposure to best practices.

I noticed in your script code that you are not using the Synchronous property. This is essential for not missing data when using Send() and WaitForString().

Does this help you get your script working?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #4  
Old 07-17-2014, 12:18 PM
surezae surezae is offline
Registered User
 
Join Date: Jul 2014
Posts: 8
Hi Todd,

Thank you very much for the support. Now it works.
Why didn't think of it to use Msgbox to see if the result I want is correct
I finally found out the poblem is with this "crt.Screen.WaitForString promptXYZ".

I changed using :
Do
bCursorMoved = crt.Screen.WaitForCursor(15)
Loop Until bCursorMoved = False

I'm having problem with prompt, because I'm getting this kind of prompt :
chr(27) & "[1;32mHOST1234" & chr(27) & "[0m> "

If I set it only : crt.Screen.WaitForString "HOST1234" it will not detect it.
Do you know how to get secureCRT to detect as long as it is "HOST1234" It can continue with the process?
Reply With Quote
  #5  
Old 07-17-2014, 02:43 PM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,305
Hi surezae,

Thanks for the update. I am glad to hear that you are getting closer to a solution.

You may be able to accomplish your goal using the IgnoreEscape property prior to making your WaitForString() call.

Does this help?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #6  
Old 07-17-2014, 04:23 PM
surezae surezae is offline
Registered User
 
Join Date: Jul 2014
Posts: 8
Hi Todd,

I will try it.
But meanwhile, there seems to be problem, sometime the result is not number,
instead is "N/A". Due to that script fail when the result data is N/A.
Could you advise me on what I should do.
Reply With Quote
  #7  
Old 07-17-2014, 05:15 PM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,305
Hi surezae,

To best assist you, if your script is failing, we need to know what line is failing, and if the code has been modified, it is also helpful to include the current iteration of the code you are using.

My guess as to a solution would be to validate the data prior to moving forward in the script.

Here are a couple of lines from the previous post:
hostvalue=crt.Screen.Get(cell,34,cell,37)
If hostvalue < 60 Then
You get the data, and immediately take an action. You may want to first determine you are actually working with a number.

For example:
Code:
hostvalue=crt.Screen.Get(cell,34,cell,37) 
If IsNumeric(hostvalue) = True Then
    If hostvalue < 60 Then
        .
        .
    End If
End If
Does this help?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #8  
Old 07-17-2014, 10:14 PM
surezae surezae is offline
Registered User
 
Join Date: Jul 2014
Posts: 8
Hi Todd,
I'm very grateful for your support
It's working fine now although detect "N/A" the process still running.

The last thing I need is to have a timeout control.
I see from the forum you're advising member to use : "section 3.6".

But what I would prefer is that the script has timelimit.
So for example, I want the script to run in 1 hour, if reach one hour then just close the session and create a new session then start again.

Because in device that I'm handling, it has many type of error or suddenly lost connection that would make the script halt, not continuing the process.

Please advise me.
And for your information my secureCRT version is version 7.2.5 (x64 build 550)

Last edited by surezae; 07-17-2014 at 10:27 PM.
Reply With Quote
  #9  
Old 07-18-2014, 12:30 PM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,305
Hi surezae,

SecureCRT doesn't have a built-in API option to accomplish your goal, but VBScript does have the Timer function.

You could set a variable equal to Timer, and then have a loop that wraps the rest of your script, and continually checks the delta using Timer during each loop.

For example:
Code:
nInitial = Timer
Do While Timer - nInitial < 3600
    ' do work
Loop
Does this help?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #10  
Old 07-21-2014, 08:33 AM
surezae surezae is offline
Registered User
 
Join Date: Jul 2014
Posts: 8
Hi Todd,

I don't understand how to run this "Timer".
I've put in to the script but nothing happen.
But I think this is because of my lack of experience in scripting, I'm still newbie.
So, what I did if I found an error I put it in "readstring" and then "If screen.matchindex.

Once again, thank you very much for your help.
Reply With Quote
  #11  
Old 07-21-2014, 04:51 PM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,305
Hi surezae,

I am not sure I understand your current goal.

The time is a way to get the time when the script starts, and then stop the script when an hour has elapsed. This will not be exactly an hour, but it would be close.

Would you post your code where you tried to use it?
Quote:
So, what I did if I found an error I put it in "readstring" and then "If screen.matchindex.
How does this related to the timer?

If it doesn't, would you provide more details about what you are trying to accomplish?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
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 10:42 PM.