Reputation: 1
I have some basic record keeping software; we are trying to capture email addresses, supporting software cannot capture an '@' sign.
Trying to use Visual FoxPro command CHRTRAN to search the field 'UdidText' for a comma ',' and replace it with an '@' sign.
The current code snippet reads:
update [udids] set udidtext = CHRTRAN (udidtext, '%,%', '@') where udidno = '78' and udidtext != ''
As a brief note; the percent sign is my preferred wildcard.
Edit: When checking the code in my application, the function produces an error "Operator/operand type mismatch".
Upvotes: 0
Views: 1172
Reputation: 23827
As per the chrtran() part, it would simply be:
chrtran(uidtext, ',', '@')
Your code is likely giving you error because udidno is not character? Probably you need:
.. udidno = 78 ...
there.
However your code wouldn't do any replacement at all, unless ANSI is ON. You have this:
... and udidtext != ''
If ANSI is NOT ON then that part would resolve to FALSE and no update would occur. To correct it you need, either SET ANSI ON or better use == which is ANSI free:
update [udids] set udidtext = CHRTRAN(udidtext, ',', '@') where udidno = '78' and !(udidtext == '')
In the same manner = '78' would mean any records where udidno Starts With '78'. If you need an exact match there, then that would become:
update [udids] set udidtext = CHRTRAN(udidtext, ',', '@') where udidno == '78' and !(udidtext == '')
Last part is actually unnecessary, so it becomes:
update [udids] set udidtext = CHRTRAN(udidtext, ',', '@') where udidno == '78'
And finally, your udidno might be a numeric:
update [udids] set udidtext = CHRTRAN(udidtext, ',', '@') where udidno = 78
Upvotes: 0
Reputation: 3937
CHRTRAN() doesn't need or want the wildcards. The second parameter is the character or characters to replace. So try:
CHRTRAN(uiditext, ',', '@')
Tamar
Upvotes: 2