Skip to main content

Hi all.

I'm having an issue having a script that keeps returning the "ghost" value from the previous screen. The code is supposed to access a dividend announcement file and flip through the different accounts until it get to the very last account. There's 12 accounts in each flip, hence if we have 15 accounts, the script would have to flip (manual loop) twice (12 3). Now, I have the script stop on the 7th account of the fourth loop and read whatever is there. I know if to be blank, but the script keeps reading the value from the 3rd run of the loop:

 

Sub Main()

Dim EmptyString as String
Dim EmptyStringFinal as String

EMSendKey "<CLEAR>" 
EMSendKey "DIVD"
EMSendKey "<ENTER>" 
EMSendKey "AD"
EMSetCursor 23,62
EMSendKey "444663656"
EMSendKey "<ENTER>" 
 
EMSetCursor 23,10
EMSendKey "PF"
EMSendKey "<ENTER>"

EMSendKey "<PF1>"
EMSendKey "<PF1>"
EMSendKey "<PF1>"
EMSendKey "<PF1>"

 
EMReadScreen EmptyString, 12, 12, 7
EmptyStringFinal=Trim(EmptyString)

msgbox EmptyStringFinal

End Sub

 

Can you help?


#Rumba

Hi all.

I'm having an issue having a script that keeps returning the "ghost" value from the previous screen. The code is supposed to access a dividend announcement file and flip through the different accounts until it get to the very last account. There's 12 accounts in each flip, hence if we have 15 accounts, the script would have to flip (manual loop) twice (12 3). Now, I have the script stop on the 7th account of the fourth loop and read whatever is there. I know if to be blank, but the script keeps reading the value from the 3rd run of the loop:

 

Sub Main()

Dim EmptyString as String
Dim EmptyStringFinal as String

EMSendKey "<CLEAR>" 
EMSendKey "DIVD"
EMSendKey "<ENTER>" 
EMSendKey "AD"
EMSetCursor 23,62
EMSendKey "444663656"
EMSendKey "<ENTER>" 
 
EMSetCursor 23,10
EMSendKey "PF"
EMSendKey "<ENTER>"

EMSendKey "<PF1>"
EMSendKey "<PF1>"
EMSendKey "<PF1>"
EMSendKey "<PF1>"

 
EMReadScreen EmptyString, 12, 12, 7
EmptyStringFinal=Trim(EmptyString)

msgbox EmptyStringFinal

End Sub

 

Can you help?


#Rumba
Hi Jose_Leon,
Is it a good practice to initialize variables when they are declared. It often prevents unexpected results.
If there is a meaningful value that you can use to initialize a variable at declaration time,then do it.
You should check and "reset" your variable after each loop. If you need all values then use an array.

Hi all.

I'm having an issue having a script that keeps returning the "ghost" value from the previous screen. The code is supposed to access a dividend announcement file and flip through the different accounts until it get to the very last account. There's 12 accounts in each flip, hence if we have 15 accounts, the script would have to flip (manual loop) twice (12 3). Now, I have the script stop on the 7th account of the fourth loop and read whatever is there. I know if to be blank, but the script keeps reading the value from the 3rd run of the loop:

 

Sub Main()

Dim EmptyString as String
Dim EmptyStringFinal as String

EMSendKey "<CLEAR>" 
EMSendKey "DIVD"
EMSendKey "<ENTER>" 
EMSendKey "AD"
EMSetCursor 23,62
EMSendKey "444663656"
EMSendKey "<ENTER>" 
 
EMSetCursor 23,10
EMSendKey "PF"
EMSendKey "<ENTER>"

EMSendKey "<PF1>"
EMSendKey "<PF1>"
EMSendKey "<PF1>"
EMSendKey "<PF1>"

 
EMReadScreen EmptyString, 12, 12, 7
EmptyStringFinal=Trim(EmptyString)

msgbox EmptyStringFinal

End Sub

 

Can you help?


#Rumba
Hi,
Please note that the EMSendKey is asynchronous request when you are sending action keys like ENTER, PF's etc.
Due to that you need to wait for your host to reply back with the new screen using one of the wait command:
EMWaitText is probably the prefered way
EMWaitX is also OK but will cause your script for a short delay
Hope this will help
Adi

Hi all.

I'm having an issue having a script that keeps returning the "ghost" value from the previous screen. The code is supposed to access a dividend announcement file and flip through the different accounts until it get to the very last account. There's 12 accounts in each flip, hence if we have 15 accounts, the script would have to flip (manual loop) twice (12 3). Now, I have the script stop on the 7th account of the fourth loop and read whatever is there. I know if to be blank, but the script keeps reading the value from the 3rd run of the loop:

 

Sub Main()

Dim EmptyString as String
Dim EmptyStringFinal as String

EMSendKey "<CLEAR>" 
EMSendKey "DIVD"
EMSendKey "<ENTER>" 
EMSendKey "AD"
EMSetCursor 23,62
EMSendKey "444663656"
EMSendKey "<ENTER>" 
 
EMSetCursor 23,10
EMSendKey "PF"
EMSendKey "<ENTER>"

EMSendKey "<PF1>"
EMSendKey "<PF1>"
EMSendKey "<PF1>"
EMSendKey "<PF1>"

 
EMReadScreen EmptyString, 12, 12, 7
EmptyStringFinal=Trim(EmptyString)

msgbox EmptyStringFinal

End Sub

 

Can you help?


#Rumba

Hi Jose_Leon,

in addition to what @ndre says, you don't mention which version of Rumba you are using or the  connectivity which you are using.

Here is a sample on how one can loop and note the various strings which appear on screen:

Sub Main
    Dim myString as String, i as Integer, myMsgString as String, my2ndLastString as String
    Dim myStrings(10) as string
    EMSendKey "<CLEAR>"
    EMWaitCursor 3, 1, 1
    EMSendKey "listcat"
    EMSendKey "<ENTER>"

    'Initialise my array index
    j = 1
    'Initialise my myString
    myString = "lets go"
    Do while myString <> ""
        For i = 1 to 24
            EMReadScreen myString, 30, i, 1
            myString = Trim(myString)
            'Check to see if the string read is blank
            if myString = "" then
                'If yes, then set a completed identifer at the end of our scraped data and exit
                myString = "Complete"
                Exit For
            End If
            'Let's note the last string read seperately (so we can compare later).
            my2ndLastString = myString
            myMsgString = myMsgString & myString & Chr$(13) & Chr$(10)
        Next i
        'Check if there is more data on the next screen if yes send <Enter>
        If myString = "***" then
            myStrings(j) = myMsgString
            j = j 1
            myMsgString = ""
            EMSendKey "<ENTER>"
        End If
        'Check to see if we are complete and if yes Exit the Do Loop
        if myString = "Complete" then Exit Do
    Loop
    'Let's check the array, and see what we have scraped from earlier screens.
    For i = 1 to UBound(myStrings)
        if myStrings(i) = "" then exit for
        Msgbox myStrings(i)
    'Let's check the last screen, and the last non blank line read.
    Next i
    Msgbox myMsgString & Chr$(13) & Chr$(10) & Chr$(10) _
                & "---------------------------------------------------------------------------" & Chr$(13) & Chr$(10) _
                & "my2ndLastString = " & my2ndLastString & Chr$(13) & Chr$(10) & "myString =" & myString
    myMsgString = ""
End Sub

Note: You can not Exit Do ig you are inside a For ... Next statement, you need to Exit For and then Exit Do, such an issue can lead to the kind of problem which you are seeing.

Tom


Hi all.

I'm having an issue having a script that keeps returning the "ghost" value from the previous screen. The code is supposed to access a dividend announcement file and flip through the different accounts until it get to the very last account. There's 12 accounts in each flip, hence if we have 15 accounts, the script would have to flip (manual loop) twice (12 3). Now, I have the script stop on the 7th account of the fourth loop and read whatever is there. I know if to be blank, but the script keeps reading the value from the 3rd run of the loop:

 

Sub Main()

Dim EmptyString as String
Dim EmptyStringFinal as String

EMSendKey "<CLEAR>" 
EMSendKey "DIVD"
EMSendKey "<ENTER>" 
EMSendKey "AD"
EMSetCursor 23,62
EMSendKey "444663656"
EMSendKey "<ENTER>" 
 
EMSetCursor 23,10
EMSendKey "PF"
EMSendKey "<ENTER>"

EMSendKey "<PF1>"
EMSendKey "<PF1>"
EMSendKey "<PF1>"
EMSendKey "<PF1>"

 
EMReadScreen EmptyString, 12, 12, 7
EmptyStringFinal=Trim(EmptyString)

msgbox EmptyStringFinal

End Sub

 

Can you help?


#Rumba

Hi Jose_Leon,

in addition to what @ndre says, you don't mention which version of Rumba you are using or the  connectivity which you are using.

Here is a sample on how one can loop and note the various strings which appear on screen:

Sub Main
    Dim myString as String, i as Integer, myMsgString as String, my2ndLastString as String
    Dim myStrings(10) as string
    EMSendKey "<CLEAR>"
    EMWaitCursor 3, 1, 1
    EMSendKey "listcat"
    EMSendKey "<ENTER>"

    'Initialise my array index
    j = 1
    'Initialise my myString
    myString = "lets go"
    Do while myString <> ""
        For i = 1 to 24
            EMReadScreen myString, 30, i, 1
            myString = Trim(myString)
            'Check to see if the string read is blank
            if myString = "" then
                'If yes, then set a completed identifer at the end of our scraped data and exit
                myString = "Complete"
                Exit For
            End If
            'Let's note the last string read seperately (so we can compare later).
            my2ndLastString = myString
            myMsgString = myMsgString & myString & Chr$(13) & Chr$(10)
        Next i
        'Check if there is more data on the next screen if yes send <Enter>
        If myString = "***" then
            myStrings(j) = myMsgString
            j = j 1
            myMsgString = ""
            EMSendKey "<ENTER>"
        End If
        'Check to see if we are complete and if yes Exit the Do Loop
        if myString = "Complete" then Exit Do
    Loop
    'Let's check the array, and see what we have scraped from earlier screens.
    For i = 1 to UBound(myStrings)
        if myStrings(i) = "" then exit for
        Msgbox myStrings(i)
    'Let's check the last screen, and the last non blank line read.
    Next i
    Msgbox myMsgString & Chr$(13) & Chr$(10) & Chr$(10) _
                & "---------------------------------------------------------------------------" & Chr$(13) & Chr$(10) _
                & "my2ndLastString = " & my2ndLastString & Chr$(13) & Chr$(10) & "myString =" & myString
    myMsgString = ""
End Sub

Note: You can not Exit Do ig you are inside a For ... Next statement, you need to Exit For and then Exit Do, such an issue can lead to the kind of problem which you are seeing.

Tom