Solved

Visual Fox Pro commands

Posted on 2011-02-13
15
50 Views
Last Modified: 2016-05-30
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.
0
Comment
Question by:ViennaWaitts
  • 5
  • 4
  • 3
  • +2
15 Comments
 
LVL 42

Accepted Solution

by:
pcelba earned 50 total points
ID: 34884791
You need just two commands:

USE YourTable
REPLACE ALL FieldB WITH FieldA * 0.02

or SQL command:

UPDATE YourTable SET FieldB = FieldA * 0.02
0
 

Author Comment

by:ViennaWaitts
ID: 34884812
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?
0
 

Author Comment

by:ViennaWaitts
ID: 34884840
Tried again - found MY error.  Got it.  Thank you very much.  I already LOVE Experts Exchange!
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 42

Expert Comment

by:pcelba
ID: 34884850
You are welcome!

BTW, what was the problem?
0
 

Author Comment

by:ViennaWaitts
ID: 34884859
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!
0
 
LVL 42

Expert Comment

by:pcelba
ID: 34884875
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.
0
 
LVL 27

Expert Comment

by:CaptainCyril
ID: 34885662
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.
0
 
LVL 27

Expert Comment

by:CaptainCyril
ID: 34885936
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.
0
 
LVL 42

Expert Comment

by:pcelba
ID: 34887042
The answer is in the question already: "This is a file in an accounting program"
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 34889036
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.



0
 

Author Comment

by:ViennaWaitts
ID: 34890524
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.
0
 
LVL 27

Expert Comment

by:CaptainCyril
ID: 34890759
In some cases it is faster to run a command on the data than do it via the interface. :-)
0
 

Expert Comment

by:EE_AutoDeleter
ID: 41623197
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
0
 
LVL 42

Expert Comment

by:pcelba
ID: 41623198
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.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Dynamic rowheight in Foxpro grid 8 343
Enable Clear Text in Win 8.1 7 46
wordpress limitations 4 124
Fox pro conversion 3 72
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question