How can I return values entered in a dialog?

Posted by rbf on 02-Feb-2009 03:57

I am starting a dialog that dynamically creates a number of fields. When the dialog returns I want to know the values the user entered.

The constructor accepts a temp-table with field definitions as input parameter.

Back in the procedural world I would return the temp-table enriched with the values entered to the caller when the Dialog is closed.

What is the easiest and best way to do I do that in the OO/.NET world?

All Replies

Posted by Matt Baker on 02-Feb-2009 07:17

Normally you would use an array and just store whatever values you need into the array. Each entry of the array would be an object that defines the structure you need. The fields would pretty much look just like the fields in your temp-table.

Or you can just use the temp-table. The affect is the same

Posted by rbf on 02-Feb-2009 07:21

Sounds rather cumbersome to convert the temp-table to an array just to be able to pass it back as an object.

But how would you pass the temp-table?

Posted by Matt Baker on 02-Feb-2009 07:30

The first suggestion was to remove the use of the temp-table completely and instead use an array of objects. This is the "OO" way.

If you don't care to be a purist, then stick with your original way and just pass the temp-table the same way you would with a procedural approach. Pass the temp-table in the constuctor to the dialog class BY-REFERENCE. When the dialog is closed retrieve the values from the temp-table.

Posted by rbf on 02-Feb-2009 07:32

Aha so BY-REFERENCE is the trick here to circumvent INPUT-OUTPUT

I will dive into object arrays shortly

Posted by Matt Baker on 02-Feb-2009 07:40

This is rough example of what I am suggesting

/*

DialogField class

*/

class DialogField:

define private variable size as Size no-undo.

define private variable location as Location no-undo.

define private variable fieldName as character no-undo.

define private variable fvalue as character no-undo.

constructor DialogField(Size s, Location l, Character name):

this-object:size = s.

this-object:location = l.

this-object:fieldName = name.

end constructor.

define public property Size as Size no-undo.

get().

define public property location as Location no-undo.

get().

define public property fieldName as character no-undo.

get().

define public property fieldValue as character no-undo.

get():

return this-object:fvalue.

end get.

set(input fvalue as character):

this-object:fvalue = fvalue.

end set.

end.

/* calling program

*/

DEFINE VARIABLE dialogFields as DialogField extent 3 no-undo.

dialogFields[1] = new DialogField().

dialogFields[2] = ...

dialogFields[3] = ...

define variable myDialog as MyDialog no-undo.

myDialog = new MyDialog(dialogFields)

wait-for System.Windows.Forms.Application:Run(myDialog).

...process the fields

Message was edited by:

Matthew Baker

Posted by rbf on 02-Feb-2009 07:58

OK I get the picture. So this is also where variable extents come in handy. I will experiment with this approach.

Thanks.

-peter

This thread is closed