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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

REPLACE ALL produces unexpected results?

Status
Not open for further replies.

jschenke

Programmer
Jun 19, 2001
48
BE
Hi all,

As i'm working on a program for the euro-conversion of an accountancy application, i have to convert the customer history from whatever currency it is in, to euros.
In this case, all i need to do is recalc the exchange rate.

To this end, i do a REPLACE command which looks something like this:

REPLACE ALL h_excrate WITH 40.3399 / h_excrate

The result is however that 40.3399 divided by 40.3399 is 1.0085 instead of 1.0000 ???

If i go through the file with a loop and just

REPLACE NEXT 1 h_excrate WITH 40.3399 / h_excrate

the results are correct (though slower)

I have to admit i'm rather baffled. I tried setting the decimals to 5, but that didn't help either.

Does anyone have any suggestions ?

Jan Schenkel.

PS: i'm running FoxPro 2.6a Win with the patches installed.


"As we grow older, we grow both wiser and more foolish at the same time." (De Rochefoucald)
 
Hi folks,

I think i have found the culprit -- however weird a culprit it may seem..
Appearently the original data was imported from a txt file using APPEND FROM <filename> TYPE DELIMITED WITH TAB

The field h_excrate in the dbf file had 5 decimals; however the original txt file had only 4 decimals in the corresponding column; and even though a browse displayed trailing zeroes, even if i imported into a dbf file with 10 decimals, _internally_ something must have been screwed up.

If i import the txt file into a new dbf file with only 4 decimals, and then append those to the original dbf file with 5 decimals, the REPLACE works like a charm.

Just thought you might like to know about this quirk.

Best regards,

Jan Schenkel.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top