Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Large Document Markup
10-30-2011, 07:45 AM, (This post was last modified: 10-30-2011, 07:48 AM by RobertShiplett.)
Large Document Markup
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 !”
Robert Shiplett, Curlr
Fredericton NB


Possibly Related Threads...
Thread Author Replies Views Last Post
  large TocDocument in 64-bit browser RobertShiplett 0 3,524 01-19-2014, 01:14 AM
Last Post: RobertShiplett
  latest flashcard markup example RobertShiplett 1 4,552 04-02-2013, 08:23 PM
Last Post: RobertShiplett
  Curl as flashcard markup RobertShiplett 1 4,819 03-09-2013, 01:58 AM
Last Post: RobertShiplett
  Curl as a markup DSL for Russian Text RobertShiplett 1 6,422 09-24-2012, 01:17 PM
Last Post: alton
  serialization for selections from a large off-line Japanese text resource RobertShiplett 0 2,943 06-04-2012, 11:20 PM
Last Post: RobertShiplett
  e-Textbook Markup RobertShiplett 0 3,344 01-22-2012, 02:02 AM
Last Post: RobertShiplett
  Indexed Document RobertShiplett 0 2,893 01-04-2012, 01:10 AM
Last Post: RobertShiplett
  Text Markup RobertShiplett 0 3,457 10-31-2011, 06:07 AM
Last Post: RobertShiplett
Forum Jump:

Users browsing this thread:
1 Guest(s)

MyBB SQL Error

MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
1017 - Can't find file: 'mybb_threadviews' (errno: 2)
INSERT INTO mybb_threadviews (tid) VALUES('330')