Link to home
Create AccountLog in
Avatar of ViennaWaitts
ViennaWaitts

asked on

Visual Fox Pro commands

Hello - I am not a programmer but know some rudimentary commands to be able to fix Fox Pro files.  My problem is I want to change a field's contents to be a fixed percentage of another field in the file.  Field A = 5.00  so I want Field B to reflect 0.02 of Field A so 0.1..  I cannot use a replace command as I do not know how to phrase it so it correctly calculates.  This is a file in an accounting program.
Would greatly appreciate assistance so I do not have to manually change 5,000 lines!
Thank you.
ASKER CERTIFIED SOLUTION
Avatar of Pavel Celba
Pavel Celba
Flag of Czechia image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of ViennaWaitts
ViennaWaitts

ASKER

Simple for you, yes, for me, not so much.  I just attempted it but nothing changed.
I opened the file and then Cntrl-W to close window.  In the command box I typed what you had (with the proper field names) and got nothing.  Am I missing some punctuation?
Tried again - found MY error.  Got it.  Thank you very much.  I already LOVE Experts Exchange!
You are welcome!

BTW, what was the problem?
I am embarrassed to tell you I typed the wrong field name.  
I have already applied it and it saved me HOURS.  Thank you again!
It can happen to everybody... But it should report an error message (or update the wrong column which is the worst scenario).

Bye
P.C.
Why would you save a calculated field in a table?

You can always do that in a report form or a grid by using a calculated column.

FieldB = FieldA * 0.02

OR

SELECT field1, field2, field3, fieldA, fieldA*0.02 AS fieldB INTO CURSOR temp
COPY TO report TYPE XLS

OR

REPORT FORM MyReport

When you calculate on the fly, it's always accurate.
If you are using a BROWSE window you can also do this:

SELECT tablename
BROWSE FIELDS fieldA, fieldB = fieldA*0.02

This way you don't have to calculate the field inside the table and worry if they were properly updated or not.
The answer is in the question already: "This is a file in an accounting program"
I agree, pcelba.

Questions Only Vienna Waitts can answer are therefor:
1. Why does the accounting software not put the correct value into FieldB in the first place?
2 Is it correct to replace all values of FieldB with 0.02*FieldA? You might only want to change a portion of the data, not all records.

Bye, Olaf.



Thank you all for the assists.  Pcelba took care of it for me.  I was just uncertain about the commands as some require characters like quotes or what not.
To answer Captain Cyril - I am updating/correcting data in a file so it does not have to be done through the user interface which would take hours and hours and hours.  FYI
Thanks, Olaf, for your input as well.
In some cases it is faster to run a command on the data than do it via the interface. :-)
I've requested that this question be deleted for the following reason:

                           
No comment has been added to this question in more than 21 days, so it is now classified as abandoned and is now flagged for deletion.


If there is a valid solution, please OBJECT and indicate the comments that are, or would otherwise lead to, a solution.


Use the specific format https:#axxxxxxxx for comment ID(s).


Also, please don't object simply because the author did not respond to your comment. While we understand this is frustrating, unfortunately we cannot force the author to return to the question. Unless you feel you have presented a valid, verifiable solution we'll simply delete the question.


Experts-Exchange Auto Deleter
It is clearly stated by the author: "Got it. Thank you very much.  I already LOVE Experts Exchange!"

The correct answer was this one: https:#a34884791

Others can decide whether to value the additional discussion.