Showing posts with label Mac OS X. Show all posts
Showing posts with label Mac OS X. Show all posts

Friday, October 07, 2005

[MetaCard and Tcl] Blogs.mc

I got asked to describe the stack a little better. Here goes:
My blogs.mc stack has two text fields (fSource and fGenerated) and some buttons at the bottom (create_card, first, prev, next, last, render, preview, delete).

With some marked-up text in the fSource field, I click 'render' and the output of the Tcl script (HTML) is put into the fGenerated field (line 6 of the 'Render' script).

Then when I click on 'preview' the HTML in the fGenerated field gets dumped to a file and passed to Safari. The fGenerated field is modifiable so I can play with things to get what I want and then tweak the Tcl script appropriately afterwards.
About the same time I posted this to the MetaCard list:
On my blog, codeaholic.blogspot.com, I've posted an item about MetaCard (on OS X) using Tcl to more-or-less bypass the script size limit of the unregistered version of MetaCard.
Richard Gaskin wrote back, saying (in part):
since there is no MetaCard anymore anyway, and since Rev only offers a 30-day trial for the engine, I'm not sure how helpful the article will be.

At $99 for the low-end Rev license, is the pricing really so prohibitive?
Also Alejandro Tejada wrote
i do not see how this could get around the 10 lines limit, but Geoff Canyon wrote an extensive tutorial to manage longer scripts within the 10 lines limits.

This tutorial is still useful for developers that want to run longer scripts in their standalone applications.

I get it from Ken Ray's website within the RR v 1.1 docs (saved as a pdf file). i'm not sure if this tutorial is still available in any website.

You could ask directly to Geoff Canyon. Look for his website: inspiredlogic.com
I answered with
> i do not see how this could get around the
> 10 lines limit,

bad choice of words on my part. It doesn't so much get around it as it does acquiesce to the fact and try to use other tools to do what can't otherwise be done. Instead of using MetaCard's HTML mechanism or writin8g something in MetaTalk, I've farmed out the functionality to a Tcl script.

> but Geoff Canyon wrote an
> extensive tutorial to manage longer scripts
> within the 10 lines limits.

of this I was unaware. I have thought about doing something similar. What I usually end up doing however, when I need to hang more closely to MetaCard is to use AppleScript and 'do script' or 'evaluate' the things I need. I will nevertheless make enquiries now that I know better.

Wednesday, September 28, 2005

[MetaCard and Tcl] Broggle's cousin at home on the iBook

MetaCard's great but I can't afford to buy it (not that you can anyway, now that it's been subsumed into Runtime Revolution). But using the demo version means I keep bumping up against an inbuilt limit for scripts. So I hit upon the idea of bypassing the issue by calling external scripts.

The tool I use to write blogs at home (as opposed to the HTA I use elsewhere) is written in MetaCard and does the render and preview passes using Tcl.

[Aside: Not that there's anything about Tcl that lends itself to the job. I could have used Perl, Lua, Python, sed (maybe), awk, or any number of other languages from Algol68 (there's an implementation for Mac OS X believe it or not) right through to Zen BASIC. It's just that Tcl is familiar ground.]

Right, where was I. Oh yes ...

First the script in my "Render" button ...
... which creates a file in the temporary folder (I'm on Mac OS X here ... might work on Linux ... have to do something drastic for Windows), and puts my marked-up text from field fSource into it. Then it shells out to render.tcl and captures its output into the fGenerated field. The temporary file is deleted.

Render.tcl looks like this (in its current incarnation):
This script inhales the file specified on the command line, splits it on newline and works its way through the lines, outputting HTML according to the rules of the markup: @ in column 1 identifies markup and there are currently four types: text, code, quot and end. Very simple, but it does me fine ... for now.

So after this runs, there's HTML in the fGenerated field. If I want to see how it's going to turn out in a browser, then I click on the Preview button. Okay, so it won't have all the CSS definitions that blogspot/blogger would apply but I get a useful approximation.

The script for the Preview button ...
... is similar to that of the Render button except this time I create an .html file in /tmp and and write the contents of the fGenerated field to it. I ignore the output of the shell() command.

I haven't quite figured out how to delete the temporary file because, if I uncomment the "delete file", by the time Safari is ready to load the file it's gone. There might be some way of making the shell synchronous, the way that /WAIT does on Win2k's START command, but then that'd probably mean waiting until Safari quits before I can use my blog writer again ... definitely sub-optimal. Then again, it'd be waiting for "open" to close, which happens as soon as it's launched Safari. And it's 10:48 pm and ...

Well, that's it. I really enjoyed this short break away from the long run of VBScript posts. I've got more stuff cooking here at home including a short foray into Javascript (a language I should have learned ages ago). Till then ...

Monday, August 22, 2005

Good news about Modula-2 on Mac OS X

Hooray! Finally I get to leverage all my Modula-2 skill into the Mac OS X environment. Bring on the Objective Modula-2!! Objective Modula-2 and An Overview of Objective Modula-2 by the founder of the project, Benjamin Kowarsch. http://en.wikipedia.org/wiki/Objective_Modula-2 See also Objective Modula-2 – A Discussion and Working Paper