The best way to print a long table field
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
The best way to print a long table field
Hi all,
My table field has unlimited lines of data, all to be printed. It prints 36 lines per page. I tried looking up a way to print 350 lines, over 10 pages, but didn't find anything. The first 'column' of a line is an Index number that increases by 1 for each next line. I'm thinking of finding a way to set each page of the TF to Indexes 1 - 36, 37 - 72, etc., and to print each card showing the range, in a repeat loop. This procedure could be arduous, and may not even work, so I would like to ask - (a) is there a better, more obvious way that you guys may know, and if not, (b) is my idea feasible ?
My table field has unlimited lines of data, all to be printed. It prints 36 lines per page. I tried looking up a way to print 350 lines, over 10 pages, but didn't find anything. The first 'column' of a line is an Index number that increases by 1 for each next line. I'm thinking of finding a way to set each page of the TF to Indexes 1 - 36, 37 - 72, etc., and to print each card showing the range, in a repeat loop. This procedure could be arduous, and may not even work, so I would like to ask - (a) is there a better, more obvious way that you guys may know, and if not, (b) is my idea feasible ?
Re: The best way to print a long table field
SOLVED
I populated the table field (from the datagrid) iusing usingn a batch of 36 lines, print a batch, populate again, print again, etc..,
using a loop to create a batch, and a second loop, til all the batches added up to the dg number of lines.
I populated the table field (from the datagrid) iusing usingn a batch of 36 lines, print a batch, populate again, print again, etc..,
using a loop to create a batch, and a second loop, til all the batches added up to the dg number of lines.
Re: The best way to print a long table field
Glad you solved this!
Not being very familiar with printing I was imagining how to do this and it struck me this would be a nice print-preview feature:
Ceate a substack, laid out as you would want to print, perhaps with a first/title page and subsequent pages being different cards and just print the card. You wouldn't need to create multiple subsequent cards, just update the table/DG showing the records to be printed (i.e. 1-36, 37-72 etc). Really you wouldn't even need to export the data to a tableField if you did this...
You could include navigation/print/cancel buttons that are hidden when printing the cards... just a thought.
Not being very familiar with printing I was imagining how to do this and it struck me this would be a nice print-preview feature:
Ceate a substack, laid out as you would want to print, perhaps with a first/title page and subsequent pages being different cards and just print the card. You wouldn't need to create multiple subsequent cards, just update the table/DG showing the records to be printed (i.e. 1-36, 37-72 etc). Really you wouldn't even need to export the data to a tableField if you did this...
You could include navigation/print/cancel buttons that are hidden when printing the cards... just a thought.
Re: The best way to print a long table field
Great workaround! Could you share the code snippet you used for the loops?
Re: The best way to print a long table field
MoodWhirr:
I do something like this. Given a field "rawData", which contains all the your data, and a field "printField", which is the actual field you want to print, in a button somewhere:
Depending on the way you have your setup, you could print the card itself, which might contain supporting elements. And you you do not actually need a field. There is the command "revPrintText" which can take the place of field "printField" above:
Untested, as I am driving in my car...
Craig
I do something like this. Given a field "rawData", which contains all the your data, and a field "printField", which is the actual field you want to print, in a button somewhere:
Code: Select all
on mouseUp
put fld "rawData" into tempData
put 20 into linesPerPrint --arbitrary, your number of lines here
put the number of lines of tempData div linesPerPrint into numPages
if the number of lines of fld "rawData" mod linesPerPrint <> 0 then add 1 to numPages
repeat numPages
put line 1 to linesPerPrint of tempData into fld "printField"
--revPrintField the name of fld "printField" --commented out for testing
delete line 1 to linesPerprint of tempData
end repeat
end mouseUp
Code: Select all
...
repeat numPages
put line 1 to linesPerPrint of tempData into textToPrint
revPrintText textToPrint
delete line 1 to linesPerprint of tempData
end repeat
Craig
-
- Livecode Opensource Backer
- Posts: 9762
- Joined: Fri Feb 19, 2010 10:17 am
Re: The best way to print a long table field
Why not export the field contents to an RTF document and print that?
Re: The best way to print a long table field
Hi,
Here's the code - don't know if it will help..good luck.
Code: Select all
put 0 into fld "stockcheck4"
repeat until fld "totallines" is tLines
repeat until fld "stockcheck4" of cd "manage products"is 33 or fld "totallines" is tLines3
add 1 to fld "stockcheck4"
add 1 to fld "totallines"
put the dgHilitedIndexes of group "DataGrid 3" into tIndex
put tIndex into fld "fcol 23"
put the dgHilitedLines of group "datagrid 3" into theLine
put the dgDataOfLine[theLine] of group "datagrid 3" into theDataA
put theDataA["code"]into fld "fcode"
put theDataA["description"]into fld "fdescription"
put theDataA["stock"]into fld "fstock"
put theDataA["type"]into fld "ftype"
put theDataA["location"]into fld "flocation"
put theDataA["checkedqty"]into fld "fcheckedqty"
set the dghilitedlines of grp "datagrid 3" to (the dghilitedlines of grp "datagrid 3" -1)
put cr & fld "fcol 23" & tab & fld "fcode" & tab & fld "fdescription" & tab & fld "ftype" & tab & fld "flocation" & tab & fld "fstock" & tab & fld "fcheckedqty" & tab after fld "tablefield1" of cd "printstockcheck"
if fld "totallines" is tLines3 and fld "stockcheck4" < 33 then
add 1 to fld "page" of cd "printstockcheck"
####print cd "printstockcheck"
answer"printing"
end if
if fld "stockcheck4" is 33 then
add 1 to fld "page" of cd "printstockcheck"
####print cd "printstockcheck"
answer "printing"
put 0 into fld "stockcheck4"
put tLines - 33 into tLines
set the dgHilitedLines of grp "datagrid 3" of cd "manage products" to tLines
end if
end repeat
set the dgHilitedLines of grp "datagrid 3" of cd "manage products" to tLines3
if fld "TotalLines" is tLines3 then
exit mouseup
end if
end repeat