PDA

View Full Version : How do I dirty a buffer in CM OOPs



Glennbo
9-May-2005, 02:00 PM
In Console Mode OOPs, how can I move a value to a field that isn't on
screen, and get the buffer dirty so that my data will get saved with the
data that is on screen.

--
_______ _____ ___ _____ ____
/ ___/ / / __/ |/ / |/ / _ )/ __ \
/ (_ / /__/ _// / / _ / /_/ /
\___/____/___/_/|_/_/|_/____/\____/
---------------------------------------------------------------------
Glennbo These go to eleven
Non-Linear Sound http://www.soundclick.com/glennbo
Hear My Music http://www.soundclick.com/jambits

Bill Clifford
10-May-2005, 09:56 AM
Glennbo,
Procedures Creating and Update are hooks you can use at the time of
saving to populate any non-visible fields with data. In some
situations, you can send refind_records to the data set, manipulate the
buffer and save manually. If you do the latter, you have to refresh
the data entry object to display any new displayed data.

Bill

>
> In Console Mode OOPs, how can I move a value to a field that isn't on
> screen, and get the buffer dirty so that my data will get saved with
> the data that is on screen.

Roger Loftus
10-May-2005, 01:21 PM
Glennbo wrote:

>
> In Console Mode OOPs, how can I move a value to a field that isn't on
> screen, and get the buffer dirty so that my data will get saved with
> the data that is on screen.

Glennbo:

This is a common problem, and may or may not have a simple answer. You
are probably using an entry class object and are likely using a
data_set for file handling. Everything depends on your programming
structure, and the solution depends on the function and procedure calls
executed when you press the 'save' key.

In this case, you need to examine the calls made when you press the
save key without changing item values in your object. From there, you
can agument (modify one of the called procedures) to accomplish your
goal.

There are many possibilities to hook into the save process, but you
probably need to trace the procedure/function calls to properly tap
into the sequence. Without changed_state of the object or
item_changed_state of the object items true, the major part of the save
sequence may be bipassed complicating the solution by guessing
possibilities.

Do you have a tracer you can use that is friendly enough to document
all procedure calls of a command sequence? If not, I would be glad to
forward one to try. With a trace of your command (save) process, you
can solve this problem, or this type of problem quite easily by
agumenting one of the procedures you know is called.

Roger Loftus

Glennbo
10-May-2005, 02:58 PM
The entity known as Bill Clifford, posted:

>> In Console Mode OOPs, how can I move a value to a field that isn't on
>> screen, and get the buffer dirty so that my data will get saved with
>> the data that is on screen.

> Glennbo,
> Procedures Creating and Update are hooks you can use at the time of
> saving to populate any non-visible fields with data. In some
> situations, you can send refind_records to the data set, manipulate the
> buffer and save manually. If you do the latter, you have to refresh
> the data entry object to display any new displayed data.

Thanks for the reply Bill.

I tried putting in both procedure creating and procedure update, but
neither seem to be getting hit at all. The app I'm working on is based on
the OOPs character mode example, OrderEnt, but using files that already
existed in another app.

In "Procedure Total_Amount" I'd like to be able to move a couple things to
fields that don't appear in the table, dirty the buffer, and get them to
save along with items that do appear in the table

--
_______ _____ ___ _____ ____
/ ___/ / / __/ |/ / |/ / _ )/ __ \
/ (_ / /__/ _// / / _ / /_/ /
\___/____/___/_/|_/_/|_/____/\____/
---------------------------------------------------------------------
Glennbo These go to eleven
Non-Linear Sound http://www.soundclick.com/glennbo
Hear My Music http://www.soundclick.com/jambits

Glennbo
10-May-2005, 03:18 PM
The entity known as Roger Loftus, posted:

>> In Console Mode OOPs, how can I move a value to a field that isn't on
>> screen, and get the buffer dirty so that my data will get saved with
>> the data that is on screen.
>
> Glennbo:
>
> This is a common problem, and may or may not have a simple answer. You
> are probably using an entry class object and are likely using a
> data_set for file handling. Everything depends on your programming
> structure, and the solution depends on the function and procedure calls
> executed when you press the 'save' key.

Thanks for the reply Roger. I'm working with a set of data files from an
existing app, and trying to get an OOPs infinite scrolling table entry form
working, using the OrderEnt sample as a model. I have most of it working,
but need to be able to move some values to fields in the data file that is
used with the table, and dirty the buffer so they will be saved along with
the data that appears in the table. I do this all the time with VDF using,

Set field_changed_value of (server(self)) field Trandtl.Account to Account

Isn't there some kind of equivalent to the above in character mode OOPs?

> In this case, you need to examine the calls made when you press the
> save key without changing item values in your object. From there, you
> can agument (modify one of the called procedures) to accomplish your
> goal.

The saves I'm trying to add my data to are happening in the row save of a
table object. I notice that procedure Save_Row is active, and I can
intercept it, but moving data to fields in the data file within that
procedure are ignored when the save happens, because the buffers aren't
dirty for those fields.

> There are many possibilities to hook into the save process, but you
> probably need to trace the procedure/function calls to properly tap
> into the sequence. Without changed_state of the object or
> item_changed_state of the object items true, the major part of the save
> sequence may be bipassed complicating the solution by guessing
> possibilities.

Is there a "field_changed_value" or equal for data elements that have no
entry object? That's what's hanging me up.

> Do you have a tracer you can use that is friendly enough to document
> all procedure calls of a command sequence? If not, I would be glad to
> forward one to try. With a trace of your command (save) process, you
> can solve this problem, or this type of problem quite easily by
> agumenting one of the procedures you know is called.

I don't have a tracer of any kind. I'd love to see what one might reveal
for me, because at this point I'm quite stumped.

--
_______ _____ ___ _____ ____
/ ___/ / / __/ |/ / |/ / _ )/ __ \
/ (_ / /__/ _// / / _ / /_/ /
\___/____/___/_/|_/_/|_/____/\____/
---------------------------------------------------------------------
Glennbo These go to eleven
Non-Linear Sound http://www.soundclick.com/glennbo
Hear My Music http://www.soundclick.com/jambits

Sture Andersen
10-May-2005, 03:53 PM
Hi,

How about declaring an entry_form object with the same server as your table
object. In this entry_form you should put the fields that you want to
update.

Then (instead of set field_changed_value... ) you can

set changed_value of (oEntrFrm(self)) item X to "Whatever"

Of course you don't want to see this entry_form on screen. You therefore:

set focus_mode to NO_ACTIVATE
set visible_state to FALSE

I'd expect that to work. Alternatively, if you're using DF32, you can use
DataDictionary objects just like in VDF.

-Sture

Roger Loftus
10-May-2005, 05:56 PM
Glennbo wrote:

> The saves I'm trying to add my data to are happening in the row save
> of a table object. I notice that procedure Save_Row is active, and I
> can intercept it, but moving data to fields in the data file within
> that procedure are ignored when the save happens, because the buffers
> aren't dirty for those fields.
>
Glennbo:

I use my own oop table and entry form programming with classes that are
conceptally different than the DAC model, so I am a bit rusty on what
you are up against. But when saving a row in the table, you probably
get to code like:

reread
send entry_update file_number 0
save

So, two things are probably killing you. One, the re-read is
overwriting anything you move to the buffer before you encounter it,
and two, entry_update x 0 only updates fields that are changed in
entry_items in your entry class object (row editor or whatever) and
ignors anything else. So, you really need to get between the
entry_update procedure and the save to get what you want.

The real question is whether you even get to this point when there are
no changed items in the entry object - I expect you may not.

If you want, you can try this: First, if you can intercept save_row,
add a dummy 'set item_changed_state item x to true' somewhere in the
procedure and then forward send it. Maybe that will get you to the
entry_update and save. Then write an "entry_update integer fileNo
integer num" procedure in your object. In this, include a forward send
'entry_update fileNo 0', then move your extra data to the buffer, and
end the procedure. Maybe this will work, but it is guesswork.

> I don't have a tracer of any kind. I'd love to see what one might
> reveal for me, because at this point I'm quite stumped.

There is a tracer class in CM that works, kind of. You really need one
to solve these kind of programing challenges effectively. The one I
adapted and use works well in a run mode or a step mode, and creates a
list of all calls resulting from any user input to review. It also
shows property and global values, object trees, focus trees, etc. Mine
might work fine as-is for you, may need some adaptation, or may not
work at all. You are certainly welcome to give it a try if you like.
In any case, if you still do much OOP CM work, I would sure look for
something to open up the OOP process calls for examination. If nothing
else, it is an amazing learning experience.

Roger Loftus

Glennbo
11-May-2005, 10:52 AM
The entity known as Sture Andersen, posted:

WooHoo! Your idea works Sture! Thanks.

I had to omit the line "set focus_mode to NO_ACTIVATE", but after doing
that, things I move to the still hidden image are getting saved. I'm
intercepting "procedure Save_Row" and then setting the values in the
hidden form with the following.

procedure Save_Row
Local Number AskingPrice Cost
Local String Category CostCode

set changed_value of (DummyForm(Current_Object)) item 0 to Cost
set changed_value of (DummyForm(Current_Object)) item 1 to CostCode
set changed_value of (DummyForm(Current_Object)) item 2 to Category
set changed_value of (DummyForm(Current_Object)) item 3 to AskingPrice

Forward Send Save_Row
End_Procedure


> How about declaring an entry_form object with the same server as your
> table object. In this entry_form you should put the fields that you
> want to update.
>
> Then (instead of set field_changed_value... ) you can
>
> set changed_value of (oEntrFrm(self)) item X to "Whatever"
>
> Of course you don't want to see this entry_form on screen. You
> therefore:
>
> set focus_mode to NO_ACTIVATE
> set visible_state to FALSE
>
> I'd expect that to work. Alternatively, if you're using DF32, you can
> use DataDictionary objects just like in VDF.



--
_______ _____ ___ _____ ____
/ ___/ / / __/ |/ / |/ / _ )/ __ \
/ (_ / /__/ _// / / _ / /_/ /
\___/____/___/_/|_/_/|_/____/\____/
---------------------------------------------------------------------
Glennbo These go to eleven
Non-Linear Sound http://www.soundclick.com/glennbo
Hear My Music http://www.soundclick.com/jambits

Glennbo
11-May-2005, 10:54 AM
The entity known as Roger Loftus, posted:

Thanks for the help Roger.

It looks like Sture has a relativly simple solution, using a hidden form,
and stuffing values into it just before the save of a row. I'd still be
interested in seeing what things are revealed using a tracer. Where can
I get the one you use?

>> The saves I'm trying to add my data to are happening in the row save
>> of a table object. I notice that procedure Save_Row is active, and I
>> can intercept it, but moving data to fields in the data file within
>> that procedure are ignored when the save happens, because the buffers
>> aren't dirty for those fields.
>>
> Glennbo:
>
> I use my own oop table and entry form programming with classes that are
> conceptally different than the DAC model, so I am a bit rusty on what
> you are up against. But when saving a row in the table, you probably
> get to code like:
>
> reread
> send entry_update file_number 0
> save
>
> So, two things are probably killing you. One, the re-read is
> overwriting anything you move to the buffer before you encounter it,
> and two, entry_update x 0 only updates fields that are changed in
> entry_items in your entry class object (row editor or whatever) and
> ignors anything else. So, you really need to get between the
> entry_update procedure and the save to get what you want.
>
> The real question is whether you even get to this point when there are
> no changed items in the entry object - I expect you may not.
>
> If you want, you can try this: First, if you can intercept save_row,
> add a dummy 'set item_changed_state item x to true' somewhere in the
> procedure and then forward send it. Maybe that will get you to the
> entry_update and save. Then write an "entry_update integer fileNo
> integer num" procedure in your object. In this, include a forward send
> 'entry_update fileNo 0', then move your extra data to the buffer, and
> end the procedure. Maybe this will work, but it is guesswork.
>
>> I don't have a tracer of any kind. I'd love to see what one might
>> reveal for me, because at this point I'm quite stumped.
>
> There is a tracer class in CM that works, kind of. You really need one
> to solve these kind of programing challenges effectively. The one I
> adapted and use works well in a run mode or a step mode, and creates a
> list of all calls resulting from any user input to review. It also
> shows property and global values, object trees, focus trees, etc. Mine
> might work fine as-is for you, may need some adaptation, or may not
> work at all. You are certainly welcome to give it a try if you like.
> In any case, if you still do much OOP CM work, I would sure look for
> something to open up the OOP process calls for examination. If nothing
> else, it is an amazing learning experience.



--
_______ _____ ___ _____ ____
/ ___/ / / __/ |/ / |/ / _ )/ __ \
/ (_ / /__/ _// / / _ / /_/ /
\___/____/___/_/|_/_/|_/____/\____/
---------------------------------------------------------------------
Glennbo These go to eleven
Non-Linear Sound http://www.soundclick.com/glennbo
Hear My Music http://www.soundclick.com/jambits

Bill Clifford
11-May-2005, 11:46 PM
Glennbo,

If nothing is happening with code in procedure creating or procedure
update, then either the data set is not properly connected to the data
entry object or the save is not occurring because the fields in the
table row have not changed. You can augment procedure request_save to
set the item_changed_state of one of the items in the row to true if
you want the save to occur without any user changes. I have never seen
a situation where these hooks do not execute along with the save as
long as you have the correct updating dataset entry on the line that
defines the table object. To test the updating and/or creating
procedure, you can put a popup message in the procedures and show some
buffer values. If the popup doesn't show with saving even when you
change values on the row, then you certainly have a problem with
syntax, not with Dataflex console mode limitations.

Bill

> The entity known as Bill Clifford, posted:
>
> >> In Console Mode OOPs, how can I move a value to a field that isn't
> on >> screen, and get the buffer dirty so that my data will get saved
> with >> the data that is on screen.
>
> > Glennbo,
> > Procedures Creating and Update are hooks you can use at the
> > time of saving to populate any non-visible fields with data. In
> > some situations, you can send refind_records to the data set,
> > manipulate the buffer and save manually. If you do the latter, you
> > have to refresh the data entry object to display any new displayed
> > data.
>
> Thanks for the reply Bill.
>
> I tried putting in both procedure creating and procedure update, but
> neither seem to be getting hit at all. The app I'm working on is
> based on the OOPs character mode example, OrderEnt, but using files
> that already existed in another app.
>
> In "Procedure Total_Amount" I'd like to be able to move a couple
> things to fields that don't appear in the table, dirty the buffer,
> and get them to save along with items that do appear in the table