Dear All,

Would anyone help me to solve below problem, and point out my mistake :-

Character field(18) Numeric Field(4)
ctn_no inner_box
11615404545601 1
11615404545601 2
. .
. .
. .
11615404545601 12

I use command "replace all ctn_no with ctn_no+PADL(inner_box,4,'0')" the
result is no any change of ctn_no, it still is "11615404545601" not my
expact result"116154045456010001"

Thanks in advance
VFP Beginner

Ah Wa

Re: string transform problem by christophe

christophe
Mon Oct 10 03:51:28 CDT 2005

Ah Wa,


try the same but fill in the table alias :
Replace All ctn_no With
YourTableAlias.ctn_no+PADL(YourTableAlias.inner_box,4,'0') In YourTableAlias

there are "rumours" to use this :
Replace All YourTableAlias.ctn_no With
YourTableAlias.ctn_no+PADL(YourTableAlias.inner_box,4,'0') In YourTableAlias
I do it mostly like this just to be sure it's the right table field i'm
changing.
but I didn't test to see any differences.
(I thought that it was Cindy Winegarden who mentioned not to use it like
this.)

regards
christophe
--
\|||/
(o o)
----ooO-(_)-Ooo-------------


"Ah Wa" <cpcpwy@ahwa.net> schreef in bericht
news:e73xd4WzFHA.720@TK2MSFTNGP15.phx.gbl...
> Dear All,
>
> Would anyone help me to solve below problem, and point out my mistake :-
>
> Character field(18) Numeric Field(4)
> ctn_no inner_box
> 11615404545601 1
> 11615404545601 2
> . .
> . .
> . .
> 11615404545601 12
>
> I use command "replace all ctn_no with ctn_no+PADL(inner_box,4,'0')" the
> result is no any change of ctn_no, it still is "11615404545601" not my
> expact result"116154045456010001"
>
> Thanks in advance
> VFP Beginner
>
> Ah Wa
>
>



Re: string transform problem by Andrew

Andrew
Mon Oct 10 03:54:03 CDT 2005

"Ah Wa" <cpcpwy@ahwa.net> wrote in message
news:e73xd4WzFHA.720@TK2MSFTNGP15.phx.gbl...
> Dear All,
>
> Would anyone help me to solve below problem, and point out my mistake :-
>
> Character field(18) Numeric Field(4)
> ctn_no inner_box
> 11615404545601 1
> 11615404545601 2
> . .
> . .
> . .
> 11615404545601 12
>
> I use command "replace all ctn_no with ctn_no+PADL(inner_box,4,'0')" the
> result is no any change of ctn_no, it still is "11615404545601" not my
> expact result"116154045456010001"

Try
REPLACE ALL ctn_no WITH ALLTRIM(ctn_no)+PADL(inner_box,4,'0')

You isn't immediately obvious that ctn_no will be padded with spaces
(probably at the end) to the width of the field.
You can see it if you open the debug window and type "table.ctn_no" on the
left, then you will see the whole field contents on the right surrounded in
""

--
HTH
Andrew Howell



Re: string transform problem by Anders

Anders
Mon Oct 10 13:40:17 CDT 2005

RELACE ALL ctn_no WITH ctn_no-PADL(inner_box,4,'0')

Using the - (minus) operator instead of + (plus) operator moves all trailing
spaces to the end of the concatenated string.

-Anders

"Ah Wa" <cpcpwy@ahwa.net> skrev i meddelandet
news:e73xd4WzFHA.720@TK2MSFTNGP15.phx.gbl...
> Dear All,
>
> Would anyone help me to solve below problem, and point out my mistake :-
>
> Character field(18) Numeric Field(4)
> ctn_no inner_box
> 11615404545601 1
> 11615404545601 2
> . .
> . .
> . .
> 11615404545601 12
>
> I use command "replace all ctn_no with ctn_no+PADL(inner_box,4,'0')" the
> result is no any change of ctn_no, it still is "11615404545601" not my
> expact result"116154045456010001"
>
> Thanks in advance
> VFP Beginner
>
> Ah Wa
>
>



Re: string transform problem by Olaf

Olaf
Mon Oct 10 07:21:29 CDT 2005

Hi Andrew,

> REPLACE ALL ctn_no WITH ALLTRIM(ctn_no)+PADL(inner_box,4,'0')
That hits the nail on the head, as we say.
An C(18) field will always contain 18 characters, so adding something
to that leaves the result unchanged, as strings longer than 18 chars
are truncated and so no change remains.

But Anders showed, that there is the - operator for string concatenation,
that works like cOne-cTwo = RTRIM(cOne)+cTwo.

So replacing with ctn_no-PADL(inner_box,4,'0') is the way to go...

Bye, Olaf.



Re: string transform problem by Bernhard

Bernhard
Mon Oct 10 08:00:26 CDT 2005

Hi Olaf

> there is the - operator for string concatenation, that works like cOne-cTwo =
> RTRIM(cOne)+cTwo.
It does more than this. I moves the trailing blanks of the first operand to the
end of the result.
cOne - cTwo -> padr(rtrim(cOne) + cTwo, len(cOne) + len(cTwo))

It is not correctly documented in the actual help file of vfp 9.
This behaviour did not change since Foxpro/DOS.

Regards
Bernhard Sander

Re: string transform problem by Olaf

Olaf
Mon Oct 10 08:12:00 CDT 2005

> cOne - cTwo -> padr(rtrim(cOne) + cTwo, len(cOne) + len(cTwo))
>
> It is not correctly documented in the actual help file of vfp 9.
> This behaviour did not change since Foxpro/DOS.
Thanks for the correction.

In both cases, the result stored to a C(18)
field it's truncated or padded to 18 chars again.

But that's nice to know if you do that kind of operation
with a variable. Then normally you'd need a final RTRIM,
if you want to get rid of the whitespace.

Bye, Olaf.



Re: string transform problem by agogo

agogo
Mon Oct 10 08:59:38 CDT 2005

Thanks for all value suggestion

"Anders" <anders@anders> ¦b¶l¥ó news:e$2pmeYzFHA.3836@TK2MSFTNGP10.phx.gbl
¤¤¼¶¼g...
> RELACE ALL ctn_no WITH ctn_no-PADL(inner_box,4,'0')
>
> Using the - (minus) operator instead of + (plus) operator moves all
trailing
> spaces to the end of the concatenated string.
>
> -Anders
>
> "Ah Wa" <cpcpwy@ahwa.net> skrev i meddelandet
> news:e73xd4WzFHA.720@TK2MSFTNGP15.phx.gbl...
> > Dear All,
> >
> > Would anyone help me to solve below problem, and point out my mistake :-
> >
> > Character field(18) Numeric Field(4)
> > ctn_no inner_box
> > 11615404545601 1
> > 11615404545601 2
> > . .
> > . .
> > . .
> > 11615404545601 12
> >
> > I use command "replace all ctn_no with ctn_no+PADL(inner_box,4,'0')" the
> > result is no any change of ctn_no, it still is "11615404545601" not my
> > expact result"116154045456010001"
> >
> > Thanks in advance
> > VFP Beginner
> >
> > Ah Wa
> >
> >
>
>



Re: string transform problem by Andrew

Andrew
Mon Oct 10 09:37:17 CDT 2005

"Olaf Doschke" <T2xhZi5Eb3NjaGtlQFNldG1pY3MuZGU@strconv.14> wrote in message
news:eJpRcVZzFHA.3720@TK2MSFTNGP14.phx.gbl...
> So replacing with ctn_no-PADL(inner_box,4,'0') is the way to go...

I couldn't determine whether or not there were leading blanks from the
initial post - and there certainly could be so I went for ALLTRIM() <g>

--
Regards
Andrew Howell