embedded spaces (ALLTRIM)

embedded spaces (ALLTRIM)

Post by Um9iZXJ » Wed, 12 Jan 2005 20:43:08


Hi,

I thought ALLTRIM() would remove embedded spaces in a character field, but I
must be wrong!

Could someone please tell me how to do this. I have a character field like:

1234 3322 dede 3333

and it needs to be given as:

12343322dede3333

Cheers
Rob
 
 
 

embedded spaces (ALLTRIM)

Post by Stefan Wue » Wed, 12 Jan 2005 21:13:04

Hi, you can use StrTran() to remove embedded spaces.

STRTRAN( cYourValue, SPACE(1) )

hth
-Stefan


"Robert" < XXXX@XXXXX.COM > schrieb im Newsbeitrag

 
 
 

embedded spaces (ALLTRIM)

Post by Um9iZXJ » Wed, 12 Jan 2005 22:17:02

Hi Stefan,

Thanks for that. It's basically just what I'm after. But i've noticed that
it's cutting off some of the numbers when the field is >16 characters long.
Do you have any idears how to solve this particular problem?

Cheers
Rob
 
 
 

embedded spaces (ALLTRIM)

Post by Olaf Dosch » Thu, 13 Jan 2005 00:47:06

> Thanks for that. It's basically just what I'm after. But i've noticed that


this STRing TRANslation just replaces spaces with nothing,
so it itself doesn't cut off numbers.

Maybe you do a select/view with the expression:
SELECT STRTRAN( cField, SPACE(1) ) AS cSpacescutout, ... from

Then be cautious: The lenght of the first result value determines
the length of the field cSpacescutout. Then you need to pad the result
to a certain length, for example the length of the original Field:
SELECT PADR(STRTRAN( cField, SPACE(1) ),Len(cField)) AS cSpacescutout, ... from

Strtran has 3 parameters, you may try
STRTRAN( cYourValue, SPACE(1) , SPACE(0))

Or CHRTRAN, which translates single chars:
CHRTRAN(cYourValue, SPACE(1), SPACE(0))

Bye, Olaf.
 
 
 

embedded spaces (ALLTRIM)

Post by Stefan Wue » Thu, 13 Jan 2005 17:38:43

I agree with Olaf, StrTran() itself can handle long strings just fine.
If the problem is not solved yet, don't hesitate to post more details.


-Stefan

"Robert" < XXXX@XXXXX.COM > schrieb im Newsbeitrag
 
 
 

embedded spaces (ALLTRIM)

Post by Dan Freema » Fri, 14 Jan 2005 01:56:42

I agree. StrTran() is actually pretty startling in the size of string it
will take.

While working on/testing a SPR driver for GenscrnX way back when, I passed
it the text of "War and Peace" and it returned instantly with a proper
result.

Dan