VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Scripting (https://forums.vandyke.com/forumdisplay.php?f=14)
-   -   Am I capturing hidden characters? (https://forums.vandyke.com/showthread.php?t=12398)

ShawnVW 07-06-2016 11:03 AM

Am I capturing hidden characters?
 
I'm using the Get command to capture a single character on screen, usually the letter "N":

Code:

x = crt.screen.get(11,68,11,68)
crt.Session.SetStatusText(">" & x  & "<" )


But when this should display ">N<", it shows "> (about 20 blank spaces) <"

Are there some hidden characters or something that could be causing this?

bgagnon 07-06-2016 12:05 PM

1 Attachment(s)
Hi ShawnVW,

In my tests, it worked as expected, but I controlled the output (see attached). :)

There could be hidden characters in the output you receive, but I need additional information about that output. It's strange that you get 20 or so characters. It sounds like there could be line endings or tabs being converted to spaces that is throwing things off.

Are these two lines the entirety of your script?

What is the output you receive prior to running this code?

If you paste that output into some application with the ability to show hidden/non-printing characters, does that shed any light on what the 68th character actually is?

ShawnVW 07-06-2016 12:13 PM

Quote:

Originally Posted by bgagnon (Post 45976)
Are these two lines the entirety of your script?

Not even close!


Quote:

What is the output you receive prior to running this code?
It's a form. The character I want to capture is in one of the fields. Actually, I tried capturing the field label too, but I just got longer string of blank spaces.

Quote:

If you paste that output into some application with the ability to show hidden/non-printing characters, does that shed any light on what the 68th character actually is?
What sort of application can do that?

Thanks!

bgagnon 07-06-2016 01:21 PM

Hi ShawnVW,

With a form it may be difficult to accomplish the objective. Get() may not be the best method to use.

I believe you can show formatting marks in several of the Microsoft Office products. You might just search on "show invisibles" or a similar term in the Help file.

ShawnVW 07-06-2016 01:33 PM

I found something. The field label reads "22)<7 spaces>ALLOW B/O".

I used this:

Code:

        strResult = crt.Screen.ReadString("ALLOW B/O:")
        msgbox(right(strResult,20))

The result I expected was:

"<several spaces>22)<7 spaces>ALLOW B/O:"

What I got was:
"N:<left arrow>[11;47H22)<several spaces>"

Isn't there some method to capture just the "normal" characters onscreen?

If Get isn't the best way to see what's at a particular point on the screen, what would be better?

bgagnon 07-06-2016 01:47 PM

Hi ShawnVW,

Yes, I believe it's the IgnoreEscape property available to the Screen Object that you seek. (See Scripting / Script Objects Reference / Screen Object in SecureCRT's Help file.)

That should take care of the escape sequence [11;47H22], but I am not sure what you mean by the <left arrow> reference. What is the actual output?


Quote:

If Get isn't the best way to see what's at a particular point on the screen, what would be better?
Right now I only have limited information. I would need "big picture" info to provide any further advice. :)

ShawnVW 07-06-2016 02:07 PM

By <left arrow> I meant single character that looks like a left-pointing arrow.

I tried IgnoreEscape. I got a different string:
)800 PHN:22) <spaces>

When you say "What is the actual output", I'm not sure what to say other than its a screen full of field labels and the content of those fields. (How can I attach a screenshot?)

bgagnon 07-06-2016 02:49 PM

Hi ShawnVW,

There should be a paperclip icon in the formatting toolbar provided when you post a reply. That will allow you to attach files.

I suspect the best way to see what the output is will be to get a raw log.

To create a raw log:
  • Before connecting with the session, select Raw Log Session from SecureCRT's File menu.
  • In the Select Log File dialog, choose a folder and filename in which you would like the log text to be stored and press the Save button. At this point, if you open the File menu, you will notice that the Raw Log Session menu item now has a checkmark next to it; this indicates that raw logging is activated.
  • Now connect to the remote machine and perform the actions that cause the behavior.
  • Disconnect the session and select Raw Log Session from the File menu to turn off the raw logging feature.
Since a raw log can contain sensitive information, please send it as an attachment via email to support@vandyke.com. Please reference "Attn Brenda - Forum Thread #12398" in the subject line.

ShawnVW 07-06-2016 04:44 PM

1 Attachment(s)
I'm not sure I'm allowed to send you a filled-out form (or log), but here's a blank one attached.

The Raw Log shows lots of those symbols and codes I described, even with IgnoreEscape turned on. After experimenting some more with ReadString, I don't think the characters' "position" is really where they "are".

Thanks, though.

bgagnon 07-07-2016 09:52 AM

Hi ShawnVW,

Without the raw log, I can only guess, but if the ALLOW B/O is the data you are trying to get, then you might consider code similar to this:

Code:

crt.Screen.WaitForString("ALLOW B/O:")
crt.Screen.ReadString("Y", "N")
If crt.Screen.MatchIndex = 1 Then
    MsgBox("Allow B/O = Yes!")
ElseIf crt.Screen.MatchIndex = 2 Then
    MsgBox("Allow B/O = No")
End If

That assumes that the Y or the N actually comes from the remote in sequence row by row. It's possible that the remote system paints all the fields first, and then paints the values in the fields (you already know there's at least an escape sequence surrounding the "Y" and the "N" to make it bold, so crt.Screen.IgnoreEscape will need to remain true for the duration of whatever script you are running).

ShawnVW 07-07-2016 10:08 AM

I think you're right about the field values being painted after the field labels. Plus, when I capture the text with ReadString, it shows nothing between one label and the next, as if the field itself isn't there.

I'll just have to proceed without actually "knowing" what's in that field. Thanks again!


All times are GMT -6. The time now is 06:44 PM.