Still Printing and formatting...
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Still Printing and formatting...
Hi,
I'm trying to 'span' the display of some text over two (or more) cards...
The first card (Card A) is the card that, ideally, would display all the data a user might have previously entered into a text field
The second card (Card B) is the card that would hold any 'overflowing' data, data that is simply too long to be displayed within the confines (rect) of the field on Card A (ie: the user has entered so much text, over so many lines, that the card simply isn't long enough to display it all)
So, I can catch (using FormattedHeight - Thanks Bernd!) the height a field would need to be to display all its data without using one or more SrollBars
I know the height of my card (Card A)
I can do the math to calculate that the text is indeed too long to fully fit on it, 'activate' the second card (Card B) and (currently) display the filed again on it (or not, if the text is short enough to fit on Card A)
My problem is that, at the moment, I'm struggling with how to determine what text has already been displayed within the confines of the filed on Card A so that I only display the 'rest' of the text on Card B.
So, say I have a field on Card A that can display (only) two physical lines of data, but I have string that is 4 lines long (may be with or without carriage returns, so text may be 'line wrapped' etc) how can I catch and display just the last 2 lines of data (the 'overflowing' lines) in a separate field on a separate card ?
I've thought of counting characters, looking for carriage returns/line feeds etc but these won't always work depending upon line wrapping etc...
Any ideas please ?
I'm trying to 'span' the display of some text over two (or more) cards...
The first card (Card A) is the card that, ideally, would display all the data a user might have previously entered into a text field
The second card (Card B) is the card that would hold any 'overflowing' data, data that is simply too long to be displayed within the confines (rect) of the field on Card A (ie: the user has entered so much text, over so many lines, that the card simply isn't long enough to display it all)
So, I can catch (using FormattedHeight - Thanks Bernd!) the height a field would need to be to display all its data without using one or more SrollBars
I know the height of my card (Card A)
I can do the math to calculate that the text is indeed too long to fully fit on it, 'activate' the second card (Card B) and (currently) display the filed again on it (or not, if the text is short enough to fit on Card A)
My problem is that, at the moment, I'm struggling with how to determine what text has already been displayed within the confines of the filed on Card A so that I only display the 'rest' of the text on Card B.
So, say I have a field on Card A that can display (only) two physical lines of data, but I have string that is 4 lines long (may be with or without carriage returns, so text may be 'line wrapped' etc) how can I catch and display just the last 2 lines of data (the 'overflowing' lines) in a separate field on a separate card ?
I've thought of counting characters, looking for carriage returns/line feeds etc but these won't always work depending upon line wrapping etc...
Any ideas please ?
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1
Re: Still Printing and formatting...
Because the title of this post is about printing my first answer changes every mention of card size to page size. Because a page can only hold so many characters (just like your 2 line card A). And the answer is, you don't have to worry about it because a printer handles page breaks.
If I have a notepad file with lots and lots of text in it I don't have to tell the printer where to make the page breaks it just does it.
When it comes time to print you can create a new invisable card and put your field into it then use the formattedHeight for the field and the card, then print.
If your post is actually about viewing the text on a screen then I think you should consider using scrollbars. Just like this browser I'm looking at I can't see your post right now but I could scroll down to see it.
Simon
If I have a notepad file with lots and lots of text in it I don't have to tell the printer where to make the page breaks it just does it.
When it comes time to print you can create a new invisable card and put your field into it then use the formattedHeight for the field and the card, then print.
If your post is actually about viewing the text on a screen then I think you should consider using scrollbars. Just like this browser I'm looking at I can't see your post right now but I could scroll down to see it.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Still Printing and formatting...
Thanks Simon,
Yep - Printing. Sorry, my understanding of printing is very limited at the moment - but I'm learning !
I have a card with various fields on it. The card (more precisely, the fields on the card) are populated with data entered on various other (different) cards. The data length for each field can vary from one to many, many lines, so, on the card the user sees, I use field scroll bars (where required) to enable all the data to be seen on the one card. This simplifies page layout (all fields can remain static / in their designed locations) and ensure the user can see all data for all fields on that card.
So, as I understand it so far, if I wish to print all this data out, I need to create a (kind of) duplicate card where the fields are not scrollable but of suitable heights to display the data they contain. Right so far ? (Maybe this is my first error). However, should this be true, then to achieve this, I note the 'top' of my first variable-height field on my print-card and set its 'height' to the 'formattedheight' of its corresponding (scrollable) field of my display-card, then adjust the 'top' of the next field of my print-card to the 'top' of the previous field (print-card) + the 'height' of that field + some offset value (to separate the fields a little...
I can do all this BUT, eventually, I come to the end of my card - i.e. the next 'top' is a value greater then my card 'height'... so... not seeing a way to change the height of an individual card, I thought I'd need to create one (or more) additional 'print overflow' cards to handle the as-yet unplaced fields... (alarm bells are now ringing in my head following your previous reply !! ).
Maybe what I should do is just keep placing fields one after the other, regardless of their fitting within my card height ?
This would certainly make life SOOO much simpler and, with the benefit of your previous reply, seems SOOO much more sensible... but, I have been unable to find an example of how to do this so I'm 'shooting from the hip' so's-to-speak... which is undoubtedly the best way to learn but is often rather embarassing
and very time consuming too
!
Anyway, I'll go away and see what happens if I simply keep adding fields to my card and then try print... I'll revert with my findings. In the meantime, if I'm still way off track, maybe you'd be able to offer some more explanation ?
Thanks a million. I'm off to try it... I'll be back (a la Arnie!)
Have a great weekend !
Yep - Printing. Sorry, my understanding of printing is very limited at the moment - but I'm learning !
I have a card with various fields on it. The card (more precisely, the fields on the card) are populated with data entered on various other (different) cards. The data length for each field can vary from one to many, many lines, so, on the card the user sees, I use field scroll bars (where required) to enable all the data to be seen on the one card. This simplifies page layout (all fields can remain static / in their designed locations) and ensure the user can see all data for all fields on that card.
So, as I understand it so far, if I wish to print all this data out, I need to create a (kind of) duplicate card where the fields are not scrollable but of suitable heights to display the data they contain. Right so far ? (Maybe this is my first error). However, should this be true, then to achieve this, I note the 'top' of my first variable-height field on my print-card and set its 'height' to the 'formattedheight' of its corresponding (scrollable) field of my display-card, then adjust the 'top' of the next field of my print-card to the 'top' of the previous field (print-card) + the 'height' of that field + some offset value (to separate the fields a little...
I can do all this BUT, eventually, I come to the end of my card - i.e. the next 'top' is a value greater then my card 'height'... so... not seeing a way to change the height of an individual card, I thought I'd need to create one (or more) additional 'print overflow' cards to handle the as-yet unplaced fields... (alarm bells are now ringing in my head following your previous reply !! ).
Maybe what I should do is just keep placing fields one after the other, regardless of their fitting within my card height ?
This would certainly make life SOOO much simpler and, with the benefit of your previous reply, seems SOOO much more sensible... but, I have been unable to find an example of how to do this so I'm 'shooting from the hip' so's-to-speak... which is undoubtedly the best way to learn but is often rather embarassing


Anyway, I'll go away and see what happens if I simply keep adding fields to my card and then try print... I'll revert with my findings. In the meantime, if I'm still way off track, maybe you'd be able to offer some more explanation ?
Thanks a million. I'm off to try it... I'll be back (a la Arnie!)
Have a great weekend !
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1
Re: Still Printing and formatting...
Nah - that didn't work
Just printed the print-card with the bottom most field just falling off the bottom of it... To be expected in some ways...
I'm using 'print card "crdPrintCard" ' to print the contents of the card so, I guess, this really isn't surprising ! Seeing as how the height of the card hasn't changed ! Hmmmm...
Once again, I'm missing something really, really basic here !
Back to the drawing board !!

Just printed the print-card with the bottom most field just falling off the bottom of it... To be expected in some ways...
I'm using 'print card "crdPrintCard" ' to print the contents of the card so, I guess, this really isn't surprising ! Seeing as how the height of the card hasn't changed ! Hmmmm...
Once again, I'm missing something really, really basic here !
Back to the drawing board !!
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1
Re: Still Printing and formatting...
See the "pageHeights" entry in the dictionary. You do need to manage the page breaks for scrolling fields, so you were on the right track. You were also correct that you need a printing card to act as a template. The pageHeights entry has a brief explanation, but the essence is that when printing long fields, get the pageHeights, print the card, set the scroll of the field to the next line of the pageHeights, print the card, and continue that way until the pageHeights are all used. You don't need to create any extra fields, just scroll the one that has the content.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Still Printing and formatting...
opps, I see what I did wrong, very sorry.
I thought you could set a cards height but you can't
, what I had done in the past was to create a new invisable stack and then resize it. Then let the printer manage the page breaks.
Jacque's coding is always great.
Simon
I thought you could set a cards height but you can't

Jacque's coding is always great.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Still Printing and formatting...
Thanks Simon, but you weren't too far off. You can set a card's height, but to do that you need to set the stack height. That will change all the cards in the stack to the same height, but if it's a printing template in a substack or one that's created dynamically, it often only has one card anyway.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Still Printing and formatting...
Hi Simon, Thanks for that. No problems. I'd looked at setting an individual card's 'height' but noted the 'height' / 'width' properties (etc) were only affected if one changed the corresponding stack properties - not what I was looking for on my visible card BUT... perfect for a subStack used for printing ... Thanks a million.
Thanks Jacque. I'm off to 'play' with 'pageHeights' !
I still have two questions - if that's not too rude at this stage :
[1] Can one have a scrollable card ? i.e.: Like this webpage (if it were a card), can I scroll the whole thing ? Maybe by adding all my controls to a 'group' - and making that scrollable ? I'd like not to be limited by the card's height (which I set by the device screen res/height...) - in other words to have controls hanging off the bottom of a card that users could scroll down (and then back up) to. This is more for mobile device work - not desktop .
[2] If I make a print card's 'height' so that it spans all controls on a card (i.e.: the 'height' of the print card would definitely be greater then the height of the user screen and any single piece of paper in the printer) do I have to do anything else to tell the printer handle the follow-on paper pages or will it simply handle this automatically ?
Again. Thanks both. Simply brilliant - in my opinion, one of the strongest features of LC is the people on this forum and their willingness to share both their knowledge and their time. Much appreciated.
TIA
Regards.
Thanks Jacque. I'm off to 'play' with 'pageHeights' !
I still have two questions - if that's not too rude at this stage :
[1] Can one have a scrollable card ? i.e.: Like this webpage (if it were a card), can I scroll the whole thing ? Maybe by adding all my controls to a 'group' - and making that scrollable ? I'd like not to be limited by the card's height (which I set by the device screen res/height...) - in other words to have controls hanging off the bottom of a card that users could scroll down (and then back up) to. This is more for mobile device work - not desktop .
[2] If I make a print card's 'height' so that it spans all controls on a card (i.e.: the 'height' of the print card would definitely be greater then the height of the user screen and any single piece of paper in the printer) do I have to do anything else to tell the printer handle the follow-on paper pages or will it simply handle this automatically ?
Again. Thanks both. Simply brilliant - in my opinion, one of the strongest features of LC is the people on this forum and their willingness to share both their knowledge and their time. Much appreciated.
TIA
Regards.
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1
Re: Still Printing and formatting...
Hi Traxgeek,
You are one of the good question askers, makes it much more fun to respond.
Jacque's pageHeight is probably the best solution, as in, knowledge that you can use in the future to produce really well formatted printouts. Mine however...
[1] Yes, you've got that. Make a group and scroll everything.
[2] Here is where I get called a Hack. As I did, make a group and put all the formattedHeight of the fields in it, format the group to it's fomattedHeight. Copy the group to a new stack and set the stacks height to the formattedHeight of your new group. Print that. Yes, it may be way too large for a screen thats why I use an invisible stack (no need for the user to see it).
Oh well, just me.
Simon
You are one of the good question askers, makes it much more fun to respond.

Jacque's pageHeight is probably the best solution, as in, knowledge that you can use in the future to produce really well formatted printouts. Mine however...
[1] Yes, you've got that. Make a group and scroll everything.
[2] Here is where I get called a Hack. As I did, make a group and put all the formattedHeight of the fields in it, format the group to it's fomattedHeight. Copy the group to a new stack and set the stacks height to the formattedHeight of your new group. Print that. Yes, it may be way too large for a screen thats why I use an invisible stack (no need for the user to see it).
Oh well, just me.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Still Printing and formatting...
Hi Simon,
To be completely frank - I like your 'quick and dirty' method. Every method has a time and place and for me, I just have one filed at the end of a card/print page that has variable length / height... Your method of simply extending the (invisible) print card (a copy of the 'real' card sounds fantastic. Probably not so good for a detailed report from a DataGrid but fantastic in this case !
Problem for me is that I can stop my code just before the 'print card' statement and see my print card's 'height is 1845 or similarly large value (my 'standard' card height is 880 - can't remember now why I selected that, but I did...) but I only print to the end of the first paper page (right to the end / into the gutter...). I can see on my printout that the code has extended the 'length' / 'height' of my print card BUT only to the very bottom of my first printed paper page. Similarly, I can see (on the screen, if I turn off the hidden property for the print card) that I am displaying the full length print card. I'm just not printing it !
I feel like a pair of nun's knickers here - always 'on' (no offense to any nun's reading this) but may I ask you to think why this may be please ?
In the meantime I'm 'playing' with 'pageheights' but, for this job, I really think this is a little overkill for what I'm trying to achieve...
TIA.
Regards.
To be completely frank - I like your 'quick and dirty' method. Every method has a time and place and for me, I just have one filed at the end of a card/print page that has variable length / height... Your method of simply extending the (invisible) print card (a copy of the 'real' card sounds fantastic. Probably not so good for a detailed report from a DataGrid but fantastic in this case !
Problem for me is that I can stop my code just before the 'print card' statement and see my print card's 'height is 1845 or similarly large value (my 'standard' card height is 880 - can't remember now why I selected that, but I did...) but I only print to the end of the first paper page (right to the end / into the gutter...). I can see on my printout that the code has extended the 'length' / 'height' of my print card BUT only to the very bottom of my first printed paper page. Similarly, I can see (on the screen, if I turn off the hidden property for the print card) that I am displaying the full length print card. I'm just not printing it !
I feel like a pair of nun's knickers here - always 'on' (no offense to any nun's reading this) but may I ask you to think why this may be please ?
In the meantime I'm 'playing' with 'pageheights' but, for this job, I really think this is a little overkill for what I'm trying to achieve...
TIA.
Regards.
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1
Re: Still Printing and formatting...
Aha - re-re-re-reading the Dictionary...
It looks like one needs to use the "Print... into" form of "Print..." a la :
Off to try that now...
The silver lining in my 'print' cloud is that this thread and my struggles may well help other newbies to LC printing in the future...
Well, here goes...
Regards.
It looks like one needs to use the "Print... into" form of "Print..." a la :
OopsNote: If a card is larger than a full page, the print command prints only the first page of the card, starting at the top left corner. To print the entire card, use the print...into pageRect form to scale the card to the page.

Off to try that now...
The silver lining in my 'print' cloud is that this thread and my struggles may well help other newbies to LC printing in the future...
Well, here goes...
Regards.
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1
Re: Still Printing and formatting...
You can make a group the way Simon explained, set the height of the group to the dimensions of a printed page, and then scroll the group instead of using the pageheights to scroll just the text field. The amount to scroll will be the same as the height of the group. The script still does need to scroll, print card, scroll, print card though.
That method will cut off any objects or text that overlap the scoll though. Half the object will be on the first page and the lower half will be on the second page. The pageheights takes that into consideration so you don't need to calculate where the bottom of a line is.
"Print into rect" could work too, though if your card is very tall, the printout will be tiny.
That method will cut off any objects or text that overlap the scoll though. Half the object will be on the first page and the lower half will be on the second page. The pageheights takes that into consideration so you don't need to calculate where the bottom of a line is.
"Print into rect" could work too, though if your card is very tall, the printout will be tiny.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Still Printing and formatting...
Hi Jacque,
I thought that Simon's way would have not scaled my card to fit a single page but rather, 'spanned' my print out over several pages as required to fit it all in...
Nevermind... I'm learning tons !
I guess my 'short and dirty' way isn't going to work because I'm not in control of the length of user input (but am in control of the card / print page width) and, therefore, what I get is an ever smaller text height to enable the printer to cram all the print card data onto one physical printer / paper page - which has the result of making the card's aspect ratio change depending upon the length of the user data... Not sure if that makes sense (it does though to me - honest !)
So.... I have learnt how to
1: use the the basic form of Print Card,
2: how to scale my output using 'printscale',
3: how to use 'print... from/to...' to print an area of my card and ...
4: how to use the 'print... into' to make (virtually) any card fit onto a printer/paper page
Now it's onto 'pageheights' to see if I can get my card spread over the required number of paper pages without changing its (width) scaling...
Again, thanks a mil. both of you. Really appreciated.
Regards.
Thanks a mil - though I just found that out"Print into rect" could work too, though if your card is very tall, the printout will be tiny.

I thought that Simon's way would have not scaled my card to fit a single page but rather, 'spanned' my print out over several pages as required to fit it all in...
Nevermind... I'm learning tons !
I guess my 'short and dirty' way isn't going to work because I'm not in control of the length of user input (but am in control of the card / print page width) and, therefore, what I get is an ever smaller text height to enable the printer to cram all the print card data onto one physical printer / paper page - which has the result of making the card's aspect ratio change depending upon the length of the user data... Not sure if that makes sense (it does though to me - honest !)
So.... I have learnt how to
1: use the the basic form of Print Card,
2: how to scale my output using 'printscale',
3: how to use 'print... from/to...' to print an area of my card and ...
4: how to use the 'print... into' to make (virtually) any card fit onto a printer/paper page
Now it's onto 'pageheights' to see if I can get my card spread over the required number of paper pages without changing its (width) scaling...
Again, thanks a mil. both of you. Really appreciated.
Regards.
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1
Re: Still Printing and formatting...
Printing is one of the more advanced things to do in LiveCode, so your progress is good. It's a lower-level procedure than most of the other things, but there isn't really a good way to automate it in the engine because every printout will have different requirements. So don't get discouraged, you're making good progress.
If all you are doing is printing a field, you can skip the grouping and just print the field. In fact, if that's all you're after, take a look at revPrintField in the dictionary, it handles all the dirty work for you. ((I forgot about that command, I hardly ever use it.) But if you want to print the whole card with all its objects, you're on the right track now.
If all you are doing is printing a field, you can skip the grouping and just print the field. In fact, if that's all you're after, take a look at revPrintField in the dictionary, it handles all the dirty work for you. ((I forgot about that command, I hardly ever use it.) But if you want to print the whole card with all its objects, you're on the right track now.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com