Listbox Printing

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Listbox Printing

4D Tech mailing list
I am printing a listbox on a form which just has a detail section (i.e. Print Form). The listbox is printing, but variable sized according to the arrays, and I’d like fixed size with empty rows. There isn’t much documentation on printing listboxes, there’s no “Print variable frame” checkbox like text areas, and they don’t even receive the normal printing events. Is there a way to accomplish this?

Jim Crate

**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Listbox Printing

4D Tech mailing list
Jim

FYI. If you want to print a list box The code is rather slow. Its actually better to convert it to a Quick report.

The following code will print any listbox area. As you can see I have not optimised this for V16. I need to look at the way it is setting the font and size etc, it also uses some formats from my system -should not take much to adapt this to your needs.(I tried it with a million rows i think and it was pretty impressive)

ARRAY TEXT($arrColNames;0)
                ARRAY TEXT($arrHeaderNames;0)
                ARRAY POINTER($arrColVars;0)
                ARRAY POINTER($arrHeaderVars;0)
                ARRAY BOOLEAN($arrColsVisible;0)
                ARRAY POINTER($arrStyles;0)
                C_LONGINT($left;$Top;$Right;$Bottom;$MaxRows;$MaxPortrait;$MaxHeight;$MaxWidth)


                LISTBOX GET ARRAYS(DB_b_OutputArrays;$arrColNames;$arrHeaderNames;$arrColVars;$arrHeaderVars;$arrColsVisible;$arrStyles)<—use your listbox area reference here
                $TotalWidth:=0
                For ($i;1;Size of array($arrColNames))
                        $TotalWidth:=$TotalWidth+LISTBOX Get column width(*;$arrColNames{$i})

                End for
                //$OK:=PRINT_SetSIZE ("A4";"P”)<—This is  piece of code  i have that sets the print size-its
               

$QRarea:=QR New offscreen area
                        QR SET REPORT TABLE($QRarea;DB_l_CurrentDisplayedForm)
                        $ColumnNumber:=0
                        For ($i;1;Size of array($arrColNames))

                                RESOLVE POINTER($arrColVars{$i};$vsVarName;$vlTableNum;$vlFieldNum)
                                If ($vlTableNum>0) | ($vsVarName#"")
                                        $ColumnNumber:=$ColumnNumber+1
                                        If ($vlTableNum>0)
                                                $Field:=Field($vlTableNum;$vlFieldNum)
                                        Else
                                                $Field:=Get pointer($vsVarName)
                                        End if
                                        $HeadVar:=$arrHeaderVars{$i}
                                        QR INSERT COLUMN($QRarea;$ColumnNumber;$Field)
                                        C_TEXT($title;$displayFormat)
                                        C_LONGINT($hide;$repeatedValue)
                                        C_LONGINT($size)

                                        $type:=Type(($Field)->)
                                        $Format:=""
                                          //LB_SetFormat ($Area;1;"";$i;$i;3)
                                        Case of
                                                : (($type=1)) & ($Format="")
                                                        $Format:="|AccountsNZ"
                                                : (($Type=8)) & ($Format="")
                                                        $Format:="|integers"
                                                : (($type=9)) & ($Format="")
                                                        $Format:="|Longint"

                                                : ($type=Is time) & ($Format="")  
                                                        $Format:="&/5"
                                                : ($type=4) & ($Format="")
                                                        $Format:=""

                                                Else
                                                        $Format:=""
                                        End case

                                        C_TEXT($object)
                                        QR GET INFO COLUMN($QRarea;$ColumnNumber;$title;$object;$hide;$size;$repeatedValue;$displayFormat)
                                        $ColumnWidth:=LISTBOX Get column width(*;$arrColNames{$i})
                                        $Hide:=Num(($ColumnWidth=0) | ($arrColsVisible{$i}=False))

                                        $ColumnTitle:=OBJECT Get title($HeadVar->)

                                        QR SET INFO COLUMN($QRarea;$ColumnNumber;$ColumnTitle;$object;$Hide;$ColumnWidth;1;$Format)
                                        If (True)
                                                QR SET TEXT PROPERTY($QRarea;$ColumnNumber;qr title;_O_qr font;_o_Font number(<>FontBold))

                                                QR SET TEXT PROPERTY($QRarea;$ColumnNumber;qr title;qr font size;<>FontDefaultBoldSize)
                                                QR SET TEXT PROPERTY($QRarea;1;-1;qr bold;1)
                                                  //QR SET TEXT PROPERTY($QRarea;1;-1;qr text color;0x0000FF00)

                                                QR SET TEXT PROPERTY($QRarea;$ColumnNumber;qr detail;_O_qr font;_o_Font number(<>FontPlain))
                                                QR SET TEXT PROPERTY($QRarea;$ColumnNumber;qr detail;qr font size;<>FontDefaultPlainSize)
                                        End if
                                End if
                        End for
                        If ($TotalWidth>$MaxPortrait)
                                //$OK:=PRINT_SetSIZE ("A4";"L”)<-changes the print to landscape
                                GET PRINTABLE AREA($MaxRows;$MaxLandcscape)
                                If ($MaxLandcscape<$TotalWidth)
                                        Gen Confirm ("Format to one sheet wide?";"Yes";"No")
                                        If (OK=1)
                                                $PC:=Int($MaxLandcscape/($TotalWidth/100))


                                                If ($PC<100)
                                                        SET PRINT OPTION(Scale option;$PC)
                                                End if
                                        End if
                                End if
                                GET PRINTABLE MARGIN($left;$Top;$Right;$Bottom)
                                GET PRINTABLE AREA($MaxHeight;$MaxWidth)
                        Else
                                GET PRINTABLE MARGIN($left;$Top;$Right;$Bottom)
                                GET PRINTABLE AREA($MaxHeight;$MaxWidth)
                        End if
                        $maxlines:=Int($MaxHeight/16)

                          //PRINT SETTINGS
                        QR RUN($QRarea)
                        QR DELETE OFFSCREEN AREA($QRarea)


Nigel Greenlee


> On 2 Aug 2017, at 19:18, James Crate via 4D_Tech <[hidden email]> wrote:
>
> I am printing a listbox on a form which just has a detail section (i.e. Print Form). The listbox is printing, but variable sized according to the arrays, and I’d like fixed size with empty rows. There isn’t much documentation on printing listboxes, there’s no “Print variable frame” checkbox like text areas, and they don’t even receive the normal printing events. Is there a way to accomplish this?
>
> Jim Crate
>
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[hidden email]
> **********************************************************************

**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Listbox Printing

4D Tech mailing list
In reply to this post by 4D Tech mailing list
have you looked into "Print object"?

http://doc.4d.com/4Dv16/4D/16/Print-object.301-3035768.en.html

> 2017/08/03 3:18、James Crate via 4D_Tech <[hidden email]> のメール:
>
> I am printing a listbox on a form which just has a detail section (i.e. Print Form). The listbox is printing, but variable sized according to the arrays, and I’d like fixed size with empty rows. There isn’t much documentation on printing listboxes, there’s no “Print variable frame” checkbox like text areas, and they don’t even receive the normal printing events. Is there a way to accomplish this?




**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Listbox Printing

4D Tech mailing list
I use Print Object a lot. For example,  here I put it in a repeat loop and move it up to the top of the page after the first page prints if there is more than 1 page…

                        $end:=Print object(vPatientName)  //Text variable
                        $end:=Print object(*;"info@“)  //segmented box with 5 text variables, ie. status, rx, start date etc.
                        $moved:=False
                        Repeat
                                $end:=Print object(*;"TreatmentCards”)  //list box

                                If (Not($end))

                                        If (Not($moved))
                                                $moved:=True
                                                OBJECT MOVE(*;"TreatmentCards";0;-43;0;43) //no longer need the patient info, just the patient name so move the list box up and make it longer

                                        End if


                                        PAGE BREAK

                                End if

                        Until ($end)

> On Aug 2, 2017, at 2:27 PM, Keisuke Miyako via 4D_Tech <[hidden email]> wrote:
>
> have you looked into "Print object"?

John Baughman
Kailua, Hawaii
(808) 262-0328
[hidden email]





**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Listbox Printing

4D Tech mailing list
In reply to this post by 4D Tech mailing list

**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Listbox Printing

4D Tech mailing list
In reply to this post by 4D Tech mailing list
I had forgotten about Print Object. However, this is a listbox embedded in a form with lots of other fields/variables, it doesn’t look like Print Object can work in combination with Print Form.

I did figure out how to fake it. There will normally be 4-8 rows, the space can accommodate 12 rows, and when there were fewer than 12 the listbox shrank, leaving a big gap on the page. I just made the arrays have 12 elements, and I get the right length. The downside is that I can’t use display formats, and I have to manage totals myself instead of using the listbox footer calculations which were so convenient. At least it’s still better than the way it was, which was 5+ objects per row for 12 rows to manually create a table that fills a space.

If listboxes are actually intended to be printed, there should be an option to print fixed size, and they should receive some kind of form event. This one does not receive On Load when printing and has no options for printing events.

Jim Crate

> On Aug 2, 2017, at 8:27 PM, Keisuke Miyako via 4D_Tech <[hidden email]> wrote:
>
> have you looked into "Print object"?
>
> http://doc.4d.com/4Dv16/4D/16/Print-object.301-3035768.en.html
>
>> 2017/08/03 3:18、James Crate via 4D_Tech <[hidden email]> のメール:
>>
>> I am printing a listbox on a form which just has a detail section (i.e. Print Form). The listbox is printing, but variable sized according to the arrays, and I’d like fixed size with empty rows. There isn’t much documentation on printing listboxes, there’s no “Print variable frame” checkbox like text areas, and they don’t even receive the normal printing events. Is there a way to accomplish this?
>
>
>
>
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[hidden email]
> **********************************************************************

**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Listbox Printing

4D Tech mailing list
I don't see any reasons why they won't work in tandem.

in the context of OPEN PRINTING JOB,
you are just printing objects on top of each other, in memory.

> 2017/08/03 12:01、James Crate via 4D_Tech <[hidden email]> のメール:
> it doesn’t look like Print Object can work in combination with Print Form.




**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Listbox Printing

4D Tech mailing list
https://github.com/miyako/4d-tips-print-form-print-object-combo

2017/08/03 12:34、miyako <[hidden email]<mailto:[hidden email]>> のメール:
I don't see any reasons why they won't work in tandem.


**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Listbox Printing

4D Tech mailing list
In reply to this post by 4D Tech mailing list
Thanks Keisuke, that’s good to know. Printing is never my favorite thing to manage but perhaps that will make things easier sometime.

Jim Crate


> On Aug 2, 2017, at 11:34 PM, Keisuke Miyako via 4D_Tech <[hidden email]> wrote:
>
> I don't see any reasons why they won't work in tandem.
>
> in the context of OPEN PRINTING JOB,
> you are just printing objects on top of each other, in memory.
>
>> 2017/08/03 12:01、James Crate via 4D_Tech <[hidden email]> のメール:
>> it doesn’t look like Print Object can work in combination with Print Form.
>
>
>
>
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[hidden email]
> **********************************************************************

**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Listbox Printing

4D Tech mailing list
In reply to this post by 4D Tech mailing list
I tried several combinations of the code below showing a button method on the form "SumForm".  The parent method gets passed some arrays, opens its form "SumForm", displays them in the LB, and provides a button with the below code.

The button method prints fine in a DB.  When the DB is used as a component, the page prints blank.  All code and the form are in the component.
The fix is to copy the source LB to the LB on the form being opened.  It's odd because it's the same form and LB.  Am I missing a simple step to make this work from a component?  FORM LOAD("SumForm";*) would not help since the Host does not contain the form.

PRINT SETTINGS  // Does not work when displaying the LB from a component
If (OK=1)
        $obj:=(->Box_Sum)
        OPEN PRINTING JOB
        If (OK=1)
                FORM LOAD("SumForm")  // this form has Box_Sum on it
                Repeat
                        $end:=Print object($obj->)
                        If (Not($end))
                                PAGE BREAK
                        end if
                Until ($end)
        End if
        CLOSE PRINTING JOB
End if

Thanks,

Keith - CDI

> On Aug 2, 2017, at 10:34 PM, Keisuke Miyako via 4D_Tech <[hidden email]> wrote:
>
> I don't see any reasons why they won't work in tandem.
>
> in the context of OPEN PRINTING JOB,
> you are just printing objects on top of each other, in memory.
>
>> 2017/08/03 12:01、James Crate via 4D_Tech <[hidden email]> のメール:
>> it doesn’t look like Print Object can work in combination with Print Form.
>

**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Listbox Printing

4D Tech mailing list

> Le 12 août 2017 à 22:46, Keith Culotta via 4D_Tech <[hidden email]> a écrit :
>
> All code and the form are in the component.[...]

Hi Keith,
I remember I tried to use a component form as a template for 'Print object': failed  :-(
From here:
<http://doc.4d.com/4Dv12/4D/12.4/Interaction-between-components-and-host-databases.300-1015873.en.html>
"On the host database side, it is imperative that subforms coming from components must be used in page mode"
I suppose the word "print" is not missing for nothing…

--
Arnaud de Montard



**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Listbox Printing

4D Tech mailing list
In reply to this post by 4D Tech mailing list
have you tried using the object name instead ?

> 2017/08/13 5:46、Keith Culotta via 4D_Tech <[hidden email]> のメール:
> $obj:=(->Box_Sum)




**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Listbox Printing

4D Tech mailing list
I tried with the name as well. It works that way too, but not when run as a component.


SET PRINT PREVIEW(True)
If (OK=1)

        ARRAY LONGINT(aA;0)
        ARRAY TEXT(aB;0)
        For ($i;1;10)
                APPEND TO ARRAY(aA;$i)
                APPEND TO ARRAY(aB;"Text"+String($i))
        End for  

        OPEN PRINTING JOB
        FORM LOAD("Form1")
        $all:=Print object(*;"ListBox")
        CLOSE PRINTING JOB

End if

Keith
         http://www.compdim.com/ | https://www.apple.com/support/macbasics/

> On Aug 13, 2017, at 5:18 PM, Keisuke Miyako via 4D_Tech <[hidden email]> wrote:
>
> have you tried using the object name instead ?
>
>> 2017/08/13 5:46、Keith Culotta via 4D_Tech <[hidden email]> のメール:
>> $obj:=(->Box_Sum)
>
>
>
>
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[hidden email]
> **********************************************************************

**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Listbox Printing

4D Tech mailing list
I am not sure I understand your code;

are you not supposed to populate the arrays AFTER you call FORM LOAD (unless the listbox already exists in the current form) ?

> 2017/08/14 23:29、Keith Culotta via 4D_Tech <[hidden email]> のメール:
>
> I tried with the name as well. It works that way too, but not when run as a component.
>
> SET PRINT PREVIEW(True)
> If (OK=1)
>
> ARRAY LONGINT(aA;0)
> ARRAY TEXT(aB;0)
> For ($i;1;10)
> APPEND TO ARRAY(aA;$i)
> APPEND TO ARRAY(aB;"Text"+String($i))
> End for
>
> OPEN PRINTING JOB
> FORM LOAD("Form1")
> $all:=Print object(*;"ListBox")
> CLOSE PRINTING JOB
>
> End if




**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Listbox Printing

4D Tech mailing list
One correction - the Listbox appears when I use the Name.  (The component built in an unused location when I tested your suggestion)

The listbox already appears in the current form, and does print as expected.  However when the app is compiled as a component, and its method called from the Host, the values do not appear in the printout.

It can be called from both apps by the shared "printLB" method.  http://cdinc.co/Sample/LBPrint.zip <http://cdinc.co/Sample/LBPrint.zip>  It just acts differently when "printLB" is called from a host.

v16.1

Keith - CDI

> On Aug 14, 2017, at 11:43 AM, Keisuke Miyako via 4D_Tech <[hidden email]> wrote:
>
> I am not sure I understand your code;
>
> are you not supposed to populate the arrays AFTER you call FORM LOAD (unless the listbox already exists in the current form) ?
>
>> 2017/08/14 23:29、Keith Culotta via 4D_Tech <[hidden email]> のメール:
>>
>> I tried with the name as well. It works that way too, but not when run as a component.
>>
>> SET PRINT PREVIEW(True)
>> If (OK=1)
>>
>> ARRAY LONGINT(aA;0)
>> ARRAY TEXT(aB;0)
>> For ($i;1;10)
>> APPEND TO ARRAY(aA;$i)
>> APPEND TO ARRAY(aB;"Text"+String($i))
>> End for
>>
>> OPEN PRINTING JOB
>> FORM LOAD("Form1")
>> $all:=Print object(*;"ListBox")
>> CLOSE PRINTING JOB
>>
>> End if
>
>
>
>
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[hidden email]
> **********************************************************************

**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Listbox Printing

4D Tech mailing list
In reply to this post by 4D Tech mailing list
I did not mean to miss your point, but the following does not work when called from within the component either.  The code I uploaded has it outside the print job.  All variations have worked when used in the matrix structure.

        OPEN PRINTING JOB
        FORM LOAD("Form1")

        ARRAY LONGINT(aA;0)
        ARRAY TEXT(aB;0)
        For ($i;1;10)
                APPEND TO ARRAY(aA;$i)
                APPEND TO ARRAY(aB;"Text"+String($i))
        End for

        v1:="Test String"
        $all:=Print object(*;"ListBox")
        $all:=Print object(*;"v1")

        CLOSE PRINTING JOB

Keith - CDI

> On Aug 14, 2017, at 11:43 AM, Keisuke Miyako via 4D_Tech <[hidden email]> wrote:
>
> I am not sure I understand your code;
>
> are you not supposed to populate the arrays AFTER you call FORM LOAD (unless the listbox already exists in the current form) ?
>
>> 2017/08/14 23:29、Keith Culotta via 4D_Tech <[hidden email]> のメール:
>>
>> I tried with the name as well. It works that way too, but not when run as a component.
>>
>> SET PRINT PREVIEW(True)
>> If (OK=1)
>>
>> ARRAY LONGINT(aA;0)
>> ARRAY TEXT(aB;0)
>> For ($i;1;10)
>> APPEND TO ARRAY(aA;$i)
>> APPEND TO ARRAY(aB;"Text"+String($i))
>> End for
>>
>> OPEN PRINTING JOB
>> FORM LOAD("Form1")
>> $all:=Print object(*;"ListBox")
>> CLOSE PRINTING JOB
>>
>> End if
>
>
>
>
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[hidden email]
> **********************************************************************

**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Listbox Printing

4D Tech mailing list
FORM LOAD simply loads the form definition.
the data source (variables and arrays) are not bound automatically in print.
you need to populate the objects by their names:

SET PRINT PREVIEW(True)

If (OK=1)

OPEN PRINTING JOB

FORM LOAD("Form1")

$aA:=OBJECT Get pointer(Object named;"Column1")
$aB:=OBJECT Get pointer(Object named;"Column2")

ARRAY LONGINT($aA->;0)
ARRAY TEXT($aB->;0)

For ($i;1;10)
APPEND TO ARRAY($aA->;$i)
APPEND TO ARRAY($aB->;"Text"+String($i))
End for

$printed:=Print object(*;"ListBox")

$v1:=OBJECT Get pointer(Object named;"v1")
$v1->:="Test String"

$printed:=Print object(*;"v1")

CLOSE PRINTING JOB

End if

> 2017/08/15 3:14、Keith Culotta via 4D_Tech <[hidden email]> のメール:
>
> I did not mean to miss your point, but the following does not work when called from within the component either.  The code I uploaded has it outside the print job.  All variations have worked when used in the matrix structure.




**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Listbox Printing

4D Tech mailing list
I see how that works.  What tripped me up initially was discovering what looked like an exception.

Run the app "LBPrint" and you'll see the listbox populates in the printout.
Then run "Host" which has no forms or methods.  It uses LBPrint as a component.  The the listbox does not populate.
In both cases run "aLBPTest" to insure a new process.

I have learned that something about the scope of its variables changes *within* an app when it is run as a component.  I was not aware of this at first.

Here is the latest I tested with in the method printLB:

SET PRINT PREVIEW(True)
If (OK=1)

        OPEN PRINTING JOB
        FORM LOAD("Form1")

        ARRAY LONGINT(aA;0)
        ARRAY TEXT(aB;0)
        For ($i;1;10)
                APPEND TO ARRAY(aA;$i)
                APPEND TO ARRAY(aB;"Text"+String($i))
        End for

        v1:="Test String"

        $all:=Print object(*;"ListBox")
        $all:=Print object(*;"v1")
        CLOSE PRINTING JOB
End if

Thanks,
Keith - CDI

> On Aug 14, 2017, at 5:51 PM, Keisuke Miyako via 4D_Tech <[hidden email]> wrote:
>
> FORM LOAD simply loads the form definition.
> the data source (variables and arrays) are not bound automatically in print.
> you need to populate the objects by their names:
>
> SET PRINT PREVIEW(True)
>
> If (OK=1)
>
> OPEN PRINTING JOB
>
> FORM LOAD("Form1")
>
> $aA:=OBJECT Get pointer(Object named;"Column1")
> $aB:=OBJECT Get pointer(Object named;"Column2")
>
> ARRAY LONGINT($aA->;0)
> ARRAY TEXT($aB->;0)
>
> For ($i;1;10)
> APPEND TO ARRAY($aA->;$i)
> APPEND TO ARRAY($aB->;"Text"+String($i))
> End for
>
> $printed:=Print object(*;"ListBox")
>
> $v1:=OBJECT Get pointer(Object named;"v1")
> $v1->:="Test String"
>
> $printed:=Print object(*;"v1")
>
> CLOSE PRINTING JOB
>
> End if
>
>> 2017/08/15 3:14、Keith Culotta via 4D_Tech <[hidden email]> のメール:
>>
>> I did not mean to miss your point, but the following does not work when called from within the component either.  The code I uploaded has it outside the print job.  All variations have worked when used in the matrix structure.
>

**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Loading...