Tutorial - Making a Coloring Book App

[Update: 6/10/14 - I just found this article today, that explains much more elegantly the why of PictureScript. Learnable Programming]

This video shows how simple notation can create a non-trivial application using PictureScript.  There are some notes about the script below the video.  Please take our survey after watching the video. Click here to take the Survey and/or register for a free Demo App.

Download the Coloring Book Script (source code here).

Music is from www.danosongs.com

Can't view the video?  Try http://goo.gl/YTMJm .

The editor you see in the movie is an in-house tool for testing PictureScript, eventually many of its features will be released in an editor called PictureScribe. The four windows shown include a sandbox for testing the PictureScript messages, a PictureScript Dictionary, a Message Editor, and a Tutorial Message viewer.

In this tutorial I have already typed in all the messages into the editor.  By checking the "Menu" box the list of messages act like a menu.  I simply click on a line and the message on that line is sent and you see the results in the sandbox window. If the "tutorial" checkbox is checked, the operation is slowed and the message is "Typed" into the tutorial window to let you view the message and digest it before the message is actually sent.  Of course the messages can be run together as a script by clicking on the "Do" button. 

Parts of the video get pretty repetitious, but since this is probably most people's first introduction into PictureScript, I figured that with each repetition, "make the next one blue", "make the next one green"... it would give people a chance to absorb the concept better. So, for much of the exercise, each setting for each item was messaged separately.

This tutorial also introduces the idea that you aren't limited to selecting the individual items in order.  You can use terms like "the fifth one" and "the last one".  In other cases you could also select several items.  "the last three" or "the first two" or "the middle four" for example.

Referring to groups of items can significantly cut down on the number of messages required.

Here are some alternative messages that would have made the script much simpler.

make 8 squares  // same as in the video

move them near the bottom // same as in the video

Make them red, white, blue, green, yellow, orange, purple, and black  // replaces 8 messages

Make their touchScript "make the paint my color"  // replaces 8 individual messages




Much of what we do, our customers would rather we not talk about. We respect that. That is why you don't see much of what we do on this site. But recently we worked on a project for a public utility, and we have permission to share. I hope you find it interesting.

SCATU - the little hero

Setting the Stage

Most people know that sewage flows down hill. Some of the unsung heros of modern life are the people and organizations that make sure it flows in a controlled fashion, out of sight and smell to its final destination at the treatment plant. They couldn't do their job without the help of machines located along the line called lift stations. Lift stations pump sewage up hill. If they don't work, sewage backs up and flows down hill to places it doesn't belong.

Over the years utilities have instituted a number of practices and technologies to insure that lift stations keep pumping.  They typically have redundant pumps, and lights that are very visible to indicate proper operation or lack there of. But sewage happens... Pumps get clogged, power fails, everyone is asleep or fails to notice the flashing red light.  You do KNOW to call your utility's trouble desk if your neighborhood lift station has a flashing red? Right? You didn't know you had a lift station down the street? Neither did we, but we recently discovered there is one less than 100m (300 ft) from our door.

The Conventional Solution

Some utilities, if blessed with a large capital improvement budget are able to install SCADA systems. That stands for Supervisory Control And Data Acquisition Systems. They are very nice and worth every penny. They allow the utility to monitor the lift stations's health continuously. They can detect problems with the lift station long before the sewage becomes a problem for someone's home or the environment. Unfortunately they don't come cheap. They need licensed radios, sensors and ruggedized embedded computers. They also require an infrastructure of central monitoring and dispatch system. Outfitting of SCADA at a lift station can cost over $10,000, but they could save more than that in operating costs and cost avoidance in just a few years.

Capital budgets do not equal operating budgets, so while spending $10,000 now to avoid spending $15,000 in clean up costs later makes sense, many utilities can't come up with enough of the right "color" money unless they issue bonds.   

Enter the SCATU

Our local utility asked if we couldn't come up with a very simple SCADA like system that just did a few critical things:

  1. Detect power failures.
  2. Detect alarms
  3. Send text messages to key personnel when there was a problem.
  4. Be inexpensive enough to purchase with their maintenance budget.


The result was the Simple Cellular Alarm Telemetry Unit. The SCATU, a little machine to monitor lift stations or other critical infrastructure that calls for help when it detects a problem.

If you want to see what a SCATU looks like installed click here.

How it Works:

The SCATU monitors three things; power, a high level float or alarm, and a service button. If the condition of any of these things change a Text Message (SMS) is sent to a list of mobile phones. (typically 2, up to 8).

The message states what happened and where it happened.  A typical sequence of messages would go like this:

9:32PM Alarm at Boley Drive Lift Station.

9:50PM Service Button Pressed at Boley Drive Lift Station.

9:52PM Power Fail at Boley Drive Lift Station.

10:11PM Power Restored at Boley Drive Lift Station.

10:21PM Alarm Cleared at Boley Drive Lift Station.

What Happened:

A pump got clogged and could not keep up with the inflowing streams.  The High Level Alarm float activated.  The SCATU waited for a minute to be sure this wasn't just a blip, and then started sending text messages to the mobile phones in its list.

"Joe" who was on call, received the message on his phone while watching Monday Night Football.  He drove out to the lift station, pressed the service button on the SCATU, to let his backup and supervisor (the other two mobiles in the SCATU's call list know that he had responded to the alarm.

He killed the power to the pump in order to safely clear the clog.  After the clog was cleared he restored the power and in a few minutes, the chamber was pumped back down below the alarm float level and the alarm was cleared.

Had Joe not responded in a reasonable amount of time his backup would have tried to reach Joe and if necessary respond himself.  After some longer time if the service button had not been pressed Joe's supervisor would have put some contingency plans in action.

 Other ways this could have played out:

In actual practice, the alarm might clear itself in 15 to 20 minutes.  If this happened during heavy rain, repeatedly, this is a good indication that the inlets are receiving storm drainage.  Further investigation might discover the problem up stream and when fixed, lower the volume of water pumped and treated resulting in an ongoing cost savings.

Joe and the operators might be aware that there is a 14 hour cushion of capacity for that particular lift station after the alarm float is lifted.  Since he will be making his rounds starting a 7:00AM, he will go to Boley Drive first and clear the problem.  He texts his supervisor and backup so they know not to expect the service button pressed notification until the next morning.  Should he forget, the text messages tell the story, and you can be sure his supervisor will discuss it with him later.

How hard was it to set up the SCATU?

The utility simply ordered a SCATU, and provided the name of the Lift station where it would be used, and three mobile phone numbers.  In about 2 weeks the SCATU arrived (was not a rush order). On opening the box. They found an outdoor rated fiberglass and stainless steel enclosure with water proof lights and switches, and a single rugged cable.  Instructions included say mount the enclosure, and connect 4 wires. One wire to power, one to neutral, one to the alarm float or alarm signal, and one to ground.  Remove the arming plug, and the protective tape on the solar cell. Press the Alarm Test button, and verify a text is received within a few moments.  An electrician or qualified maintenance personnel can set one up in 15 to twenty minutes.




Flash in the Pan

A while back, I wrote about a major shift in the world of web browsers, where web standards were beginning to become the norm, and IE was becoming less and less important while Google and Apple, by pushing standards, were driving the industry, not Microsoft. I suggested that the coming of age of SVG (a critical component of HTML5) as evidence. I suggested that Microsoft should be a little worried and embrace the standards or become irrelevant.

So What has happened since then?  Google has introduced its own browser "Chrome" based on Apple's Safari. HTML5 is all the rage and Microsoft is promising support in IE9.  Google has provided a Chrome plugin for IE that fills some HTML5 gaps in the current IE versions.  (Google continues to "help" Microsoft). Google Apps on the other hand, an online alternative to the MS office suite is getting better and picking up fans.  

Microsoft is responding to Google Apps with Office Online. Meanwhile Silverlight, Microsoft's alternative to Flash is picking up some steam.  Windows 7 is a big success, and Microsoft is seeing signs that finally, corporate customers are willing to let go of Windows XP.  But...

A number of  WinXP customers are switching to Apple's Macintosh. Windows Mobile market share is dropping like a rock. Apple is now the self described largest mobile device maker in the world.   Windows tablets with a 7 year head start have failed to catch anyone's imagination.  Yet Apple is selling "an iPad every 3 seconds". Apple has sold over 1 billion applications for its iOS platform that includes the iPhone, iPad, and iPod Touch, and over 100 million devices.  Apple's iTune store sells more music than anybody, even Walmart. Apple's market cap recently left Microsoft's behind, to become the second largest US based company.  

The point isn't that MicroSoft is fading away.  The point is that Apple is now the elephant in the room.  When Apple speaks, or acts you might want to pay attention.  

Apple says Flash, Adobe's technology is buggy, a resource hog and  a fading technology. That's not just talk, Apple has banned Flash on its popular iOS devices like iphones and iPads. So if you were planning on basing your product around Flash, you might want to reconsider.


8-20-09 The Day the World Stood Still

If Microsoft has a competitor it is worried about, it has to be Google. In general, they must be worried about Open Source and Free software (not made by them), since that cuts at the core of their business. Internet Explorer, the most widely used free software made by Microsoft, is rapidly loosing market share.

This is for a number of reasons that you can read about elsewhere. But one of the reasons, for not using IE just went away. Google just announced a product that allows IE plus 95% of all other browsers to render SVG (Scalable Vector Graphics).This means that the same interactive graphics can be displayed in on a PC and on an iPhone. (without the PC  user installing Safari.)

Developers can now use SVG and deploy almost anywhere. (Whether Microsoft likes it or not.) Safari, Opera, and to some degree FireFox already support SVG natively, but Microsoft apparently has had no plans to support this open technology, opting instead for pushing for its own SilverLight.  This had caused a kind of chicken and egg scenario where developers couldn't reach the 70% of PC users who won't bother to switch browsers.


Ironically, more SVG on the web makes the iPhone experience more enjoyable, while Android, Google's cell phone operating system, billed as an alternative to the iPhone's OSX, does not support this solution.

Ironically, Google makes this possible by tapping into the power of Flash, Adobe's proprietary vector rendering software, and is considering using SilverLight as well.

OK, so maybe the world didn't stand still, maybe its web counter part just shifted its axis just a bit.

The video below, courtesy of Google explains the technology.




George Gets a Ramp

ACME a high tech and high profile outfit was building a new control room, complete with a raised floor with removable panels.  George was in charge of setting the requirements for the control room.  He was in the operations group.  The control room was in essence being built for him. The floor was only raised 36".  He had asked for 60" but according to the construction group, the architect had supposedly said that this would have raised the entire building profile, which in turn would require additional structure for wind loads. This was a lie, but a cost effective lie to avoid spending an extra $.50 per square foot for the higher floor. (You must realize that for many organizations, construction dollars are valued 10 to 1 over operational dollars.)

George knew that someone (maybe himself) would wind up crawling those floors adding cables for years to come. Make it easy to make under floor changes, the job might get done right.  Make it hard, good luck. Besides cable trays, there would be power conduits, cooling and sprinkler water pipes sharing the space.  Often equipment racks would be added or moved requiring new wiring trays to be installed.  He could probably argue thousands of dollars in extra operations costs, but no one would buy hundreds of thousands of dollars in expense to offset the increase in construction costs.

Years later his fears were realized, as a major cabling addition was required without affecting ongoing operations.  Only one or two panels could safely be removed at a time, so a lot of crawling and questionable routing of cables was involved.  This essentially made the job take 10 times longer.

When the building was nearly complete, someone pointed out the three to four feet of wasted space above the dropped ceiling, clearly able to accommodate the higher raised floor.  When George called construction on the lie, construction was obviously pleased, that he had been found out.  It was one of those, "I got-ya" moments.  He had that satisfied "and there's nothing you can do about it" smiles.

This was just before George discovered he would not be getting his ramp.  The plans called for a ramp from the office and shop level up to the control room so that racks, equipment carts, tool boxes, work stations etc... could easily be moved from one area of the facility to another.  Someone figured out that several thousand dollars could be saved by eliminating the ramp and installing standard steel steps instead.  The ramp was removed by change order that conveniently didn't need concurrence from operations. One day the steps showed up where the ramp should have been.

George of course complained that this wasn't according to his requirements or the plans Operations had signed off on.  Construction explained that the change was made and approved via change order, and operations could live with it.  "Fork lifts can be used to move tool carts and other equipment. People can use the stairs."

At this point in history the Americans with Disabilities Act was relatively new, but not so new that acceptable reasons for exceptions hadn't become a staple of the construction group.  If it wasn't an area frequented by the public, for the most part the ADA didn't apply. Employees who couldn't safely navigate the stairs, could be assigned work in other areas. The control room would be a restricted "able bodied area".

ACME had a practice of having review meetings, where upper management, would review the progress of the big projects in an orchestrated and often much practiced presentation.  Construction, Operations, Safety and Quality, all contributed to the meeting.  The goal was to get through the meeting with out blood on the floor.  All differences were left at the door. Bash each others heads outside the room, but only perfect harmony was allowed in the meeting. Notes were taken and published for those who were not able to attend.  While the meeting was mostly for show,  it was "for the record".  

Each presenter followed basically the same format, ending with potential problems or risks.  The trick was always to present the risk or challenge in a positive light with a ready plan for reducing it.  Never ever did you want to leave a problem open for upper management to try to solve. It was in this environment that George and Construction gave their presentations.

George ended his presentation with this: " I want to confess we may have a big problem, one that I should have recognized earlier.  A change was made to the basic access  to the control room, and while at the time the change seemed reasonable because it saved approximately x number of dollars, construction can get you the exact figure, we did not consider all the consequences.  This was operations responsibility, and we don't hold the construction or safety group responsible for the oversight. The question now is what to do about it.  To fix the problem is bound to cost a lot of money, more than if it had stayed in the original design, but even if we had the funds, operations money is the wrong color to use. I'm afraid that the fix would have to come from the  construction budget, money they just don't have. Construction could get you the amount that is needed,  I'm certain."

"While it is true that for current employees wheel chair access is not required and the ADA allows exceptions, we didn't consider the effect that the lack of a ramp could have on operations and moral.  Just last year one of our key contractor personnel had a skiing accident.  She would not have been able to safely do her job. Every day each one of us is running the risk of a car accident. And of course, anyone of us, in operations or management with responsibility for oversight, is susceptible to injury or disease. We are looking at hiring more people and one of our goals when filling positions is to seek qualified veterans, especially veterans with disabilities."  

"This control room is going to be the pride of our organization that we will want to show off to VIPs and the press and by removing the ramp, we have in essence painted a sign under the door, that says 'if you have trouble walking we don't want you here.'   The bad publicity I'll leave for others to deal with, but I'm concerned about needing the best of the best to operate and manage this facility, and them not having access at a critical moment when they are needed in the control room.  Our fork lifts (looking at construction in the eye) are not man rated."

At this point I might mention that one of the senior managers and arguably the most important member of the review team played football in the Big Eight, and as a result, only takes elevators and never takes the stairs.

Construction quickly spoke up and said George was right to bring this up, and understanding the risks involved his group could probably find the funds to fix the problem.  Safety added that if construction needed their help in generating the specifications, they would be glad to provide the personnel, and mentioned that in the future they should be allowed to review change orders that might have ADA implications.

One construction dollar may be worth 10 times what an operations' dollar is worth,  but public and management relations dollars are priceless.  George got his ramp.