RAD - Case Study Version 2

Mark Wieder mwieder at ahsoftware.net
Mon Mar 27 01:08:15 EST 2006


David-

All right - I got suckered into taking the challenge, too.

You're on the right track here, but I think Jacque's right about
needing to observe the existing message-passing hierarchy and working
with it, rather than trying to find ways around it. The idea of
independent reusable objects is very powerful. If all goes well I may
be presenting an object-oriented approach similar to yours at a BOF
session at RevCon West. I've built the routines into a library -
here's the code for your examples:

button "Choose":
on mouseUp
  answer folder "what folder do ya want?"
  if it is not empty then
    mc2_libDispatcher.SendEvent "NewFolder", it
  end if
end mouseUp
---------------------
field "FolderContents":
on mouseUp
  mc2_libDispatcher.SendEvent "NewFolder", the hilitedText of me
end mouseUp

setProp NewFolder pFolderName
  set the defaultFolder to pFolderName
  put the files into me
end NewFolder
---------------------
field "FileContents":
on mouseUp
  mc2_libDispatcher.SendEvent "NewFile", the hilitedText of me
end mouseUp

setProp NewFolder pFolderName
  set the defaultFolder to pFolderName
  put the files into me
end NewFolder
---------------------
on openStack
  start using stack "libDispatcher"
  mc2_libDispatcher.Register the id of field "FileContents", \
    "NewFile", the id of field "FolderContents"
  mc2_libDispatcher.Register the id of field "FolderContents", \
    "NewFolder", the id of button "Choose"
end openStack

Total lines of code: 13

---------------------
---------------------

Version 2:
duplicate the controls, rename them, change the openStack handler to:

on openStack
  start using stack "libDispatcher"
  mc2_libDispatcher.Register the id of field "FileContents", \
    "NewFile", the id of field "FolderContents"
  mc2_libDispatcher.Register the id of field "FolderContents", \
    "NewFolder", the id of button "Choose"
  mc2_libDispatcher.Register the id of field "FileContents2", \
    "NewFile", the id of field "FolderContents2"
  mc2_libDispatcher.Register the id of field "FolderContents2", \
    "NewFolder", the id of button "Choose2"
end openStack

Total work time to modify: 2 minutes, including testing
Total extra lines of code: 2 (register two new observers)
Total modified lines of code in objects: 0
Total custom properties to adjust: 0

-- 
 -Mark Wieder
  mwieder at ahsoftware.net




More information about the Use-livecode mailing list