Loading ...
Sorry, an error occurred while loading the content.

Re: [Clip] Re: StrReplace

Expand Messages
  • Axel Berger
    ... That If ought to be superfluous - the A already does the same. And yes, thats exactly what I m going to do, except that with Replace I can only set a
    Message 1 of 13 , Nov 29, 2012
    • 0 Attachment
      John Shotsky wrote:
      > Replace [whatever] >> [whatever] AHIRS0
      > IfError Next Else Skip_-1

      That If ought to be superfluous - the A already does the same.

      And yes, thats exactly what I'm going to do, except that with Replace I
      can only set a marker, not the final thing which requires using a
      function.
      As ^$Function($1)$ can't be used I'll have to loop them one by one and
      use ^$Function(^$GetSelection$)$.

      Never mind. In most cases there won't be any Russian and then it all
      boils down to two failed Finds, that take up no time whatever. Still,
      Regex and functions would be very nice to have in the same Replace
      command or function.

      Axel
    • Axel Berger
      ... To finalize the thread, this is what I ve come up with and what seems to ... ^!Jump TEXT_START ... ;long line start ^!Find
      Message 2 of 13 , Nov 30, 2012
      • 0 Attachment
        Axel Berger wrote:
        > And yes, that's exactly what I'm going to do,

        To finalize the thread, this is what I've come up with and what seems to
        work fine:

        :russian
        ^!Jump TEXT_START
        :russloop
        ;long line start
        ^!Find "(?s)^\\inputencoding\{x-cp1251(.*?)^\\inputencoding\{x-atarist"
        HRS1
        ;long line end
        ;^!Continue
        ^!IfError unicode
        ^!Replace "([\xC0-\xFF])" >> "&#R$1;" HRAST
        ^!Goto russloop
        :unicode
        ^!Jump TEXT_START
        :uniloop
        ^!Find "&#(R.);" RS1
        ;^!Continue
        ^!IfError atari
        ;long line start
        ^!InsertText
        ^$Calc(848+^$CharToDec(^$StrCopyRight("^$GetSelection$";1)$)$;0)$
        ;long line end
        ^!Goto uniloop
        :atari

        Axel
      • joy8388608
        ... How about a set of farclip subroutines that remember the current selection and reselect the remembered selection? That would be a nice enhancement! Joy
        Message 3 of 13 , Nov 30, 2012
        • 0 Attachment
          --- In ntb-clips@yahoogroups.com, Axel Berger <Axel-Berger@...> wrote:
          >
          > "flo.gehrke" wrote:
          > > > ^!Find "[\xC0-\xF0]" RS
          >
          > Yes, but it needs to be a Find H inside a selection and the first hit
          > destroys it. I'll now use a regex ^!Replace to mark the russian letters and a second ^!Find loop to work them one by one.
          >
          > Axel
          >

          How about a set of farclip subroutines that remember the current selection and reselect the remembered selection? That would be a nice enhancement!

          Joy
        • flo.gehrke
          ... Interesting solution! Maybe you could even omit marking those characters with R . Search those characters inside the selection, assign them to an array,
          Message 4 of 13 , Dec 1, 2012
          • 0 Attachment
            --- In ntb-clips@yahoogroups.com, Axel Berger <Axel-Berger@...> wrote:
            >
            > To finalize the thread, this is what I've come up with and what
            ; seems to work fine:
            >
            > :russian
            > ^!Jump TEXT_START
            > :russloop
            > ;long line start
            > ^!Find "(?s)^\\inputencoding\{x-cp1251(.*?)^\\inputencoding\{x-atarist"
            > HRS1
            > ;long line end
            > ;^!Continue
            > ^!IfError unicode
            > ^!Replace "([\xC0-\xFF])" >> "&#R$1;" HRAST
            > ^!Goto russloop
            > :unicode
            > ^!Jump TEXT_START
            > :uniloop
            > ^!Find "&#(R.);" RS1
            > ;^!Continue
            > ^!IfError atari
            > ;long line start
            > ^!InsertText
            > ^$Calc(848+^$CharToDec(^$StrCopyRight("^$GetSelection$";1)$)$;0)$
            > ;long line end
            > ^!Goto uniloop
            > :atari


            Interesting solution!

            Maybe you could even omit marking those characters with 'R'. Search those characters inside the selection, assign them to an array, and edit them one after another in the same order.

            I don't have your data and couldn't test it. But possibly it could work as follows:


            ^!Find "(?s)^\\inputencoding\{x-cp1251.*?^\\inputencoding\{x-atarist" WRS
            ^!SetListDelimiter "|"
            ^!SetArray %Char%=^$GetDocListAll("[\xC0-\xFF]";"&#$0;|")$
            ^!Set %i%=1

            :Loop
            ^!Find "[\xC0-\xFF]" RS
            ; Long line start
            ^!InsertText ^$StrReplace(^$GetSelection$;^$Calc(848+^$CharToDec(^$GetSelection$)$)$;"^%Char^%i%%";R)$
            ; Long line end
            ^!Inc %i%
            ^!If ^%i% < ^%Char0 Loop


            Regards,
            Flo
          • Axel Berger
            ... There may be more than one such foreign block and there may be more than one lnguage, Greek and Hebrew are other possibilities. That s why I needed the R
            Message 5 of 13 , Dec 1, 2012
            • 0 Attachment
              "flo.gehrke" wrote:
              > Maybe you could even omit marking those characters with 'R'. Search
              > those characters inside the selection, assign them to an array, and
              > edit them one after another in the same order.

              There may be more than one such foreign block and there may be more than
              one lnguage, Greek and Hebrew are other possibilities. That's why I
              needed the R to specify Russian.

              Axel
            Your message has been successfully submitted and would be delivered to recipients shortly.