I made a macro to sort a form and it works fine as long as every thing that it searches for is there to find. If not it times out waiting for an event. I do not know VB, The only reason I put the [ ] around [rcEnterPos, "30", "0", 6, 53] was because every time it hit a , or " it gave me an error "expected then or goto". An if I do get the punctuation so the lines do not turn red it highlights ".WaitForEvent" and says "argument not optional" what I am trying to do is after it searches for "R8002" and does not find it. That it will continues after the ELSE line without a time out. The argument i was trying to do is If waitforevent is = to the cursor Position Then continue to the next line and if not goto the line after Else. The reason I put the if statement where i did is because this is where it turns yellow in debug mode after the time out.

IF starts on line 107
Else is on line 144

if it helps

waitForEvent = (event as long,TimeOut as String, Duration As Long Col As Long) (sub)

rcEnterPos = cursor enters Position (Const)

Sub FidSort124()
'
' Generated by the Reflection Macro Recorder on 08-04-2007  23:02:52.74
' Generated by Reflection for IBM for Windows 10.0.244
'
    With Session
        .WaitForEvent rcEnterPos, "30", "0", 4, 15
        .WaitForDisplayString "===>", "30", 4, 10
        .TransmitTerminalKey rcIBMTabKey
        .TransmitANSI "csr "
        .TransmitTerminalKey rcIBMHomeKey
        .WaitForEvent rcEnterPos, "30", "0", 4, 15
        .WaitForDisplayString "===>", "30", 4, 10
        .TransmitANSI "f ""end of order filling"""
        .TransmitTerminalKey rcIBMEnterKey
        .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
        .WaitForEvent rcEnterPos, "30", "0", 6, 16
        .WaitForDisplayString "-", "30", 6, 9
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitANSI "dd"
        .TransmitTerminalKey rcIBMEnterKey
        .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
        .WaitForEvent rcEnterPos, "30", "0", 8, 2
        .TransmitTerminalKey rcIBMHomeKey
        .TransmitANSI "bottom"
        .TransmitTerminalKey rcIBMEnterKey
        .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
        .WaitForEvent rcEnterPos, "30", "0", 4, 15
        .WaitForDisplayString "===>", "30", 4, 10
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitANSI "dd"
        .TransmitTerminalKey rcIBMEnterKey
        .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
        .WaitForEvent rcEnterPos, "30", "0", 5, 9
        .WaitForDisplayString "******", "30", 5, 2
        .TransmitTerminalKey rcIBMHomeKey
        .TransmitANSI "top"
        .TransmitTerminalKey rcIBMEnterKey
        .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
        .WaitForEvent rcEnterPos, "30", "0", 4, 15
        .WaitForDisplayString "===>", "30", 4, 10
        .TransmitANSI "sort 45"
        .TransmitTerminalKey rcIBMEnterKey
        .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
        .WaitForEvent rcEnterPos, "30", "0", 4, 15
        .WaitForDisplayString "===>", "30", 4, 10
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitANSI "dd"
        .TransmitTerminalKey rcIBMEnterKey
        .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
        .WaitForEvent rcEnterPos, "30", "0", 16, 2
        .TransmitTerminalKey rcIBMHomeKey
        .TransmitANSI "f r8000"
        .TransmitTerminalKey rcIBMEnterKey
        .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
        .WaitForEvent rcEnterPos, "30", "0", 6, 53
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMUpKey
        .TransmitTerminalKey rcIBMUpKey
        .TransmitANSI "dd"
        .TransmitTerminalKey rcIBMEnterKey
        .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
        .WaitForEvent rcEnterPos, "30", "0", 5, 11
        .TransmitTerminalKey rcIBMHomeKey
        .TransmitANSI "bottom"
        .TransmitTerminalKey rcIBMEnterKey
        .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
        .WaitForEvent rcEnterPos, "30", "0", 4, 15
        .WaitForDisplayString "===>", "30", 4, 10
        .TransmitTerminalKey rcIBMPf8Key
        .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
        .WaitForEvent rcEnterPos, "30", "0", 4, 15
        .WaitForDisplayString "===>", "30", 4, 10
        .TransmitANSI "f r8002 prev"
        .TransmitTerminalKey rcIBMEnterKey
        .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
        If _
            .WaitForEvent = [rcEnterPos, "30", "0", 6, 53] Then
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitANSI "dd"
        .TransmitTerminalKey rcIBMEnterKey
        .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
        .WaitForEvent rcEnterPos, "30", "0", 7, 2
        .TransmitTerminalKey rcIBMHomeKey
        .TransmitANSI "bottom"
        .TransmitTerminalKey rcIBMEnterKey
        .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
        .WaitForEvent rcEnterPos, "30", "0", 4, 15
        .WaitForDisplayString "===>", "30", 4, 10
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitANSI "dd"
        .TransmitTerminalKey rcIBMEnterKey
        .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
        .WaitForEvent rcEnterPos, "30", "0", 5, 9
        .WaitForDisplayString "******", "30", 5, 2
        Else _
            :.TransmitTerminalKey rcIBMHomeKey
        .TransmitANSI "top"
        .TransmitTerminalKey rcIBMEnterKey
        .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
        .WaitForEvent rcEnterPos, "30", "0", 4, 15
        .WaitForDisplayString "===>", "30", 4, 10
        .TransmitANSI "sort 124"
        .TransmitTerminalKey rcIBMEnterKey
        .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
        .WaitForEvent rcEnterPos, "30", "0", 4, 15
        .WaitForDisplayString "===>", "30", 4, 10
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMTabKey
        .TransmitTerminalKey rcIBMRightKey
        .TransmitTerminalKey rcIBMRightKey
        .TransmitTerminalKey rcIBMRightKey
        .TransmitTerminalKey rcIBMRightKey
        .TransmitTerminalKey rcIBMRightKey
        .TransmitTerminalKey rcIBMRightKey
        .TransmitTerminalKey rcIBMRightKey
        .TransmitTerminalKey rcIBMRightKey
        .TransmitTerminalKey rcIBMRightKey
        .TransmitTerminalKey rcIBMRightKey
        .TransmitANSI "FidSort "
        .TransmitANSI (Now)
        .TransmitTerminalKey rcIBMHomeKey
        .WaitForEvent rcEnterPos, "30", "0", 4, 15
        .WaitForDisplayString "===>", "30", 4, 10
        .TransmitANSI "save"
        .TransmitTerminalKey rcIBMEnterKey
        .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
        .WaitForEvent rcEnterPos, "30", "0", 4, 15
        .WaitForDisplayString "===>", "30", 4, 10
        .TransmitANSI "prn 1 s8"
        .TransmitTerminalKey rcIBMEnterKey
        .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
        .WaitForEvent rcEnterPos, "30", "0", 4, 15
        .WaitForDisplayString "===>", "30", 4, 10
        .TransmitANSI "=9.onfbrat"
        .TransmitTerminalKey rcIBMEnterKey
          End If   
    End With
End Sub

do i have to put something after the them to make it goto the next line? or does it just know to do that?

the only other way i can think of is to try is GOTO statement but from what a read it is not good to use them?

is there any other simple ways to make jumps in lines other than if, then. else?

does anyone read the posts?

what about waitForEvent = true then.

any help would be great!

This one's out of my league, but maybe if you post your program it might generate a better response?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.