one dialog per stack or several

Ben Rubinstein benr_mc at cogapp.com
Wed Jul 3 04:30:01 EDT 2002


on 2/7/02 7:00 pm, Jeanne A. E. DeVoto at jeanne at runrev.com wrote:

> You can do this either way, of course - either separate substacks, or put
> all the controls in a single stack and do a bit of fancy footwork in
> preOpenStack to hide/show/move/resize controls appropriately. But I would
> think in almost all cases the separate-stacks approach would be simpler.

The recent case I've come to is where I've got a set of related dialogs that
I want to 'think about' similarly.  I made them separate cards of one stack.
There wasn't very much fancy footwork required; I made the first line of the
dialog data be the card name of the dialog actually required, and the
preOpenStack just does this:

    on preOpenStack
      get line 1 of the dialogData
      if there is a cd it then
        go to cd it
      else
        go to cd "Raw"
        answer "SNH: No card Œ" & it & "¹"
      end if
    end preOpenStack


Then each card has it's own 'preOpenCard' handler to do whatever setup is
required for that dialog, based on the dialog data; each of them also call a
handler 'doResizeDialog', also defined in the stack:

    on doResizeDialog
      set the width of this window to \
        16 + (item 3 of the formattedRect of this card)
      set the height of this window to \
        16 + (item 4 of the formattedRect of this card)
    end doResizeDialog


So that was the only overhead of combining them into one stack.  The payoff
is that I can share as much or as little code or controls between the
dialogs as required (and I have eight less substacks to look at in my App
Overview).

But hourse for courses, of course; and in the same project I have three
other dialogs each in their own substacks.
 
  Ben Rubinstein               |  Email: benr_mc at cogapp.com
  Cognitive Applications Ltd   |  Phone: +44 (0)1273-821600
  http://www.cogapp.com        |  Fax  : +44 (0)1273-728866





More information about the use-livecode mailing list