Curl Global Community
Large Document Markup - Printable Version

+- Curl Global Community (
+-- Forum: Blogs (
+--- Forum: Tech blog (
+---- Forum: Robert blog (
+---- Thread: Large Document Markup (/showthread.php?tid=330)

Large Document Markup - RobertShiplett - 10-30-2011

In the last post we have a 4+ Mb document to display. That document can also be difficult to edit and as a Curl file, even awkward to debug.

Two small changes make the large UTF-8 document very much easier to handle.

First: replace all US-keyboard ASCII quotation marks (") in the text with UNICODE quote marks. In this case I have folowed one of the German quotation mark practices which is "low" double marks first and then "English" LEFT dbl-marks at the end. The effect is „this“. Now we have no Curl programming language type quoted strings in the text other than those tags and such used in our macros and procs. Life can be good ...

Second: replace/escape all ( parentheses ) with \( and \). This also makes handling a large text easier if a macro has a problem or you have a curly brace typo or { mismatch. Ditto for [square brackets] though we had none in this text.

Now what about the user? Will this text take 5 seconds to load or will it take 35 seconds? Does the applet look to be dead or alive?

My easy answer was to add a SplashScreen. The object is one of the first declared. I also declare and instantiate an almost empty TextFlowBox and add an event handler to it. Then one of the last items at the end of the text is the value of that tfb. So our text now starts with these expressions:

{def tfb = {TextFlowBox
{on AttachEvent do
}, {br}

title = "Loading Applet ...",
footer = "Text is loading ..."

|| then near the end of the text place

{value tfb}

|| when tfb is "attached" to the parent TextFlowBox, our splash screen will close

You can see the result of these and few other cosmetic changes at

Replacing the quotation marks in the text can be easy or tricky depending on how you proceed. You can use regular expressions with Find/Replace in your editor, but with expression-based Curl, I like to use an expression-based text processing script from a favourite language such as Rebol or a compiled Icon language such as Icon 9.5, UNICON or Robert Parlett's Object Icon. The text itself had been constructed using 2 lines of Rebol code. You may use Perl. There is even a SNOBOL plugin for Python if you want classic text processing without sed/awk and friends.

But could we let the user know how many seconds remain? We could add each of the books to a previously Visual such as a TextFlowBox and trip an AttachEvent to a timer loop for a progress bar on that SplashScreen. We risk creating a "Bill Gates-ian" file copy widget ... No! If we do one, it will be better than that!

Anyone have another idea for a progress bar?

Of course, not loading the entire large file up-front would leverage Curl async worker tasks or as-needed pkg loading or „…“ \[ more to follow \]

Until next post, “Enjoy Curl !”