Re: Listbox Printing

2017-08-15 Thread Keith Culotta via 4D_Tech
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 
> <4d_tech@lists.4d.com> 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 <4d_tech@lists.4d.com> のメール:
>> 
>> 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:4d_tech-unsubscr...@lists.4d.com
**

Re: Listbox Printing

2017-08-14 Thread Keisuke Miyako via 4D_Tech
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 <4d_tech@lists.4d.com> のメール:
>
> 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:4d_tech-unsubscr...@lists.4d.com
**

Re: Listbox Printing

2017-08-14 Thread Keith Culotta via 4D_Tech
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 
> <4d_tech@lists.4d.com> 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 <4d_tech@lists.4d.com> のメール:
>> 
>> 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:4d_tech-unsubscr...@lists.4d.com
> **

**
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:4d_tech-unsubscr...@lists.4d.com
**

Re: Listbox Printing

2017-08-14 Thread Keith Culotta via 4D_Tech
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   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 
> <4d_tech@lists.4d.com> 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 <4d_tech@lists.4d.com> のメール:
>> 
>> 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:4d_tech-unsubscr...@lists.4d.com
> **

**
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:4d_tech-unsubscr...@lists.4d.com
**

Re: Listbox Printing

2017-08-14 Thread Keisuke Miyako via 4D_Tech
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 <4d_tech@lists.4d.com> のメール:
>
> 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:4d_tech-unsubscr...@lists.4d.com
**

Re: Listbox Printing

2017-08-14 Thread Keith Culotta via 4D_Tech
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 
> <4d_tech@lists.4d.com> wrote:
> 
> have you tried using the object name instead ?
> 
>> 2017/08/13 5:46、Keith Culotta via 4D_Tech <4d_tech@lists.4d.com> のメール:
>> $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:4d_tech-unsubscr...@lists.4d.com
> **

**
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:4d_tech-unsubscr...@lists.4d.com
**

Re: Listbox Printing

2017-08-13 Thread Keisuke Miyako via 4D_Tech
have you tried using the object name instead ?

> 2017/08/13 5:46、Keith Culotta via 4D_Tech <4d_tech@lists.4d.com> のメール:
> $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:4d_tech-unsubscr...@lists.4d.com
**

Re: Listbox Printing

2017-08-13 Thread Arnaud de Montard via 4D_Tech

> Le 12 août 2017 à 22:46, Keith Culotta via 4D_Tech <4d_tech@lists.4d.com> 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:

"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:4d_tech-unsubscr...@lists.4d.com
**

Re: Listbox Printing

2017-08-12 Thread Keith Culotta via 4D_Tech
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 
> <4d_tech@lists.4d.com> 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 <4d_tech@lists.4d.com> のメール:
>> 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:4d_tech-unsubscr...@lists.4d.com
**

Re: Listbox Printing

2017-08-02 Thread Keisuke Miyako via 4D_Tech
https://github.com/miyako/4d-tips-print-form-print-object-combo

2017/08/03 12:34、miyako > 
のメール:
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:4d_tech-unsubscr...@lists.4d.com
**

Re: Listbox Printing

2017-08-02 Thread James Crate via 4D_Tech
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 <4d_tech@lists.4d.com> 
> 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 <4d_tech@lists.4d.com> のメール:
>> 
>> 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:4d_tech-unsubscr...@lists.4d.com
> **

**
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:4d_tech-unsubscr...@lists.4d.com
**

Re: Listbox Printing

2017-08-02 Thread John Baughman via 4D_Tech

**
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:4d_tech-unsubscr...@lists.4d.com
**

Re: Listbox Printing

2017-08-02 Thread Keisuke Miyako via 4D_Tech
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 <4d_tech@lists.4d.com> のメール:
>
> 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:4d_tech-unsubscr...@lists.4d.com
**

Re: Listbox Printing

2017-08-02 Thread Nigel Greenlee via 4D_Tech
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;0xFF00)

QR SET TEXT 
PROPERTY($QRarea;$ColumnNumber;qr detail;_O_qr font;_o_Font number(<>FontPlain))