how to change field values?

I am looking for a way to address fields to change their values. I cannot understand how it can be done in VFP. For instance, if I use two statements which open a database table with a few fields in it, what do I do next

USE
DatabaseVfp1 tcp_ip IN 0 as cTableAlias

SELECT ALL FROM cTableAlias

cTableAlias.fieldName1 - what does this expression give me Is it the field value or just a field name Can I write:

cTableAlias.fieldName1 = "myString" for instance if it is a type string field

From the way VFP handles tables and queries as I can see so far it hardly can be called OO language. In Visual dBASE it is much more convenient and logical. It is just a lament:)

Thanks.




Answer this question

how to change field values?

  • Louisb

    Hi Alex,

    you may want to check out these free tutorial videos here:
    http://www.sweetpotatosoftware.com/SPSBlog/PermaLink,guid,2baba34c-ebd6-46a3-aabe-35a4d7348014.aspx

    Additionally it always is a good idea to read the products help, just press F1: The VFP help has a lot written about concepts and "How to do". 

    Also there are a lot of sample "How-To's" available in the SOLUTION tab of the Taskpane.



  • C.K. Chua

    Thank you, Cindy, it is very helpful. It answers my question.

  • Arex

    Jurgen thanks,

    It is helpful. I just downloaded a source code zip file from your website:

    http://www.sweetpotatosoftware.com/SPSBlog/PermaLink,guid,2baba34c-ebd6-46a3-aabe-35a4d7348014.aspx

    However, the Parts I-III did not download. The browser came up completely blank.

    I did read every possible "how to" in help files. I cannot claim that what I wanted is not there, I simply could not find it. Many of the pages over there are circuitous and not really helpful. They redirect you from one header to another. I do not want to cast a bad spell on the whole product. The more I use it the more I like it. I still have mentality associated with years in Visual dBase and some of their things are done differently and in a way more conveniently. It is a truly OO language. The fields are objects (it is an array), they have parents (rowset), the rowset have parents (query), etc. You address a particular field as you address an element of a one-dimensional array. It is still an object with some properties, some of them user defined. One of the properties is VALUE. Thus at the long end of this chain of reference you find what you need. You can change it with a simple assignment statement.

    Using the Taskpane is something new for me. I just tried it. it is very helpful.

    Thanks.

  • Pogman

    Hi Alex,

    When you have an object you can change one of its property values by using oMyObject.cMyProperty = "Hello World!"

    When working with data from a table its a different matter. If you want to change a value in the table itself you can use Replace MyTable.cMyField With "Hello World!"  If the table is not the active work area then add the In MyTable  clause to your Replace statement. (It sounds redundant but there's a catch you can read about in Help.) You can also use an Update - SQL statement: Update MyTable Set cMyField = "Hello World!"

    You can also use Scatter and Gather to Scatter data from a table row into memory variables and Gather to write data from memory variables to a row in a table. Later versions of FoxPro allow Scatter Name oData to create a data object with properties you can change and then Gather back to a table row. Select MyTable | Scatter Name oData | oData.cField1 = "Hello World!" | Gather Name oData .

    You can learn a lot about how commands work by typing the commands you listed above into the FoxPro Command window. Use a " " to print the value to the Fox desktop, as in cTableAlias.FieldName1 .



  • madwinchester

    Hi Alex,

    >> the browser came up completely blank.

    Not here. If I click on one of the three links, I first get a "LOADING" notice, and shortly after that, the movie starts. Do you have the MacroMedia Flash plugin installed and enabled



  • morningsunshine

    No I don't. I have had a bad luck with MM Flash, sorry.

  • how to change field values?