Alpha Video Training
Results 1 to 6 of 6

Thread: <Field>.Value_Put()

  1. #1
    "Certified" Alphaholic
    Real Name
    Gaby Hernandez
    Join Date
    Sep 2008
    Posts
    1,170

    Default <Field>.Value_Put()

    I have on a form 2 fields: Bill_Add and Ship_Add, and a button. As an exercise, I am trying to write a very simple script attached to the button to set the value in Ship_Add = to Bill_add. I tried to learn something from the Xbasic code generated by The Set Field Value Action script, but got lost in the details. I then tried the <Field>.Value_Put() method with no result.
    Could someone please show me a simple Xbasic script to do this?
    Thanks

  2. #2
    "Certified" Alphaholic
    Real Name
    Mike Christensen
    Join Date
    Nov 2005
    Location
    Michigan U.P.
    Posts
    5,937

    Default Re: <Field>.Value_Put()

    Gaby,

    Go into Design Mode.
    On the top menu click on View-->Object Explorer. Find your first field. click on Copy to Clipboard. Choose relative and the one that has .value added to it. On your button's OnPush event, choose action scripting then choose xbasic from the left screen and Inline xbasic from the right screen. ,,Or just choose the xbasic editor instead of action scripting.

    when in editor, right click and paste or use control+V.

    It should look something like topparent:Ship_Add.value

    go back to the Object explorer and do the same for the second field.

    add this to what you already pasted in the editor like so

    topparent:Ship_Add.value = topparent:Bill_Add.value


    For others who want Action Scripting....
    You could also do this via Action Scripting in various ways. One would be by choosing Objects Properties (Set and Get) on the left screen and Set Properties of Objects on the right screen. Then choose you field in the top box, choose the Value from the second box and then choose Specify and expression.... from the drop down--in the expression builder choose what you want the field chosen to equal.
    Mike
    __________________________________________
    It is only when we forget all our learning that we begin to know.
    It's not what you look at that matters, it's what you see.
    Henry David Thoreau
    __________________________________________




  3. #3
    "Certified" Alphaholic
    Real Name
    Gaby Hernandez
    Join Date
    Sep 2008
    Posts
    1,170

    Default Re: <Field>.Value_Put()

    Fantastic; Thanks Mike :)

  4. #4
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,310

    Default Re: <Field>.Value_Put()

    Gaby,

    Xbasic includes commands that talk to tables "beneath" the form, and commands that talk to the table "through" the form. Mike's approach talks to the table "through" the object on the form. This simulates the user entering the desired field value from the keyboard.

    The first example in the help file discussion of <field>.value_put() illustrates how to talk directly to the table beneath the form. After running the example script you'd need to refresh the field object to see the new value.

  5. #5
    "Certified" Alphaholic
    Real Name
    Gaby Hernandez
    Join Date
    Sep 2008
    Posts
    1,170

    Default Re: <Field>.Value_Put()

    Tom: your explanations clarified a lot of things for me. Why are these details not clearly mentioned somewhere in the user guide or did I missed something?

  6. #6
    "Certified" Alphaholic
    Real Name
    Cal Locklin
    Join Date
    Mar 2000
    Location
    S.E. Michigan
    Posts
    5,763

    Default Re: <Field>.Value_Put()

    To make it even more confusing, I'd almost never use the ".value_put()" command because it's almost never necessary. As far as I'm concerned, its only use is when looping through fields in some generic routine - probably for some type of application utility (which I've built a few of). In the vast majority of cases, it's much easier just to get a pointer to the table and use the field names.....

    tc = table.current() [or tc = table.get("<tablename>")]
    tc.change_begin()
    tc.ship_add = tc.Bill_add
    tc.change_end()

    After which you may need to use a parentform.Refresh_layout() to see the change. (or may not - I simply don't recall.)

    HOWEVER, if you are changing a field that is shown in the current form, it's probably best to use the form methods. Otherwise you can run into problems. For example, my above script would cause an error if you tried to run it while the form was already in data entry mode while Mike's code that uses form methods would not. All Mike's code would do is put the form into data entry mode IF it was in View mode before that script ran. If the form was already in Enter or Change mode, it would just change another field.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •