Remove Trailing Squares from String

Primary tabs

Hi,

     Can anyone please explain me how to remove trailing squares from the text field (String). Trailing squares is a white space ?

I tried different things like Ltrim, Trim from sql query side and also from object scripting side something below.

 If Address1 set Address1 = $ZSTRIP(Address1,"<>P,<>C,<>W")
 If Address1 set Address1 = $ZSTRIP(Address1,"$C(9), $C(32), $C(160)")
 If Address1 set Address1 = $ZSTRIP(Address1,"*W,*C")

Nothing works for me

Can anyone please help me to solve this

 

Thanks

Replies

You need to identify what character(s) the trailing squares actually are. Typically an empty box is not whitespace, but something for which your font doesn't have a glyph. Can you post the output of zzdump for one of the strings?

it's important to ZZDUMP  the "address" to understand what is going on

if it is a $LB-structure you may also see the squares not id is not whitespace
then $ZSTRIP() will not help at all but just cause confusion

Hi Jude, first identify the character by:

for j = 1: 1 s car = $ e (a, j) q: car = ""  w !, car, "=", $ a (car)

to know the square character

While I agree that you need to identify the ascii value of the characters you have at the end, I do want to note that to remove trailing whitespaces, the syntax is $zstrip(x,">W")

Using that removes trailing whitespaces as you can see in the example below.  Additionally, to add the stripping of "control characters" you would just add the C, so $zstrip(x,">WC")

>set x = "  apple   "
 
>write "/" _ $zstrip(x,">W") _ "/"
/  apple/
>

Thanks to everyone.

It starts working after I tried this code.

 Set Address1  = $ZSTRIP(Address1,"*C",,)