I'm starting to make more use of library stacks (partly because I'm trying to switch away from revIgniter to a CGI-based solution to allow me to do more work & debugging in the IDE).

And now I'm looking for best-practice and/or suggestions for how to use library stacks. The not-quite-obvious context is that if some other library is later put into use, and it has no librarystack handler, then the librarystack message can get through to my (already in use) library.

My naive approach (from non-LC background) was very simple :

all initialisation would be done in the librarystack handler

that handler would also set a script-local variable to avoid repeated initialisation

so something like

local sIHaveBeenInitialized
on librarystack
  if sIHaveBeenInitialized is empty then
    put the millisecs into sIHaveBeenInitialized
  else
     -- setup initial / default values, etc.
     ....
  end if
end librarystack

This is fine for subsequent usage of the library - however, it's not so convenient while working on the library. The problem then is that any changes made to the initialization won't take effect unless I either manually unset this script-local, or exit / re-enter the IDE.

I thought about adding a reset handler, e.g.

on library_reset
   put empty int sIHaveBeenInitialized
   pass library_reset
end library_reset

which would give me a quick, safe and easy way to reset any (all) libraries from the message box. But then I thought it felt like I was rediscovering a wheel - so I thought I'd ask on here :-)

Is there another easier / better way to handle this ?

Thanks
Alex.


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to