Friday, 23 November 2012

Including/Reusing an H2 script inside another H2 Script

Here is a cool technique that I use to include *.H2 scripts into other scripts, and the environment that I create during its development:

Here is what this script is doing:

  • Line 1: 'Include' the source code of the Util - Windows Handles Viewer (Simple Gui).h2 at the top (think of this as a 'copy and paste' of the external script code
  • Line 3: Get a reference to the parent Form object (note that the topPanel value was set on the included H2 script) and set a timer to close it in 10 sec (this is very useful when doing development on stand-alone Form controls, since during REPL development we just want to take a quick look at what happened with the latest code changes
  • Line 7: insert a panel below (this is the same as adding a SplitContainer with the current control at the top and a new Panel at the bottom
  • Line 8: Because the split container (created in line 7) by default sets the Splitter Distance to be half of the current form (and calling {target}.insert_Below(nn) will set the bottom frame to be the size of nn), we need to set this value here (since we want the top frame to have the size of nn (in this case 30 )
  • Line 10: Add a .Net TextBox with the Docking value set to Fill and with MultiLine enabled (which is why I call it a TextArea)

This is what this script looks like (with the comments/arrows added using Lucid Chart) 

Question: does this diagram make sense? Should I create more like these?

I'm still trying to figure out a good convention and format for these 'this is what is going on' kind of diagrams


IBM_O2User said...

Hey Dinis. I've been following your blogs and work on the O2 Platform for several years now but have been mostly watching from the shadows.

It's been an amazing show to watch (a lot of empty seats so I grabbed the front row) but the progress you've achieved recently has brought me out of my hiding spot and I plan on doing everything I can to help others understand, including the companies that just can't quite seem to see what is directly in front of their faces.

I love the stuff you've been doing with AppScan and plan on attending your training session coming up next week in Belgium.

Next comment will actually be relevant to your post, but I just wanted to first say "Hi" and "Congratulations" on all that you've achieved over the last bunch of years.


Dinis Cruz said...


It's good to have you sharing your views :)