On Sat, Aug 25, 2012 at 2:10 PM, Art Heimsoth <artst...@artheimsoth.com> wrote:

> I have the program working, but I really do not understand why.  I
> had the following code at the start of the "Ok" method:
>
>     resOK = self~OK:super
>     resOK = 0
>     self~Finished = resOK\

There are problems with that code.  First off, never touch finished.
That attribute is for internal use only and should never have been
exposed to the users of the ooDialog framework.  I know that some of
the example programs that came from IBM used it, which was a
completely wrong thing to do.

Second, you should always call either the super class Ok() or super
class Cancel() methods to end your dialogs.  That is the one way to
ensure that all the details of cleaning up the execution of the dialog
is done properly.

And lastly, for what you want, you don't want the self~ok:super to be
at the start of the method, you probably want it as the very last
thing in your method.

> I do want to do processing from that method, and do not necessarily
> want to end the program.

Here is what you want to do, in semi-pseudo code:

::method ok unguarded

  -- First do your processing
  do something
  do some other things

  if <ok to close dialog> then do
      -- Every thing is good, I want the
      -- the dialog to close now.
      return self~ok:super
  end
  else do
      -- Some problem here, maybe the
      -- user didn't fill in a required field,
      -- I do *not* want the dialog to close
      return 0
  end

> I do not understand the purpose of the
> super operation - I have read the User Guide, but still do not really
> understand what it causes to happen.

The purpose of it, in your case, is to close the dialog cleanly with
ok.  Dialogs can only close with 2 states, ok or cancel.  Typically ok
means 'whatever I was doing in the dialog, any changes I made, etc.
are good.'  While cancel typically means 'whatever I was doing in the
dialog, any changes, etc., I don't want applied.'

Technically what the clause "self~ok:super" means is: invoke the ok()
method in the super class of the 'self' object.

An explanation of this is: the ooDialog framework implements a base
dialog class that does all the hard work of producing a Windows
dialog.  When you use the ooDialog framework you are taking advantage
of all that hard work being done for you.  You create / program a
subclass of the base dialog and just tweak a few things to create a
custom dialog.  But, all the hard work is still done by the base
dialog.

The base class has an ok() method where all the details (hard work) of
correctly ending the execution of the underlying Windows and taking
care of all the necessary clean up is done.  If you do nothing in your
subclass, and the push button with a resource ID of 1 (which is what
IDOK equals) is pushed, the base class ok() method executes, ends the
dialog, and does all the clean up.

On the other hand, if you want to tweak the way the dialog is closed
with the ok button, you add your own ok() method to your subclass.
The ok() method in your subclass is said to "over-ride" the ok()
method in the superclass.  When the user presses the ok button in the
dialog, the ok() method in your subclass is invoked, rather than the
ok() method in the superclass.

The whole subject of method over-riding is vast.  But, we just want to
simplify this one thing to better understand it.  So, in this case we
just say:

You want to over-ride the ok() method so that you can do your own
processing.  However, you still don't know what all needs to be done
to properly end the Windows dialog execution and you have no idea what
needs to be done to properly clean up.  Therefore you still depend on
the superclass ok() method to end the dialog properly.

1.) You over-ride the superclass ok() method to do your own processing.

2.) You decide if you want the dialog to end, or not.

3a.) If you don't want the dialog to end, you just return from your
ok() over-ride.

3b.) If you do want the dialog to end, you invoke the superclass ok()
method to take care of the details for you.

--
Mark Miesfeld

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Oorexx-users mailing list
Oorexx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-users

Reply via email to