Gracion Home

Coding in Prograph CPX

Here's a little home movie of what interactive coding is like in Prograph. In this example, I decide I want my app to read from a text or PICT file. I'm writing a "method", perhaps to be called by a menu command.

While the movie is loading, here's a description. (It requires the QuickTime plugin, is 878K, runs 1.5 minutes, silent).

I start by creating an instance operation that will use the Text File class, a rich class that contains dozens of useful methods. First method of the class I want is Get File, which brings up the standard get file dialog. I decide I want the dialog to allow TEXT and PICT files, and the second input to Get File supports that. It accepts a Prograph List, which I'll just hard code in (notice how easy it is to make a list, it's just literals separated by spaces within parentheses. Lists can be programmatically generated of course, and may contain any object).

Next we'll want to Open File, then we can Read Line. Ok, I'm not done yet, but I want to see how I've done so far. I'll hit a command and start execution (This is not a video edit! I didn't launch the app, but I'm able to execute any method upon command at any moment, with or without the app running).

As soon as Get File executes, I get a standard dialog (now we're executing my code). I double-click a file, then execution continues through the last item I coded (because of a breakpoint I set earlier. You can only see the tip of the red flag icon that represents this). Now execution is suspended while I can look at any of the data flowing down the source, make changes to data or code, as you'll see in a sec. The shaded background tells me that this is an executing method, currently paused.

Ok, lets see - I'll glance at the Text Edit class, in a little window that shows me the attributes and values, such as file type (shown as an integer here, though there's a function to see it as text), file reference, a couple of boolean flags, etc.). I could change a value here for fun, like change the maximum line length, but let's move on.

Did I get any data out of Read Line? Sure enough, there it is in the little popup (which can be selected to show up to 32K of text). Fine.

Now I'll just add a little code to find the location of the substring "text" in this data-- a Prograph primitive "in" does this. Pop back into execute mode, and step through the two new elements, and there's the result: the offset is 13.

Oh, I could have changed some code and showed you how it automatically backs up to the change and continues from that point, but this movie's getting long enough. I could go on and on about the dozens of ways Prograph makes it easier to create applications. I'd like you to see about the Editors (including an interface builder), direct access to Toolbox, code resources, or shared libraries, the interactive browsers and Info window with hyperlinked primitives, classes, and externals with usage comments.

Bottom line: with Prograph, coding is more like thinking.

An opensource replacement for Prograph: OSPGL

Commercial Prograph-like implementation for Mac OS X: Marten


This article is translated to Serbo-Croatian language by Jovana Milutinovich from Geeks Education.

Home

Notes by Paul A. Collins, Gracion Software (formerly One Click Systems).