Consulting

Results 1 to 6 of 6

Thread: Need help on WaitForString methods in Unix

  1. #1
    VBAX Newbie
    Joined
    Jun 2018
    Posts
    3
    Location

    Need help on WaitForString methods in Unix

    I have recorded some macros, and I get the gist of much of it (how to output text, press function keys, etc. What I'm struggling with is the "text" parameter of the WaitForString() methods.

    Below are some examples of the generated code. The first entry is pretty much self-explanatory. It just waits for the text "LEADS" on the screen. The next ones are where I start to struggle. What does the "H" mean in the second line? What does the "[" mean in the bottom 3 lines? What about the "0m" and "0mS"? The "10;44" looks kinds of like a location on screen, but I'm not sure. I want to be able to write my own macros without having to record everything to get the proper WaitForString values.

    Any help on the syntax/structure of this text argument would be most appreciated. I can't find any help on it anywhere online.

    returnValue = osCurrentScreen.WaitForString3("LEADS", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
    returnValue = osCurrentScreen.WaitForString3("H" & ESC & "[0m", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
    returnValue = osCurrentScreen.WaitForString3(HT & "[0mS", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
    returnValue = osCurrentScreen.WaitForString3(ESC & "[10;44H", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)

  2. #2
    Moderator VBAX Wizard SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    6,971
    Location
    Just a guess here
    Everything, Including brackets and punctuation marks, that are inside double quotes is a String.
    Esc is not a printable character so the Strings before and after must be Concatenated (&) with it. In fact "ESC" is a Variable whose Value is the nonprinting value of the Esc key.
    HT looks like a variable, but may be a special character, like Esc.

    As for exactly what "[10;44H" means, you would need to look at a complete and verbose log of the entire transaction to possibly determine that.

    I would bet that the "NEVER_TIME_OUT" Wait option means that the script is going to "hang" at each line until it receive the exact uppercase String it's waiting for.And will not show an error. Ever.

    You should read the WaitForStrings3 man page on your Unix system.

    I found this on the Net: http://docs.attachmate.com/reflectio...forstrings.htm Also click the ShowTableOfContents link thereon.


    In order to get better help, you need to provide great detail on what scripting languages, applications, and systems you are working with as well as what you are trying to do.
    Last edited by SamT; 06-05-2018 at 07:16 PM.
    I always expect the student to do their homework and find all the errrors I leeve in.

    Please take the time to read the Forum FAQ

  3. #3
    VBAX Newbie
    Joined
    Jun 2018
    Posts
    3
    Location
    Quote Originally Posted by SamT View Post
    Everything, Including brackets and punctuation marks, that are inside double quotes is a String.
    Esc is not a printable character so the Strings before and after must be Concatenated (&) with it. In fact "ESC" is a Variable whose Value is the nonprinting value of the Esc key.
    HT looks like a variable, but may be a special character, like Esc.
    I understand all of this. HT = Chr(9) = Tab key, ESC = Chr(27) = Escape key, etc.

    What I don't understand is when to include those in the string in the macro.

    Quote Originally Posted by SamT View Post
    As for exactly what "[10;44H" means, you would need to look at a complete and verbose log of the entire transaction to possibly determine that.
    What transaction logs are you talking about? I don't have access to the UNIX system, just the front-end application. There are no special characters (tab, escape, line feed, etc.) that are VISIBILE on the page, and since I only have access to the front-end screen, I can't see any non-printable characters.

    Quote Originally Posted by SamT View Post
    You should read the WaitForStrings3 man page on your Unix system.
    I have checked the URL you provided (and similar sites I have found on the web) show general details of the method calls, but nothing about the HT/ESC/[10;44H type of stuff. I have even checked the Micro Focus website and it also only tells that this argument is the string you are waiting for.

    Quote Originally Posted by SamT View Post
    In order to get better help, you need to provide great detail on what scripting languages, applications, and systems you are working with as well as what you are trying to do.
    I am writing macros for Micro Focus Reflections for VT Terminal. Macros for 3270 are much more straight-forward. I'm just having trouble with the VT Terminal macros (for UNIX-based application).

  4. #4
    Moderator VBAX Wizard SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    6,971
    Location
    Most of the details of WaitForString are outside my expertise.

    What is your Script supposed to be accomplishing?

    As for exactly what "[10;44H"
    If the Recorder added that to the recorded macro, then it came from you or your system. Is your computer a *nix or a Windows? I understand that it is easy for a *nix box to record a log of anything. Just don't ask me how. :
    I always expect the student to do their homework and find all the errrors I leeve in.

    Please take the time to read the Forum FAQ

  5. #5
    VBAX Newbie
    Joined
    Jun 2018
    Posts
    3
    Location
    Quote Originally Posted by SamT View Post
    What is your Script supposed to be accomplishing?

    If the Recorder added that to the recorded macro, then it came from you or your system. Is your computer a *nix or a Windows? I understand that it is easy for a *nix box to record a log of anything. Just don't ask me how. :
    I am essentially just entering a command or data into the application. The page builds itself as you enter data.

    I just recorded a short macro to show what I'm seeing. All I am doing here (from a user perspective) is typing "fxi2", hitting the enter key, typing "MBRMST", and hitting the tab key. Obviously my entire process/macro would be longer, but this should pretty much sum it up.

    Sub ExternalRecorded3()
    ' Generated by the Reflection Macro Recorder on 06-06-2018 09:52:26.82.
    ' Generated by Micro Focus Reflection Desktop (16.1.362.0).
    
    Dim osCurrentScreen As Screen
    Dim osCurrentTerminal As Terminal
    Dim returnValue As Integer
    
    
    Const NEVER_TIME_OUT = 0
    Dim HT As String    ' Chr(rcHT) = Chr(9) = Control-I
    Dim CR As String    ' Chr(rcCR) = Chr(13) = Control-M
    Dim ESC As String   ' Chr(rcESC) = Chr(27) = Control-[
    
    Set osCurrentTerminal = ThisFrame.SelectedView.Control
    Set osCurrentScreen = osCurrentTerminal.Screen
    HT = Chr(9)
    CR = Chr(13)
    ESC = Chr(27)
    
    osCurrentScreen.SendKeys "fxi2"
    osCurrentScreen.SendControlKey ControlKeyCode_Return
    
    ' The following string was not unique:
    'Wait for a string on the host screen before continuing
    ' returnValue = osCurrentScreen.WaitForString3(ESC & "[0m", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
    ' If (returnValue <> ReturnCode_Success) Then
    '   Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
    ' End If
    
    'Wait for a string on the host screen before continuing
    
    returnValue = osCurrentScreen.WaitForString3("H" & ESC & "[0m", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
    
    If (returnValue <> ReturnCode_Success) Then
        Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
    End If
    
    osCurrentScreen.SendKeys "MBRMST"
    'Wait for a string on the host screen before continuing
    
    returnValue = osCurrentScreen.WaitForString3(ESC & "[0mMBRMST", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
    
    If (returnValue <> ReturnCode_Success) Then
        Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
    End If
    
    ' Press Tab (Simulate pressing the keyboard Tab key).
    osCurrentScreen.SendControlKey ControlKeyCode_Tab
    
    ' The following string was not unique:
    'Wait for a string on the host screen before continuing
    ' returnValue = osCurrentScreen.WaitForString3(ESC & "[12;42H", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
    ' If (returnValue <> ReturnCode_Success) Then
    '   Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
    ' End If
    
    'Wait for a string on the host screen before continuing
    
    returnValue = osCurrentScreen.WaitForString3("_" & ESC & "[12;42H", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
    
    If (returnValue <> ReturnCode_Success) Then
        Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
    End If
    Exit Sub
    
    ' Recording stopped at 09:52:39.59.
    End Sub
    Last edited by SamT; 06-06-2018 at 12:47 PM.

  6. #6
    Moderator VBAX Wizard SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    6,971
    Location
    I still don't know what you're trying to accomplish.
    FXi2 might be a SAP code and you're connecting to the APPL Application or the ABAP Object. If so See: https://www.sap-tcodes.org/tcode/fxi2.html

    Here's what I think is happening... You're sending the command "fxi2" somewhere to something. That thing is replying "H" & ESC & "[0m".

    "H" & ESC & "[0m" means "Hello, read you loud and clear. Over."

    Then you send to that thing above,the command "MBRMST", and it replies, ESC & "[0mMBRMST".

    ESC & "[0mMBRMST" means, "Roger. Copy MBRMST. Over"

    Then you send a Tab character, and the thing replies, "_" & ESC & "[12;42H".

    "_" & ESC & "[12;42H" means, "Aye, aye, Sir, will do. Over and Out"

    As you can see, there are two ways to learn what the appropriate Replies from that thing are. Find it's manual, or keep experimenting and keep a list of replies to commands, both the replies that indicate success and those that indicate an error on your part. What the reply actually means doesn't matter, all that matters to you as a Coder is success and failure.



    Myself I would create a Module with a list of Mnemonic Constants for all the replies
    Const fxi2_Ready As String = "H" & ESC & "[0m"
    Const fxi2_MBRMST_Received As String = ESC & "[0mMBRMST"
    Const fxi2_MBRMST_Tab_Received As String = "_" & ESC & "[12;42H"
    That way, when you send an "fxi2", you know the reply should be fxi2_Ready



    BTW, FXI2, (all Caps) is the SAP TCode for Change Report, according the the above link. If that link is relevant, you might want to use some more constants. Like
    Const ChangeReport As String = "FXI2"
    Const DisplayReport As String = "FXI3"
    The purpose would be to make your code self documenting. The more your code reflects human reality, the better the code. At least IMHO.

    Imagine
    osCurrentScreen.SendKeys ChangeReport
    osCurrentScreen.SendControlKey ControlKeyCode_Return
    
    returnValue = osCurrentScreen.WaitForString3(ReadyTo_ChangeReport, _
    NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
    Again, if that link is relevant, what your macro is doing is telling the Parent Application (SAP?) to Change Report, Report Type MBRMST. Or sumpin like dat.
    Last edited by SamT; 06-06-2018 at 02:05 PM.
    I always expect the student to do their homework and find all the errrors I leeve in.

    Please take the time to read the Forum FAQ

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •