Find Command Stuck

Find Command Stuck

2
NewbieNewbie
2

    Mar 01, 2014#1

    Hello. I am a beginner with macros and ran into a problem. I was wondering if I am doing something wrong or if this is a bug.

    What happens is, if I search for a keyword twice and there is only 1 of them in the document, subsequent Find commands will stop to function.

    The actual macro I am using is bigger, but I can demonstrate what is happening with a very simple example:

    Example Text:
    Hello John.
    Hello Ed.
    Hello Ed.

    Example Macro 1:
    InsertMode
    ColumnModeOff
    HexOff
    UltraEditReOn
    Find "john"
    Find "john"
    Top
    Find "ed"

    - Result: It will not be able to find the word Ed.

    Example Macro 2:
    InsertMode
    ColumnModeOff
    HexOff
    UltraEditReOn
    Find "ed"
    Find "ed"
    Top
    Find "john"

    - Result: This works fine, because there are 2 Eds. Now for something even more puzzling. I will select a piece of text (John) in stead of searching for it directly.

    Example Macro 3:
    InsertMode
    ColumnModeOff
    HexOff
    UltraEditReOn
    Find "hello"
    Key RIGHT ARROW
    StartSelect
    Key Ctrl+RIGHT ARROW
    EndSelect
    Find "^s"
    Top
    Find "ed"

    - Result: Again the Find command stops functioning. The only way to break out of it is by printing some text (and removing it).

    Example Macro 4:
    InsertMode
    ColumnModeOff
    HexOff
    UltraEditReOn
    Find "hello"
    Key RIGHT ARROW
    StartSelect
    Key Ctrl+RIGHT ARROW
    EndSelect
    Find "^s"
    "X"
    Key BACKSPACE
    Top
    Find "ed"

    - Result: This works fine again.

    So can anyone explain to me what is happening? Thanks in advance.

    6,602547
    Grand MasterGrand Master
    6,602547

      Mar 02, 2014#2

      Macro 1 and 2 do not work as expected with UE v21.00.0.1033 and v20.00.0.1056, but work with UE v19.10.0.1012 and previous versions.

      Macro 3 fail in all version of UltraEdit with which I executed the macro, oldest was 11.20b.

      This is from my point a view definitely a bug in code of UltraEdit. Looks like a synchronization problem after command Top.

      Please report this problem with your excellent steps and examples to reproduce the problem as posted here by email to IDM support.
      Best regards from an UC/UE/UES for Windows user from Austria

      2
      NewbieNewbie
      2

        Mar 02, 2014#3

        Thank you for replying and the additional research. I only added the TOP commands to make the behavior more consistent so the examples are easier to compare, but even without them it still glitches.

        I think I am a little closer to the problem. See the next example, which is a variant of 2.

        Example 2b:
        InsertMode
        ColumnModeOff
        HexOff
        UltraEditReOn
        Find "ed"
        Find "ed"
        Find "ed"
        Top
        Find "john"

        - Result: While example 2 worked fine, 2b did not. What I think happens is that FIND reaches the end of the document and should start searching from the top again (hence I thought to add TOP, but to no avail), but in stead gets 'stuck'.

        I will try to email IDM Comp. with my findings.

        6,602547
        Grand MasterGrand Master
        6,602547

          Mar 03, 2014#4

          Please note that a Find/Replace executed from within an UltraEdit macro or script is always only from current position of the caret down to end of file (search downwards) or up to beginning of file (search upwards). The search configuration setting Continue find at End of File is always temporarily disabled as also the replace all option Replace All is from top of file and similar options when running a script/macro. This behavior is needed to avoid endless loops.

          That's the reason why command Top or Bottom must be used to move caret to other end of file as you have done here absolutely correct.

          I could see that command Top was executed after a not successful Find and therefore the caret was blinking at top of the file after the macros finished. But the Find command after Top always failed if a Find before Top failed too. That is definitely a bug of UltraEdit which can be worked around as you have proven. But it would be definitely better when the developers of IDM fix that bug in a future version as soon as possible, best in a hotfix version of UE v21.00 as this is an ugly bug.
          Best regards from an UC/UE/UES for Windows user from Austria