Manipulating a price with differing decimal formats

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Manipulating a price with differing decimal formats

  • Creator
    Topic
  • #49918
    Dan Loch
    Participant

      Hopefully someone has done this before and has an easy fix.

      Our Lawson item master price format has mysteriously changed last night – we were receiving a standard format price, 00000999.99 – always with 2 decimals.  Some of our items are not coming in with a 5 decimal format, 00999.99000, and I have been given the task of correcting today.

      I need to output a 2 decimal price (string) in a field that is 11 characters long.

      Would any of the TCL experts possible have code to manipulate this?

      It would be MOST appreciated.

      Thanks.

      Dan

    Viewing 4 reply threads
    • Author
      Replies
      • #64091
        Michael Hertel
        Participant

          set price 00999.99000

          lassign [split 00000000000$price .] price dec

          set price [join

            [crange $dec 0 1]] .]

          1. #64092
            Dan Loch
            Participant

              Michael – thanks – worked great!!!

              I owe you – next time you are in southern Michigan look me up.

              Dan

            • #64093
              Michael Hertel
              Participant

                You’re welcome  ðŸ˜‰

              • #64094
                Tom Rioux
                Participant

                  Still another way to skin that cat!

                  hcitcl>set price 00999.99000

                  hcitcl>set newprice [format “%08.2f” $price]

                  hcitcl>echo $newprice

                  00999.99

                  If you are using this in an xlate then you only need the one line of code:

                  set xlateOutVals [format “%08.2f” $xlateInVals]

                  Glad you got it working!

                  Tom Rioux

                • #64095
                  Tom Rioux
                  Participant

                    Small correction…for 11 characters long, change the format command from “%08.2f” to “%011.2f”

                    Hope this helps!

                    Tom Rioux

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