wrap selected text, with conditions

wrap selected text, with conditions

8
NewbieNewbie
8

    Oct 31, 2005#1

    Hello,

    I've tried to do a simple macro :
    wrap the selected text with "<a href="selText">selText</a> if selText begin by "http" or
    wrap the selected text with "<a href="http://selText">selText</a> if not.

    My macro always add "http://".

    Do you see the problem ?

    Code: Select all

    InsertMode
    ColumnModeOff
    HexOff
    UnixReOff
    
    Clipboard 9
    
    Find Select "http"
    
    IfFound
      Cut 
      "<a href=""
      Paste 
      "">"
      Paste 
      "</a>"
      Clipboard 0
    Else
      Cut 
      "<a href="http://"
      Paste 
      "">"
      Paste 
      "</a>"
      Clipboard 0
    EndIf
    
    
    thanks

    6,686585
    Grand MasterGrand Master
    6,686585

      Oct 31, 2005#2

      I think you have misunderstood something. Find Select "http" does not search for "http" in the selected area. It searches for "http" and selects everything from current cursor position to "http" if found (same as holding Shift key while pressing the OK button in the find dialog). It's not possible to search only inside a selected area.

      And I have never tried but I guess, that Find Select with IfFound or IfNotFound is not possible. This combination simply makes no sense.

      Suggestion:

      First always delete "http://" in the selected text and then always add it.

      Find "http://"
      Replace All SelectText ""
      Best regards from an UC/UE/UES for Windows user from Austria

      344
      MasterMaster
      344

        Oct 31, 2005#3

        Hi,

        Either I went stupid or there is a bug in "find select" (10.20+2) ....
        It never finds anything....
        Type this complicated file:

        Hello
        you
        out
        there

        and mark whatevery you want, say, "you"

        Now play the makro that looks for "you":

        Code: Select all

        InsertMode
        ColumnModeOff
        HexOff
        UnixReOff
        Find Select "you"
        IfFound
        "yes !!!"
        Else
        "no :-("
        EndIf
        

        I'm keen on your behaviour on this ...

        P.S. Its not better when working with "StartSelect" ...

        rds bego
        Normally using all newest english version incl. each hotfix. Win 10 64 bit

        8
        NewbieNewbie
        8

          Nov 01, 2005#4

          thank you Mofi,

          It's working well now.
          I've had a "clipboard 8 copy" to keep the original string.

          Here is the new one :

          Code: Select all

          InsertMode
          ColumnModeOff
          HexOff
          UnixReOff
          
          Clipboard 8
          Copy 
          Clipboard 9
          
          Find "http://"
          Replace All SelectText ""
          
          Cut 
          "<a href="http://"
          Paste 
          "">"
          Clipboard 8
          Paste 
          "</a>"
          Clipboard 0
          

          Bego :
          mofi wrote:I guess, that Find Select with IfFound or IfNotFound is not possible.

          344
          MasterMaster
          344

            Nov 01, 2005#5

            Hi neekolo & Mofi,

            seems so. Nevertheless, help file isn't helpful here: :?
            Find Select: Nur markierten Text durchsuchen (optional).
            (Only find in marked text)
            Anyway there is a good solution for that now ... :wink:

            rds Bego
            Normally using all newest english version incl. each hotfix. Win 10 64 bit

            6,686585
            Grand MasterGrand Master
            6,686585

              Nov 01, 2005#6

              Bego wrote:Find Select: Nur markierten Text durchsuchen (optional).
              (Only find in marked text)
              In English help the option Select is described as follows:

              Select - indicates the text should be selected from the current selection/position to the end of the search target

              If this is wrong described in German help, you should report this to IDM.

              To test if Find Select has found something, use IfSel command instead of IfFound.
              Best regards from an UC/UE/UES for Windows user from Austria