Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

ALLTRMCHR() Not Quite Right

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ALLTRMCHR() Not Quite Right

    If the original string is left-justified and blank filled into a larger string field, then the ALLTRMCHR() does not work as one would expect. For example, assume a 6-digit value of 0 is placed into a 10-character field. Then, the original string value would be "000000____" (where _ is a blank). If you invoke the TRMLFTCHR command with TRMCHR('0') and ALLTRMCHR('?'), the return string is "__________", not the expected "?_________". To "fix" this, the CPP would need to be changed to unconditionally scan for an all blank return value and if found, use the appropriate ALLTRMCHR().

    While your are tweaking, how about one command that can trim left, trim right, or trim both. Also it would be nice to allow multiple trim characters
    Code:
    TRIM VAR(&STR) TRMCHR(' ' '0' '$' ',')
    And what about those negative numbers ...

    Oh well, nice article. Provides a good starting point.
    Last edited by BCSleeth; 06-04-2010, 12:45 PM.

  • #2
    I suspect you missed this paragraph from the article:

    " The next version of the TRMLFTCHR command will demonstrate how a user command can support the TRMCHR command parameter as a list of values."

    That article should be out later this week

    And I'm not sure I agree with your conclusion that the results are "not quite right". What you have is a Char(10) variable with six zeroes and four blanks. TRMLFTCHR is trimming the six zeroes, left adjusting the four non-zero blank characters and then blank padding with six additional blanks. In any case, the next version of TRMLFTCHR should do what you would like -- trim leading zeroes and blanks, leaving you with '? '.

    Comment

    Working...
    X