Help with algorithm in XML tps preproc

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Help with algorithm in XML tps preproc

  • Creator
    Topic
  • #51939
    Bob Moriarty
    Participant

      I want to convert inter-tag “<" character(s) to the string "less than". For example, convert

      Code:

      123 < x


      to

      Code:

      123 less than x

      Also, on “tagless” lines, convert

      Code:

      qwe < asd


      to

      Code:

      qwe less than asd

      And, to raise the difficulty level a bit, convert

      Code:

      qwe < asd < zxc


      to

      Code:

      qwe less than asd less than zxc

      I’m pretty comfortable with tps preprocs but I’m having trouble coming up with a simple algorithm to make this substitution in tcl.

      TIA

    Viewing 3 reply threads
    • Author
      Replies
      • #72401
        Jim Kosloskey
        Participant

          Bob,

          How about

          set var [string map

            $var

            Where var is the string with the < ?

          email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

        • #72402
          Bob Moriarty
          Participant

            Jim,

            You wrote

            Quote:

            set var [string map

              $var

            That hangs

            Code:

            tcl>set var ” qwe < asd
            qwe < asd
            tcl>set var [string map [list ” < " : less than "] $var

            This also hangs:

            Code:

            tcl>set var ” qwe < asd
            qwe < asd
            tcl>set var [string map [list ” < " " less than "] $var

          • #72403
            Jim Kosloskey
            Participant

              Bob,

              My typo with the : and missing the ending square bracket should be:

              set var [string map

                $var]

              email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

            • #72404
              Bob Moriarty
              Participant

                Thanks Jim.

                Short and sweet!   😀

                I should have caught the missing bracket. I over-focused on the :  ðŸ˜¯

            Viewing 3 reply threads
            • The forum ‘Cloverleaf’ is closed to new topics and replies.