Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Real basic question about REPLACE command

Status
Not open for further replies.

MikeL91

Programmer
Feb 8, 2001
100
US
I have seen in some programs at my new job code with REPLACE ALL on a FOR condition. I thought it was either ALL or conditional but not both ways, they seem to work both ways. We did have an issue where the program was not doing the conditional replace, say every 1000 times it was executed, but I'm not sure if that was related.

ex:

I would use the folowing:

REPLACE Input.zip WITH alltrim(zip)+"-"+alltrim(plus4) FOR !empty(plus4)

the code I see here is:

REPLACE ALL Input.zip WITH alltrim(zip)+"-"+alltrim(plus4) FOR !empty(plus4)

please advise.

Thanks in advance
-Mike
 
FOR has a default scope of all regardless of the actual presence of ALL.
 
The few times I experienced a REPLACE command failing, without an error, was because the table or maybe even a relationship was at EOF().

I am a bit paranoid about the replace and make sure it is the current work area and not eof(). It seems to produce 100 percent results in this situation..



Jim Osieczonek
Delta Business Group, LLC
 
FYI: Other "scopes" that can be applied to the REPLACE command are: NEXT nRecords, RECORD nRecNo, REST

These are ways of determining what records it will affect.

Interestingly, if the Record specified using "RECORD nRecNo" is filtered out by the filter,
(ie:
REPLACE .... RECORD 8 FOR RecNo()<>8
)
then the replace does not happen.

which is different than:
SET FILTER TO RecNo()<>8
GOTO 8
REPLACE ...
which GOTO call DOES IGNORE the filter!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top