Regsub

  • Creator
    Topic
  • #48564
    Femina Jaffer
    Participant

    I need to eliminate any spaces in the name field of PID 5.  For example, Jacobs- Barney^Dave (the space after the “-“).  I have written the code and seems to work correctly or atleast do the job, but I am encountering an error in the testing tool.

    The error is: [0:TEST] Insufficient room for integer part of numeric value ‘AAAF7966X4698060605’

    The proc I have written in the xlate is:

            set xlateOutVals “”

            set name xlateInVals

            set name [lindex $xlateInVals 0]

            regsub ” ” $name  “” name

            set xlateOutVals

      Any help would be most appreciated.

      FJ

Viewing 7 reply threads
  • Author
    Replies
    • #58998

      Try this:

      Code:

      regsub -all {s?} $name {} name

      -- Max Drown (Infor)

    • #58999
      Femina Jaffer
      Participant

      Thanks Mark.

      I did try this, and again it does do the trick but the error message still appears.

      Any ideas?

    • #59000

      try this …

      http://www.planetdrown.com/images/bjc_regsub_example.jpg" />

      … of course make the appropriate changes for your own needs.

      -- Max Drown (Infor)

    • #59001
      Femina Jaffer
      Participant

      Thanks Max.  I really appreciate your help.  But, unfortunately I still get this error below:

      MESSAGE 1

      [0:TEST] Insufficient room for integer part of numeric value ‘AAAF7966X4698060605’

      ..followed by the Message

    • #59002
      Femina Jaffer
      Participant

      Max,

      I think the error that is being encountered has nothing to do with the PID 5 field.  I think the code is working and this erroneous message is generated by another field that may not be large enough.

      Thanks for all your help!

    • #59003
      Charlie Bursell
      Participant

      I would agree that the error may be coming from another part or the translation.  This normally happens when you use integer compares when you meant to do a string compare.  For example:

                   if {$str == “somevalue”} instead of

                   if {[string equal $str “somevalue”]}

      Use what I refer to as the binary search method.

      Copy your translate to a temporary file like XXX.xlt

      Cut the file in half.  Be careful to split on a statement border.  

      If the problem is still there then split it again.  If not load the 2nd half and make sure the error is there.

      Keep spliting the file.  In a very short time you can get it down to one or two statements.  After that it gets easier to figure out.

      FWIW, the statement “regsub — { } $xlateInVals {} xlateInVals” is fine if your intention is to convert xlateInVals from a list to a scalar variable.  

      Remember, all of the translate variables are *LISTS*.  And, list elements are delimited with whitespace.

    • #59004
      Femina Jaffer
      Participant

      Thanks Charlie!  I will definitely keep this in mind.  Again, thanks for the tip.

    • #59005
      Jo Ellen Laansma
      Participant

      forget the above question.

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

Forum Statistics

Registered Users
5,129
Forums
28
Topics
9,301
Replies
34,447
Topic Tags
288
Empty Topic Tags
10