Suppose I have a string where I want to change all "abc" to
"def". This is easy:
thing="abcdefghiabcjkl"
thing=strtran(thing,"abc","def")
What if I want to have it be case-insensitive in the search so that
thing="aBcdefghiABcjkl"
would also result in two changes?

The problem is that the flags parm controls case sensitivity, and
I apparently have to specify all parms.
thing=strtran(thing,"abc","def",,,1)
does not work. I have to fill in the blanks as in
thing=strtran(thing,"abc","def",1,n,1)
where n is arbitrarily high. This is a kludge -- think large memos.
Is there a way to avoid this?

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.

Re: VFP 9: strtran() Optional Parms by Roger

Roger
Sun Jun 24 01:13:40 CDT 2007


"Gene Wirchenko" <genew@ocis.net> wrote:

> Suppose I have a string where I want to change all "abc" to
> "def". This is easy:
> thing="abcdefghiabcjkl"
> thing=strtran(thing,"abc","def")
> What if I want to have it be case-insensitive in the search so that
> thing="aBcdefghiABcjkl"
> would also result in two changes?
>
> The problem is that the flags parm controls case sensitivity, and
> I apparently have to specify all parms.
> thing=strtran(thing,"abc","def",,,1)
> does not work. I have to fill in the blanks as in
> thing=strtran(thing,"abc","def",1,n,1)
> where n is arbitrarily high. This is a kludge -- think large memos.
> Is there a way to avoid this?

Try using -1.

-Roger




Re: VFP 9: strtran() Optional Parms by Gene

Gene
Sun Jun 24 01:28:07 CDT 2007

"Roger Ansell" <notmy@realemailaddress.net> wrote:

>"Gene Wirchenko" <genew@ocis.net> wrote:
>
>> Suppose I have a string where I want to change all "abc" to
>> "def". This is easy:
>> thing="abcdefghiabcjkl"
>> thing=strtran(thing,"abc","def")
>> What if I want to have it be case-insensitive in the search so that
>> thing="aBcdefghiABcjkl"
>> would also result in two changes?
>>
>> The problem is that the flags parm controls case sensitivity, and
>> I apparently have to specify all parms.
>> thing=strtran(thing,"abc","def",,,1)
>> does not work. I have to fill in the blanks as in
>> thing=strtran(thing,"abc","def",1,n,1)
>> where n is arbitrarily high. This is a kludge -- think large memos.
>> Is there a way to avoid this?
>
>Try using -1.
[for number of replacements]
Thank you. That works. It is still a kludge, but it is a
better kludge. <sad smile> The docs state that the parm is optional,
but when you need the parm after, you apparently have to put something
there.

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.

Re: VFP 9: strtran() Optional Parms by Roger

Roger
Sun Jun 24 01:46:12 CDT 2007


"Gene Wirchenko" <genew@ocis.net> wrote:

[snip]
>>> The problem is that the flags parm controls case sensitivity,
>>> and
>>> I apparently have to specify all parms.
>>> thing=strtran(thing,"abc","def",,,1)
>>> does not work. I have to fill in the blanks as in
>>> thing=strtran(thing,"abc","def",1,n,1)
>>> where n is arbitrarily high. This is a kludge -- think large memos.
>>> Is there a way to avoid this?
>>
>>Try using -1.
> [for number of replacements]
> Thank you. That works. It is still a kludge, but it is a
> better kludge. <sad smile> The docs state that the parm is optional,
> but when you need the parm after, you apparently have to put something
> there.

Yes - the documentation's wrong and has been so since VFP7.

-Roger