exchange data between frames

hedgehog

New Member
Hi,

I'm writing an application which consists of two frames, on the first frame there is a browse object and a button. The only thing the button does is executing the command: RUN frame2.w. This frame shows some information based on the row selected in the browse object of the first frame. Is there a possibility to give the rownumber as a kind of parameter to the second frame, i tried to do so by using the same method as when you use input parameters in a procedure, but that didn't work.

Is it possible to do that, or should i do it another way?

thanks in advance
 
Well, SmartObjects are the obvious answer here. using SmartObjects, you can set this up quite easily. But as you are not using them so you'll have to do it manually.

When you click the button, you can run frame2.w passing the row information as a run-time parameter. The ROWID of the record is probably the best thing to pass as a parameter. The row number would be far less useful:

RUN frame2.w (INPUT ROWID(<table>)).

But what happens if another row on frame1 is clicked? Do you want another instance of frame2, or do you want the current instance to refresh itself with the new row?

If you want another instance of frame2 then you don't need to do anything other than the RUN statement above.

If you want to refresh the current instance of frame2 then is gets more complicated. I think that the simplest way is to run frame2 persistently. This will give you a handle to the running procedure. In frame2.w, add an internal procedure called say, 'refresh' that accepts a ROWID as an input parameter. When this procedure is executed, you can read the record using the rowid and display the details:

PROCEDURE refresh:
DEFINE INPUT PARAMETER p-rowid AS ROWID NO-UNDO.

FIND <table> WHERE ROWID(<table>) = p-rowid.

DISPLAY <fields> WITH FRAME <frame>.

END PROCEDURE.

In frame1.w your button trigger will then look something like this:

ON CHOOSE of BUTTON-1
DO:
IF NOT VALID-HANDLE(h-frame2)
THEN
RUN frame2.w PERSISTENT SET h-frame2.

IF ROW-AVAILABLE(<table>) THEN
RUN refresh IN h-frame2 (INPUT ROWID(<table>).
END.

The variable 'h-frame2' is a variable of type WIDGET-HANDLE that you must define in the initialization section:

DEFINE VARIABLE h-frame2 AS WIDGET-HANDLE NO-UNDO.

Finally, in frame1.w, you can place a trigger on the browser to update frame2 when a new row is selected:

ON VALUE-CHANGED OF BROWSE-1
DO:
APPLY "CHOOSE" TO BUTTON-1.
END.
 

hedgehog

New Member
it seems to me that ROWID(<table>) is not working, it doesn't return any value (I tested it with: MESSAGE ROWID(leden) in which leden is the name of my table). Then i tried to do it by passing the BROWSE-1:FOCUSED-ROW value, but i didn't succeed in catching the passed value in a variable so i can work with it.

I use the following code-fragments:

ON CHOOSE OF button-1
DO:
IF NOT VALID-HANDLE (h-frame2) THEN
RUN frame2.w PERSISTENT SET h-frame2.

/*the row-available check wasn't recognised so i dropped it*/
RUN toon IN h-frame2 (INPUT browse-2:FOCUSED-ROW).
END.


PROCEDURE toon:
DEFINE INPUT PARAMETER rijid AS INTEGER.
DEFINE VARIABLE teller AS INTEGER INITIAL 1.

FOR EACH leden:
IF teller = rijid THEN
DO:
id:SCREEN-VALUE = leden.id.
naam:SCREEN-VALUE = leden.naam.
END.
teller = teller + 1.
END.

END PROCEDURE.


It looks to me like i never pass through the procedure. Can you tell me what i'm doing wrong? I'm just a progress-newbie so forgive me if i'm asking stupid questions.

Thx a lot
 
you may need to do a BROWSE-2:FETCH-SELECTED-ROW(1). before you can access the ROWID(leden). Try something like this

Code:
IF BROWSE-2:NUM-SELECTED-ROWS > 0
THEN DO:
	BROWSE-2:FETCH-SELECTED-ROW(1).
	RUN toon IN h-frame2 (INPUT ROWID(leden)).
END.
 
/*....*/
 
PROCEDURE toon:
	DEFINE INPUT PARAMETER rijid AS ROWID.
 
	FIND leden where ROWID(leden) = rijid NO-LOCK NO-ERROR.
 
	IF AVAILABLE(leden) THEN
	DO:
		id:SCREEN-VALUE = leden.id.
		naam:SCREEN-VALUE = leden.naam.
	END.
 
END PROCEDURE.
 
Sorry, my mistake. It's just AVAILABLE not ROW-AVAILABLE.

What I've suggested does work. Have a look at the attached files. They use the sports database.
 

Attachments

  • win.zip
    6.1 KB · Views: 29
Top