FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Can TCOMBOBOX with 2 dimension array?
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM

Can TCOMBOBOX with 2 dimension array?

Posted: Wed Jul 22, 2015 12:27 PM

As subject.

Thanks in advance.

Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM

Re: Can TCOMBOBOX with 2 dimension array?

Posted: Wed Jul 22, 2015 01:27 PM
Dutch

I do not think a two dimensional array is possible.. I have worked around this by concantonating two values together into a single text and loaded it to an array ..
Code (fw): Select all Collapse
aEmp := {}

Select 1 // employee
Go Top

Do While .not. eof()
    cText := str(a->EmpNumber,4)+"---"+a->EmpName
    AAdd( aEmp, cText )
    
    select 1
    skip
Enddo


Then if I want to extract ONLY the Employee number I substr it out from the value of cEmp
Code (fw): Select all Collapse
REDEFINE COMBOBOX oEmp  var cEmp    ID 127 of oDlg  ;
              ITEMS aEmp UPDATE

...
...

b->EmpNumber := val(substr( cEmp,1,4))


Rick Lipkin
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM

Re: Can TCOMBOBOX with 2 dimension array?

Posted: Wed Jul 22, 2015 02:37 PM

I'm not sure exactly what you are needing this for, but with DBCombo you can list one value and return another. For instance you can list a description and return an ID number.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM

Re: Can TCOMBOBOX with 2 dimension array?

Posted: Wed Jul 22, 2015 10:47 PM

Dear Rick,

Thanks, it is a good idea for solve the problem.

Dear James,

Yes, exactly I need. Show 1 column (array) return another column as your said. How can I do that?

Thank you so much.

Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM

Re: Can TCOMBOBOX with 2 dimension array?

Posted: Wed Jul 22, 2015 11:45 PM
Dutch,

Below is an example. You will also need the fwh\samples\states.dbf data file.

James

Code (fw): Select all Collapse
/*
Program : DBC1.PRG
Purpose : Test DBCombo
Notes   :
*/

#include "fivewin.ch"
#include "dbcombo.ch"


function main()
   local oDlg, oDBC1, oDBC2, cVar, oCust, cStateID:="  ", oBtn, cState:=""
   local cDept:= space(3), oStates, aItems, aList
   field NAME

   if file("states.dbf")
      use states
      index on upper(NAME) to temp
      database oStates
   else
      msgInfo("File states.dbf not found.")
   endif

   define dialog oDlg

   @ 10,30 dbcombo oDBC1 var cStateID of oDlg;
      alias oStates:cAlias;
      size 100,200 pixel;
      itemfield "CODE" ;
      listfield "NAME";
      ON CHANGE msgbeep();
      update;

   aList:= {"Accounting","HR","Marketing","Production","Research","Shipping","Sales"}
   aItems:= {"100","200","400","300","600","500","700"}

   @ 30,30 DBCOMBO oDBC2 VAR cDept;
      items aItems;
      size 100,200 pixel;
      list aList;
      of oDlg;
      update


   @ 50, 50 button oBtn prompt "Selected";
      of oDlg pixel action (odbc1:Select( 5 ), eval( oDBC1:bChange) ) default
//      action msgInfo( "cStateId: " +cStateID +CRLF+"DeptNo: "+cDept,"Selected" );
//      default

   @ 60,100 button oBtn2 prompt "sdfs" of oDlg action msgInfo( cStateID ) pixel

   activate dialog oDlg center;

   ferase("temp.ntx")

return nil

// EOF
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM

Re: Can TCOMBOBOX with 2 dimension array?

Posted: Wed Jul 22, 2015 11:51 PM

Dutch,

I just noticed you wanted to use a 2-dimensional array. You will need to copy the two columns to single dimensional arrays. Or, you could copy the entire 2-dimensional array into a temp dbf and specify the column names. See another recent thread here about temp DBFs that are all in memory.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM

Re: Can TCOMBOBOX with 2 dimension array?

Posted: Thu Jul 23, 2015 07:30 AM

Dear James,

Thank you, I got it now.

Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)

Continue the discussion