Printing text from a field nicely formatted - options?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
rumplestiltskin
Posts: 222
Joined: Wed Jun 21, 2006 7:33 pm
Location: West of the Pecos
Contact:

Printing text from a field nicely formatted - options?

Post by rumplestiltskin » Thu Mar 22, 2018 11:42 pm

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

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

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

Post by MaxV » Fri Mar 23, 2018 2:38 pm

Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9823
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

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

Post by FourthWorld » Fri Mar 23, 2018 9:32 pm

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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”