jumping to another line

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • countryboy
    New Member
    • Jul 2007
    • 13

    jumping to another line

    I made a macro to sort a report that i can edited in VB. it works 98% of the time. r8002 is what i want it to find in this part of the macro. the only time this macro does not work is if there is not any r8002 to find and it stops. I want it to skip to the next part. is there any way i can make it say

    "if you do not see this"( .WaitForEvent rcEnterPos, "30", "0", 6, 53)

    than skip to the line that say (.TransmitANSI "top" )

    this is just a chunk of the macro i have noted where it stops and where i would like it to jump to. is there an easy way i can do this?

    If anyone can help thanks.

    [CODE=vb].TransmitANSI "f r8002 prev"
    .TransmitTermin alkey rcIBMNewLineKey
    .WaitForEvent rcKbdEnabled "30", "0", 1, 1
    .WaitForEvent rcEnterPos, "30", "0", 6, 53 (it stops here)
    .TransmitTermin alkey rcIBMNewLineKey
    .TransmitANSI "dd"
    .TransmitTermin alkey rcIBMEnterKey
    .WaitForEvent rcKbdEnabled "30", "0", 1, 1
    .WaitForEvent rcEnterPos, "30", "0", 7, 2
    .TransmitTermin alkey rcIBMHomeKey
    .TransmitANSI "bottom"
    .TransmitTermin alkey rcIBMEnterKey
    .WaitForEvent rcKbdEnabled "30", "0", 1, 1
    .WaitForEvent rcEnterPos, "30", "0", 4, 15
    .waitForDisplay String "===>", "30, 4, 10
    .TransmitTermin alkey rcIBMNewLineKey
    .TransmitTermin alkey rcIBMNewLineKey
    .TransmitANSI "dd"
    .TransmitTermin alkey rcIBMEnterKey
    .WaitForEvent rcKbdEnabled "30", "0", 1, 1
    .WaitForEvent rcEnterPos, "30", "0", 5, 9
    .waitForDisplay String "******","3 0", 5, 2
    .TransmitTermin alkey rcIBMHomeKey
    .TransmitANSI "top" (I want it to jump to here)
    .TransmitTermin alkey rcIBMEnterKey[/CODE]
    Last edited by Killer42; Sep 4 '07, 02:54 AM. Reason: Added [CODE=vb] tag. (Note there's an unclosed string turning everything red)
  • Martin2007
    New Member
    • Jul 2007
    • 21

    #2
    Code:
    If .WaitForEvent rcEnterPos, "30", "0", 6, 53 = SomeReturnValue 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
    .TransmitANSI "dd"
    .TransmitTerminalkey rcIBMEnterKey
    .WaitForEvent rcKbdEnabled "30", "0", 1, 1
    .WaitForEvent rcEnterPos, "30", "0", 5, 9
    .waitForDisplayString "******","30", 5, 2 
    .TransmitTerminalkey rcIBMHomeKey
    End IF
    .TransmitANSI "top"       
    .TransmitTerminalkey rcIBMEnterKey[/QUOTE]
    Does waitforevents return anything?

    If it does can you not just use If Then Else...???

    Comment

    • countryboy
      New Member
      • Jul 2007
      • 13

      #3
      "If .WaitForEvent rcEnterPos, "30", "0", 6, 53 = SomeReturnValue Then"

      "30", "0", 6, 53 is a cursor position i think that is what it is waiting for so would

      If .WaitForEvent rcEnterPos,= "30", "0", 6, 53 then

      and if it did not = "30", "0", 6, 53 it would junp to the line after end if?
      can i start a line with "if"?

      thanks its a little clealer

      Comment

      • countryboy
        New Member
        • Jul 2007
        • 13

        #4
        i thinking about what you said about then else does this look like it would work? does "if" and "else" have to be on there own line? how important is spacing? on some examples i see the lines after "if" and "else" are indented? if this will work i think i am starting to understand if not i am lost :)


        Code:
        .TransmitANSI "f r8002 prev"
        .TransmitTerminalkey rcIBMNewLineKey
        .WaitForEvent rcKbdEnabled "30", "0", 1, 1
        [B]if
        .WaitForEvent rcEnterPos,= "30", "0", 6, 53 then[/B]
        .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
        .TransmitANSI "dd"
        .TransmitTerminalkey rcIBMEnterKey
        .WaitForEvent rcKbdEnabled "30", "0", 1, 1
        .WaitForEvent rcEnterPos, "30", "0", 5, 9
        .waitForDisplayString "******","30", 5, 2
        .TransmitTerminalkey rcIBMHomeKey
        [B]else
        .TransmitANSI "top"
        end if[/B]
        .TransmitTerminalkey rcIBMEnterKey

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          It is standard practice to indent the lines of code that are dependent on an IF condition. In other words...
          Code:
          If <condition> Then
              Do something
          Else
              Do something different
          End If
          To split the condition from the actual IF though, I believe you would have to use the line continuation character (_), such as...
          [CODE=vb]If _
          .WaitForEvent rcEnterPos,= "30", "0", 6, 53 Then[/CODE]However, I fail to see what purpose this serves, apart from the purely cosmetic one of making the lines a bit shorter.

          Comment

          • countryboy
            New Member
            • Jul 2007
            • 13

            #6
            thanks but still having trouble I will start from the beginning to make it easier.

            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 ".WaitForEv ent" and says "argument not optional" what I am trying to do is after it searches for "R8002" and does not find it that it 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 statment where i did is because this is where it turns yellow in debug mode after the time out.

            IF statement starts on line 107
            ELSE on line 144

            if it helps

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

            rcEnterPos = cursor enters Position




            [CODE=vb]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
            .WaitForDisplay String "===>", "30", 4, 10
            .TransmitTermin alKey rcIBMTabKey
            .TransmitANSI "csr "
            .TransmitTermin alKey rcIBMHomeKey
            .WaitForEvent rcEnterPos, "30", "0", 4, 15
            .WaitForDisplay String "===>", "30", 4, 10
            .TransmitANSI "f ""end of order filling"""
            .TransmitTermin alKey rcIBMEnterKey
            .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
            .WaitForEvent rcEnterPos, "30", "0", 6, 16
            .WaitForDisplay String "-", "30", 6, 9
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitANSI "dd"
            .TransmitTermin alKey rcIBMEnterKey
            .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
            .WaitForEvent rcEnterPos, "30", "0", 8, 2
            .TransmitTermin alKey rcIBMHomeKey
            .TransmitANSI "bottom"
            .TransmitTermin alKey rcIBMEnterKey
            .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
            .WaitForEvent rcEnterPos, "30", "0", 4, 15
            .WaitForDisplay String "===>", "30", 4, 10
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitANSI "dd"
            .TransmitTermin alKey rcIBMEnterKey
            .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
            .WaitForEvent rcEnterPos, "30", "0", 5, 9
            .WaitForDisplay String "******", "30", 5, 2
            .TransmitTermin alKey rcIBMHomeKey
            .TransmitANSI "top"
            .TransmitTermin alKey rcIBMEnterKey
            .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
            .WaitForEvent rcEnterPos, "30", "0", 4, 15
            .WaitForDisplay String "===>", "30", 4, 10
            .TransmitANSI "sort 45"
            .TransmitTermin alKey rcIBMEnterKey
            .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
            .WaitForEvent rcEnterPos, "30", "0", 4, 15
            .WaitForDisplay String "===>", "30", 4, 10
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitANSI "dd"
            .TransmitTermin alKey rcIBMEnterKey
            .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
            .WaitForEvent rcEnterPos, "30", "0", 16, 2
            .TransmitTermin alKey rcIBMHomeKey
            .TransmitANSI "f r8000"
            .TransmitTermin alKey rcIBMEnterKey
            .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
            .WaitForEvent rcEnterPos, "30", "0", 6, 53
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMUpKey
            .TransmitTermin alKey rcIBMUpKey
            .TransmitANSI "dd"
            .TransmitTermin alKey rcIBMEnterKey
            .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
            .WaitForEvent rcEnterPos, "30", "0", 5, 11
            .TransmitTermin alKey rcIBMHomeKey
            .TransmitANSI "bottom"
            .TransmitTermin alKey rcIBMEnterKey
            .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
            .WaitForEvent rcEnterPos, "30", "0", 4, 15
            .WaitForDisplay String "===>", "30", 4, 10
            .TransmitTermin alKey rcIBMPf8Key
            .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
            .WaitForEvent rcEnterPos, "30", "0", 4, 15
            .WaitForDisplay String "===>", "30", 4, 10
            .TransmitANSI "f r8002 prev"
            .TransmitTermin alKey rcIBMEnterKey
            .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
            If _
            .WaitForEvent = [rcEnterPos, "30", "0", 6, 53] Then
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitANSI "dd"
            .TransmitTermin alKey rcIBMEnterKey
            .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
            .WaitForEvent rcEnterPos, "30", "0", 7, 2
            .TransmitTermin alKey rcIBMHomeKey
            .TransmitANSI "bottom"
            .TransmitTermin alKey rcIBMEnterKey
            .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
            .WaitForEvent rcEnterPos, "30", "0", 4, 15
            .WaitForDisplay String "===>", "30", 4, 10
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitANSI "dd"
            .TransmitTermin alKey rcIBMEnterKey
            .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
            .WaitForEvent rcEnterPos, "30", "0", 5, 9
            .WaitForDisplay String "******", "30", 5, 2
            Else _
            :.TransmitTermi nalKey rcIBMHomeKey
            .TransmitANSI "top"
            .TransmitTermin alKey rcIBMEnterKey
            .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
            .WaitForEvent rcEnterPos, "30", "0", 4, 15
            .WaitForDisplay String "===>", "30", 4, 10
            .TransmitANSI "sort 124"
            .TransmitTermin alKey rcIBMEnterKey
            .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
            .WaitForEvent rcEnterPos, "30", "0", 4, 15
            .WaitForDisplay String "===>", "30", 4, 10
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMNewLineKey
            .TransmitTermin alKey rcIBMTabKey
            .TransmitTermin alKey rcIBMRightKey
            .TransmitTermin alKey rcIBMRightKey
            .TransmitTermin alKey rcIBMRightKey
            .TransmitTermin alKey rcIBMRightKey
            .TransmitTermin alKey rcIBMRightKey
            .TransmitTermin alKey rcIBMRightKey
            .TransmitTermin alKey rcIBMRightKey
            .TransmitTermin alKey rcIBMRightKey
            .TransmitTermin alKey rcIBMRightKey
            .TransmitTermin alKey rcIBMRightKey
            .TransmitANSI "FidSort "
            .TransmitANSI (Now)
            .TransmitTermin alKey rcIBMHomeKey
            .WaitForEvent rcEnterPos, "30", "0", 4, 15
            .WaitForDisplay String "===>", "30", 4, 10
            .TransmitANSI "save"
            .TransmitTermin alKey rcIBMEnterKey
            .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
            .WaitForEvent rcEnterPos, "30", "0", 4, 15
            .WaitForDisplay String "===>", "30", 4, 10
            .TransmitANSI "prn 1 s8"
            .TransmitTermin alKey rcIBMEnterKey
            .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
            .WaitForEvent rcEnterPos, "30", "0", 4, 15
            .WaitForDisplay String "===>", "30", 4, 10
            .TransmitANSI "=9.onfbrat "
            .TransmitTermin alKey rcIBMEnterKey
            End If
            End With
            End Sub[/CODE]

            Comment

            • countryboy
              New Member
              • Jul 2007
              • 13

              #7
              do i have to put something after the then 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?

              Comment

              • countryboy
                New Member
                • Jul 2007
                • 13

                #8
                what about if waitForEvent = true then. do i have to put a goto after then or will it just go to the next line?

                Comment

                • Killer42
                  Recognized Expert Expert
                  • Oct 2006
                  • 8429

                  #9
                  Sorry, I haven't really been following this thread, largely because so much of the syntax looks unfamiliar. I'm not familiar with WaitForEvent and so on. What version of VB are you using, and what does all this relate to? In other words, what is a "Session" object?

                  Um... actually, you said that it was a macro. In what product?

                  As for the If/Then business, VB (or any language which includes this structure) will automatically follow the appropriate path through an IF...ELSE...END IF block. If the IF condition is True, it will execute the code following THEN. Otherwise, it will execute the code (if any) following ELSE. It will always either the True block or, if present, the False block. There is no need to "tell it" to go on to the next statement.

                  I suspect any confusion may arise from the nature of the WaitForEvent function (or method, or whatever it is). To judge from it's name, it will stop and wait for an event to occur. If that event never occurs, then maybe it will continue to wait forever. However, with parameters called "Timeout" and "Duration", it seems as though you should be able to control that. Most likely, if it times out, that is when you would hit the False condition and thus execute the Else block.

                  Most languages support a number of statements which control the flow of execution (or "make jumps in lines").

                  The main ones which come to mind, with some examples, would be...
                  • Branching
                    • If/Else
                    • Select Case
                  • Looping
                    • For...Next
                    • For Each...Next (not the same thing, at all)
                    • Do While...Loop
                    • Do Until...Loop
                    • While...Wend

                  The GOTO statement should rarely be required, and is widely seen as a sign of poor, or at least lazy, programming.

                  Comment

                  • countryboy
                    New Member
                    • Jul 2007
                    • 13

                    #10
                    "The Reflection object name (Application vs session)
                    In versions of Reflection prior to 7.0, all methods and properties acted on the
                    Application object. The newer Session object is now used in all help programming examples. However, if you are creating and/or maintaining Reflection Basic scripts,
                    you should continue to use Application for the Reflection object name."
                    not sure what that means but it came out of the manual.

                    I'm using VB6.

                    The product is Reflection for IBM.

                    It says in the manual

                    Programming language elements that are common to all implementations of BASIC include:
                    Data types, variable and constants, and arrays (declared with Dim and Const)
                    •Operators and expressions (such as +, -, *, /, Not, Like, and Or)
                    •User-defined functions and procedures (Sub and Function)
                    •Control structures and loops (such as For ... Next, Do ... Loop, and If ... Then ... Else)
                    Additional concepts in VBA and stand-alone Visual Basic include:
                    •Objects
                    •Forms
                    •Events

                    So i think it would work if i knew how to "declare" it with a Dim or Const.

                    if you could give me an example using my code that would be great.

                    Comment

                    Working...