Combobox on multidimensional array

Post Reply
User avatar
Marco Turco
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London
Contact:

Combobox on multidimensional array

Post by Marco Turco »

Hi all,
I have a multidimensional array like:

aArray:=array(0,2)
aadd(1,"Marc")
aadd(2,"Luca")
aadd(3,"Jannette")
aadd(4,"Francis")

and I would make a combobox with only the second element list (the names).

Is there a quick way to make this directly into the REDEFINE COMBOBOX command line ?

Thank you in advance
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Antonio Linares
Site Admin
Posts: 42520
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Re: Combobox on multidimensional array

Post by Antonio Linares »

Marco,

Code: Select all | Expand

#include "FiveWin.ch"

function Main()

   local aArray := {}
   local oDlg, cName := "Marc"

   AAdd( aArray, { 1, "Marc" } )
   AAdd( aArray, { 2, "Luca" } )
   AAdd( aArray, { 3, "Jannette" } )
   AAdd( aArray, { 4, "Francis" } )

   DEFINE DIALOG oDlg

   @ 1, 1 COMBOBOX cName ITEMS ArrTranspose( aArray )[ 2 ]

   ACTIVATE DIALOG oDlg CENTERED

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Marco Turco
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London
Contact:

Re: Combobox on multidimensional array

Post by Marco Turco »

Hi Antonio,
it runs. Thank you.

I have just a problem trying to use the ArrTranspose() into the command syntax,
essentially I have to replace the <aItems> with ArrTranspose(<aItems>)[2] but it doesn't runs, sure for a syntax problem. Any ideas ?
Thank you.


#xcommand REDEFINE COMBOLIST [ <oCbx> VAR ] <cVar> ;
[ <items: PROMPTS, ITEMS> <aItems> ] ;
[ ID <nId> ] ;
[ <dlg:OF,WINDOW,DIALOG> <oWnd> ] ;
[ <help:HELPID, HELP ID> <nHelpId> ] ;
[ ON CHANGE <uChange> ] ;
[ VALID <uValid> ] ;
[ <color: COLOR,COLORS> <nClrText> [,<nClrBack>] ] ;
[ <update: UPDATE> ] ;
[ MESSAGE <cMsg> ] ;
[ WHEN <uWhen> ] ;
[ BITMAPS <acBitmaps> ] ;
[ ON DRAWITEM <uBmpSelect> ] ;
[ STYLE <nStyle> ] ;
[ <pict: PICT, PICTURE> <cPicture> ];
[ ON EDIT CHANGE <uEChange> ] ;
=> ;
[ <oCbx> := ] TComboBox():ReDefine( <nId>, bSETGET(<cVar>),;
ArrTranspose(<aItems>)[2], <oWnd>, <nHelpId>, <{uValid}>, [{|Self|<uChange>}],;
<nClrText>, <nClrBack>, <cMsg>, <.update.>, <{uWhen}>,;
<acBitmaps>, [{|nItem|<uBmpSelect>}], <nStyle>, <cPicture>,;
[<{uEChange}>] )
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Antonio Linares
Site Admin
Posts: 42520
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Re: Combobox on multidimensional array

Post by Antonio Linares »

Marco,

Please try this:

ArrTranspose(<aItems>)\[2\]
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Marco Turco
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London
Contact:

Re: Combobox on multidimensional array

Post by Marco Turco »

Great !! Thank you Antonio.
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
cnavarro
Posts: 6557
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

Re: Combobox on multidimensional array

Post by cnavarro »

Marco
I think the solution is:

viewtopic.php?f=3&t=25496&start=0&hilit=arrtranspose

:D :D :D

Sorry,
It's a joke
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Post Reply