Page 1 of 1

Printing text from a field nicely formatted - options?

Posted: Thu Mar 22, 2018 11:42 pm
by rumplestiltskin
I have a field that has tab-delimited text. I defined where the tabs should "appear", so to speak, so when I programmatically insert a line of tab-delimited text into that field, everything lines up nicely in columns. I know I can use the revPrintField command and, with the proper parameters, that seems to result in a nicely printed page.

However, I was wondering what others are doing to print text from their stacks.

I remember (and this tells you how old I am) printing from my Commodore using something like

Code: Select all

print@10 "This text.",CR
...which would start printing that text 10 spaces over from the left followed by a line feed and return but, of course, this was with a dot-matrix line printer and it printed as mono-spaced (and mono-spaced isn't a bad thing for a columnar report, right?).

I know PostScript can do much of this but I'm not going down that rathole. Is there anything in LC that can provide something similar to what I've described, above?

Thanks!

Barry

Re: Printing text from a field nicely formatted - options?

Posted: Fri Mar 23, 2018 2:38 pm
by MaxV

Re: Printing text from a field nicely formatted - options?

Posted: Fri Mar 23, 2018 9:32 pm
by FourthWorld
You've already found revPrintField; revPrintText is also useful, worth reviewing.

While both offer quick ways to handle text output, they provide little support for specifying locations for specific blocks of text.

In PostScript strings can be rendered at specific locations, and a similar method is used in LiveCode Builder (though less maddeningly in LCB, since it places the origin point at top-left as most systems do, while PostScript is nearly an island with its origin at bottom-left).

In LiveCode Script we use fields as text containers, with all the freedom of size and placement that allows.

If you review the scripts for revPrintField you'll find that ultimately they create offscreen stacks with fields in them, populating the fields with data for each page.

You don't need to dynamically create such stacks. Any card in any stack can be used as a printing source; the stack doesn't need to be visible to be printed from.

You may want to pop open the Dictionary and filter by "print", noting the many options available for setting scale, printing only portions of a card, handling the standard OS print dialogs, and more.

In short, we have nearly as much flexibility as PostScript in many respects, but with the ease of development one comes to expect from LiveCode.