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

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

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

4D Tech mailing list
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:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

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

4D Tech mailing list
Thanks to anyone that read my post.

I think I found what I was looking for.

Happy New Year!

Randy Engle

-----Original Message-----
From: 4D_Tech <[hidden email]> On Behalf Of Randy Engle via 4D_Tech
Sent: Sunday, December 30, 2018 3:58 PM
To: '4D iNug Technical' <[hidden email]>
Cc: Randy Engle <[hidden email]>
Subject: ListBox - assign pulldown array ?? a la ALPro for Data Entry

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:[hidden email]
**********************************************************************

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

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

4D Tech mailing list
In reply to this post by 4D Tech mailing list
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 <
[hidden email]> 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:[hidden email]
> **********************************************************************



--
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:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

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

4D Tech mailing list
Kirk

Happy new year to you!
Thanks for the tips!

Randy Engle

-----Original Message-----
From: 4D_Tech <[hidden email]> On Behalf Of Kirk Brooks via 4D_Tech
Sent: Monday, December 31, 2018 10:19 AM
To: 4D iNug Technical <[hidden email]>
Cc: Kirk Brooks <[hidden email]>
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 < [hidden email]> 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:[hidden email]
> **********************************************************************



--
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:[hidden email]
**********************************************************************

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

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

4D Tech mailing list
In reply to this post by 4D Tech mailing list
Wow that's a lot of code to replace a single AreaList Pro line :-)

Happy new year to all!

Best regards,
--
Phil


> On 31 Dec 2018, at 19:19, Kirk Brooks via 4D_Tech <[hidden email]> wrote:
>
> 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 <
> [hidden email]> 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:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

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

4D Tech mailing list
the original post specified v13, which restricts options.

v14 has OBJECT SET LIST BY REFERENCE which makes life a lot easier.

http://doc.4d.com/4Dv16/4D/16.4/OBJECT-SET-LIST-BY-REFERENCE.301-3978434.en.html

c.f. http://forums.4d.com/Post/FR/27013321/1/27039356#27039356

2019/01/02 20:49、Philippe Ganter via 4D_Tech <[hidden email]<mailto:[hidden email]>>のメール:
Wow that's a lot of code to replace a single AreaList Pro line :-)



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