RE: ListBox - assign pulldown array ?? a la ALPro for Data Entry

2018-12-31 Thread Randy Engle via 4D_Tech
Kirk

Happy new year to you!
Thanks for the tips!

Randy Engle

-Original Message-
From: 4D_Tech <4d_tech-boun...@lists.4d.com> On Behalf Of Kirk Brooks via 
4D_Tech
Sent: Monday, December 31, 2018 10:19 AM
To: 4D iNug Technical <4d_tech@lists.4d.com>
Cc: Kirk Brooks 
Subject: Re: ListBox - assign pulldown array ?? a la ALPro for Data Entry

Randy,
Here are a couple of methods that are handy working with almost any type of 
listbox pre collection based ones.

First is my method for getting the column variable pointers. Greatly simplifies 
working with a listbox constructed of dynamic columns. You pass the name of the 
listbox and a pointer to a pointer array. The pointer array is populated with 
the column vars. Sometimes this is easier than screwing around with the 
specific column names to get those pointers. That is useful if you didn't want 
to bother with cogent names for the columns in the first place. If the listbox 
is in a subform you include the subform name as $3.

// Method: Listbox_get_colVarArray (text; pointer{;text}) // $1 is the listbox 
name // $2 is ptr to pointer array // $3 is subform name // Purpose: populate 
$2 with colVar pointers

C_TEXT($1)
C_POINTER($2)
C_TEXT($3)
C_POINTER($ptr)

If (Count parameters=3)
$ptr:=OBJECT Get pointer(Object named;$1;$3) Else $ptr:=OBJECT Get 
pointer(Object named;$1) End if

ARRAY TEXT($arrColNames;0)
ARRAY TEXT($arrHeaderNames;0)
ARRAY POINTER($arrColVars;0)
ARRAY POINTER($arrHeaderVars;0)
ARRAY BOOLEAN($arrColsVisible;0)
ARRAY POINTER($arrStyles;0)

LISTBOX GET
ARRAYS($ptr->;$arrColNames;$arrHeaderNames;$arrColVars;$arrHeaderVars;$arrColsVisible;$arrStyles)
// 
COPY ARRAY($arrColVars;$2->)


Here is an idea I got from seeing ALP code, is really useful and isn't 
supported natively: the selected row index. This dates from v13 and works with 
array and selection based listboxes. Turns out to be a really useful tool.

// Method: Listbox_get_selectionIndex (text; pointer)  -> longint // $1 is the 
name of the listbox // $2 is pointer to longint array // $0 is number 
selections // Purpose: populate longint array with row numbers of selected rows 
// for selection based listboxes array is record number & //  $2{0} is table 
number

C_TEXT($1)
C_POINTER($2;$LBptr)
C_LONGINT($0)
C_LONGINT($i;$tableNum)
C_TEXT($set;$nameSel)
C_POINTER($id_ptr;$table_ptr)

ARRAY LONGINT($aI;0)

$LBptr:=OBJECT Get pointer(Object named;$1)

Case of
: (Nil($LBptr))

: (Type($LBptr->)=Is longint)// selection or named selection
LISTBOX GET TABLE SOURCE(*;$1;$tableNum;$nameSel;$set)
$table_ptr:=Table($tableNum)
$id_ptr:=Table_get_idFieldPtr ($table_ptr)//  method returns pointer to key 
field of a table

Case of
: (Records in set($set)=0)

: ($nameSel#"")
USE SET($set)

If (Nil($id_ptr))// get record numbers
SELECTION TO ARRAY($table_ptr->;$aI)
Else
SELECTION TO ARRAY($id_ptr->;$aI)
End if

Else // avoid clobbering the current selection FIRST RECORD($table_ptr->)

While (Not(End selection($table_ptr->))) Case of
: (Not(Is in set($set)))
: (Nil($id_ptr))// get record numbers
APPEND TO ARRAY($aI;Record number($table_ptr->)) Else APPEND TO 
ARRAY($aI;$id_ptr->) End case

NEXT RECORD($table_ptr->)
End while

End case

$aI{0}:=$tableNum

: (Type($LBptr->)=Boolean array)//  array based LB For ($i;1;Size of 
array($LBptr->)) If ($LBptr->{$i}) APPEND TO ARRAY($aI;$i) End if End for

Else
TRACE
End case

// 
COPY ARRAY($aI;$2->)
$0:=Size of array($aI)

For collection based listboxes there are better ways of managing the listbox 
and the data.


On Sun, Dec 30, 2018 at 3:58 PM Randy Engle via 4D_Tech < 4d_tech@lists.4d.com> 
wrote:

> List has been pretty quiet the last few days.
> Anyone alive out there?
>
> I've been using ALPro vs Listbox exclusively since before Listbox existed.
> As such, I've got extremely limited experience/knowledge of it.
>
> So, I've decided to educate myself so at least I know how to put a 
> LISTBOX together.
>
> There is a command in ALPro that allows assigning a popup/pull-down 
> array to a column, so the user can click the popup and select from 
> some given values for entry into a cell.
>
> e.g.
> associatedMenuPtr:=->at_My_Text_Array
> AL_SetColumnPtrProperty
> ($alpArea;$columnNumber;ALP_Column_PopupArray;$associatedMenuPtr)
>
> I've dug around a lot in LISTBox but have not found a similar 
> method/command
>
> Does it exist?
>
> Many thanks
>
> Randy Engle
>
>
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **



--
Kirk Brooks
San Francisco, CA
===

*We go vote - they go home*

Re: ListBox - assign pulldown array ?? a la ALPro for Data Entry

2018-12-31 Thread Kirk Brooks via 4D_Tech
Randy,
Here are a couple of methods that are handy working with almost any type of
listbox pre collection based ones.

First is my method for getting the column variable pointers. Greatly
simplifies working with a listbox constructed of dynamic columns. You pass
the name of the listbox and a pointer to a pointer array. The pointer array
is populated with the column vars. Sometimes this is easier than screwing
around with the specific column names to get those pointers. That is useful
if you didn't want to bother with cogent names for the columns in the first
place. If the listbox is in a subform you include the subform name as $3.

// Method: Listbox_get_colVarArray (text; pointer{;text})
// $1 is the listbox name
// $2 is ptr to pointer array
// $3 is subform name
// Purpose: populate $2 with colVar pointers

C_TEXT($1)
C_POINTER($2)
C_TEXT($3)
C_POINTER($ptr)

If (Count parameters=3)
$ptr:=OBJECT Get pointer(Object named;$1;$3)
Else
$ptr:=OBJECT Get pointer(Object named;$1)
End if

ARRAY TEXT($arrColNames;0)
ARRAY TEXT($arrHeaderNames;0)
ARRAY POINTER($arrColVars;0)
ARRAY POINTER($arrHeaderVars;0)
ARRAY BOOLEAN($arrColsVisible;0)
ARRAY POINTER($arrStyles;0)

LISTBOX GET
ARRAYS($ptr->;$arrColNames;$arrHeaderNames;$arrColVars;$arrHeaderVars;$arrColsVisible;$arrStyles)
// 
COPY ARRAY($arrColVars;$2->)


Here is an idea I got from seeing ALP code, is really useful and isn't
supported natively: the selected row index. This dates from v13 and works
with array and selection based listboxes. Turns out to be a really useful
tool.

// Method: Listbox_get_selectionIndex (text; pointer)  -> longint
// $1 is the name of the listbox
// $2 is pointer to longint array
// $0 is number selections
// Purpose: populate longint array with row numbers of selected rows
// for selection based listboxes array is record number &
//  $2{0} is table number

C_TEXT($1)
C_POINTER($2;$LBptr)
C_LONGINT($0)
C_LONGINT($i;$tableNum)
C_TEXT($set;$nameSel)
C_POINTER($id_ptr;$table_ptr)

ARRAY LONGINT($aI;0)

$LBptr:=OBJECT Get pointer(Object named;$1)

Case of
: (Nil($LBptr))

: (Type($LBptr->)=Is longint)// selection or named selection
LISTBOX GET TABLE SOURCE(*;$1;$tableNum;$nameSel;$set)
$table_ptr:=Table($tableNum)
$id_ptr:=Table_get_idFieldPtr ($table_ptr)//  method returns pointer to key
field of a table

Case of
: (Records in set($set)=0)

: ($nameSel#"")
USE SET($set)

If (Nil($id_ptr))// get record numbers
SELECTION TO ARRAY($table_ptr->;$aI)
Else
SELECTION TO ARRAY($id_ptr->;$aI)
End if

Else // avoid clobbering the current selection
FIRST RECORD($table_ptr->)

While (Not(End selection($table_ptr->)))
Case of
: (Not(Is in set($set)))
: (Nil($id_ptr))// get record numbers
APPEND TO ARRAY($aI;Record number($table_ptr->))
Else
APPEND TO ARRAY($aI;$id_ptr->)
End case

NEXT RECORD($table_ptr->)
End while

End case

$aI{0}:=$tableNum

: (Type($LBptr->)=Boolean array)//  array based LB
For ($i;1;Size of array($LBptr->))
If ($LBptr->{$i})
APPEND TO ARRAY($aI;$i)
End if
End for

Else
TRACE
End case

// 
COPY ARRAY($aI;$2->)
$0:=Size of array($aI)

For collection based listboxes there are better ways of managing the
listbox and the data.


On Sun, Dec 30, 2018 at 3:58 PM Randy Engle via 4D_Tech <
4d_tech@lists.4d.com> wrote:

> List has been pretty quiet the last few days.
> Anyone alive out there?
>
> I've been using ALPro vs Listbox exclusively since before Listbox existed.
> As such, I've got extremely limited experience/knowledge of it.
>
> So, I've decided to educate myself so at least I know how to put a LISTBOX
> together.
>
> There is a command in ALPro that allows assigning a popup/pull-down array
> to a column, so the user can click the popup and select from some given
> values for entry into a cell.
>
> e.g.
> associatedMenuPtr:=->at_My_Text_Array
> AL_SetColumnPtrProperty
> ($alpArea;$columnNumber;ALP_Column_PopupArray;$associatedMenuPtr)
>
> I've dug around a lot in LISTBox but have not found a similar
> method/command
>
> Does it exist?
>
> Many thanks
>
> Randy Engle
>
>
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **



-- 
Kirk Brooks
San Francisco, CA
===

*We go vote - they go home*
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Write Pro print preview

2018-12-31 Thread David Ringsmuth via 4D_Tech
4D v17 R2 32bit and 64bit
Windows 10 (current)

At first and sometimes while using different features, I get a print preview.

But now I mostly get a Save File dialog when executing WP Print.

$pdfprintername:="Microsoft Print to PDF"
…
SET CURRENT PRINTER($pdfprintername)
SET PRINT OPTION(Destination option;3;$pdfpath)// pdfpath is a valid path to 
the temporary folder and a unique new file name.
SET PRINT PREVIEW(True)
WP USE PAGE SETUP($WP_Area_ob)
WP PRINT($WP_Area_ob;wk html wysiwyg)

Amazingly when using the library toolbar for WP, there is a “Print Preview” 
button with a “Standard Action” of “Print” that does a print preview. So the 
form’s sub-form standard action of “print” does a print preview? Yup.

I need it to always work correctly.

Please help!

Thanks!

David Ringsmuth

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

RE: Write Pro print preview

2018-12-31 Thread David Ringsmuth via 4D_Tech
SET PRINT OPTION(Destination option;2;$pdfpath)

“2” seems to do a print preview.



David Ringsmuth

From: David Ringsmuth
Sent: Monday, December 31, 2018 9:32 AM
To: 4D iNug Technical
Subject: Write Pro print preview

4D v17 R2 32bit and 64bit
Windows 10 (current)

At first and sometimes while using different features, I get a print preview.

But now I mostly get a Save File dialog when executing WP Print.

$pdfprintername:="Microsoft Print to PDF"
…
SET CURRENT PRINTER($pdfprintername)
SET PRINT OPTION(Destination option;3;$pdfpath)// pdfpath is a valid path to 
the temporary folder and a unique new file name.
SET PRINT PREVIEW(True)
WP USE PAGE SETUP($WP_Area_ob)
WP PRINT($WP_Area_ob;wk html wysiwyg)

Amazingly when using the library toolbar for WP, there is a “Print Preview” 
button with a “Standard Action” of “Print” that does a print preview. So the 
form’s sub-form standard action of “print” does a print preview? Yup.

I need it to always work correctly.

Please help!

Thanks!

David Ringsmuth


**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

detecting APPLY TO SELECTION

2018-12-31 Thread Alan Tilson via 4D_Tech
Happy New Year's Eve!

Is there a way to tell if code is running within APPLY TO SELECTION? I have
code that can run one record at a time and can also be applied a selection
of records. And in some cases when run one at a time there is an Alert or
Confirmation or Request for input, all of which cause an error if executed
within ATS.

Is there a way to avoid this?

I use ATS 550 times in our system, so wrapping it would be a big job...

Thanks,
Alan
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**