Multiple Dimension Array in Combobox
- cdmmaui
- Posts: 653
- Joined: Fri Oct 28, 2005 9:53 am
- Location: The Woodlands - Dallas - Scottsdale - London
- Contact:
Multiple Dimension Array in Combobox
Hello Everyone,
Happy Friday!
Is it possible to use a multiple dimension array in a COMBOBOX where one array element is the selected item and another array element is the display item in the COMBOBOX. I believe it would be similar to DBCOMBO.
If possible, can someone please provide an example?
Thank you,
Happy Friday!
Is it possible to use a multiple dimension array in a COMBOBOX where one array element is the selected item and another array element is the display item in the COMBOBOX. I believe it would be similar to DBCOMBO.
If possible, can someone please provide an example?
Thank you,
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Multiple Dimension Array in Combobox
We can use multi-dimensional array in DBCOMBO.
Example
@ r,c DBCOMBO <clauses> ALIAS <array> ITEMFIELD "1" LISTFIELD "2"
Example
@ r,c DBCOMBO <clauses> ALIAS <array> ITEMFIELD "1" LISTFIELD "2"
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- cdmmaui
- Posts: 653
- Joined: Fri Oct 28, 2005 9:53 am
- Location: The Woodlands - Dallas - Scottsdale - London
- Contact:
Re: Multiple Dimension Array in Combobox
Hi Rao,
Redefine works the same as well, correct?
Redefine works the same as well, correct?
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
- cdmmaui
- Posts: 653
- Joined: Fri Oct 28, 2005 9:53 am
- Location: The Woodlands - Dallas - Scottsdale - London
- Contact:
Re: Multiple Dimension Array in Combobox
Dear Rao,
I am loading data in to an array with the SQLLOAD below, however I am getting the following error message, source code below the error message.
// ERROR MESSAGE------------------------------------------------------------------
Application
===========
Path and name: C:\winapps\ual\ualdash.exe (32 bits)
Size: 3,873,280 bytes
Compiler version: Harbour 3.2.0dev (r1801051438)
FiveWin version: FWH 18.02
C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
Windows version: 6.2, Build 9200
Time from start: 0 hours 0 mins 3 secs
Error occurred at: 05/26/2018, 11:52:55
Error description: Error BASE/1068 Argument error: array access
Args:
[ 1] = C
[ 2] = N 1
Stack Calls
===========
Called from: .\source\classes\DBCOMBO.PRG => TDBCOMBO:FILL( 508 )
Called from: .\source\classes\DBCOMBO.PRG => TDBCOMBO:REDEFINE( 174 )
Called from: ualdash.prg => EDITBILL( 363 )
Called from: ualdash.prg => (b)MAIN( 105 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:CLICK( 693 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:LBUTTONUP( 944 )
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1721 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:HANDLEEVENT( 1909 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3368 )
Called from: => WINRUN( 0 )
Called from: .\source\classes\WINDOW.PRG => TWINDOW:ACTIVATE( 1043 )
Called from: ualdash.prg => MAIN( 158 )
// Code
REDEFINE DBCOMBO aGet[07] VAR nVessel ID 4007 OF oDlg ALIAS aVessel ITEMFIELD "1" LISTFIELD "2"
//-----------------------------------------------------------------------------
FUNCTION _SqlLoad( cSqlTable )
local oSqlLoad, cSqlLoad := "", aReturn := {}, cDat1 := "", cDat2 := "", cDat3 := "", cToday := "", cYr, cMon, cDay
IF PCOUNT()<1
cSqlTable := ""
ENDIF
AADD( aReturn, "" )
IF EMPTY(cSqlTable)
RETURN aReturn
ENDIF
cSqlTable := UPPER( cSqlTable )
TRY
oSqlLoad:=TOleAuto():New("ADODB.Recordset")
CATCH
MsgWait( "Unable to Load SQL Driver", Ptitle )
RETURN (.F.)
END
// Set...
oSqlLoad:CursorType := 1 // opendkeyset
oSqlLoad:CursorLocation := 3 // local cache
oSqlLoad:LockType := 3 // lock opportunistic
// Set SQL string...
cSqlLoad := "SELECT * FROM vessels WHERE Active=1 ORDER BY [DateCreated] DESC"
TRY
oSqlLoad:Open( cSqlLoad, 'Provider='+xPROVIDER+';Data Source='+xSOURCE+';Initial Catalog='+xDATABASE+';User Id='+xUSERID+';Password='+xPASSWORD )
CATCH oError
MsgInfo("Failed to Connect to the Database" + cEol + cSqlLoad + cEol + oError:Description, Ptitle )
RETURN .F.
END
DO WHILE (! oSqlLoad:BOF) .AND. (! oSqlLoad:EOF)
cDat1 := oSqlLoad:Fields( "id" ):Value
cDat2 := oSqlLoad:Fields( "Vessel Name" ):Value
cDat3 := oSqlLoad:Fields( "Voyage CSA" ):Value
IF (VALTYPE(cDat1)<>"U") .AND. (VALTYPE(cDat2)<>"U") .AND. (VALTYPE(cDat3)<>"U")
AADD( aReturn, { cDat1, ALLTRIM(cDat2) + " V." + ALLTRIM(cDat3) } )
ENDIF
oSqlLoad:Move( 1 )
ENDDO
oSqlLoad:Close()
oSqlLoad:=NIL
RETURN (aReturn)
I am loading data in to an array with the SQLLOAD below, however I am getting the following error message, source code below the error message.
// ERROR MESSAGE------------------------------------------------------------------
Application
===========
Path and name: C:\winapps\ual\ualdash.exe (32 bits)
Size: 3,873,280 bytes
Compiler version: Harbour 3.2.0dev (r1801051438)
FiveWin version: FWH 18.02
C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
Windows version: 6.2, Build 9200
Time from start: 0 hours 0 mins 3 secs
Error occurred at: 05/26/2018, 11:52:55
Error description: Error BASE/1068 Argument error: array access
Args:
[ 1] = C
[ 2] = N 1
Stack Calls
===========
Called from: .\source\classes\DBCOMBO.PRG => TDBCOMBO:FILL( 508 )
Called from: .\source\classes\DBCOMBO.PRG => TDBCOMBO:REDEFINE( 174 )
Called from: ualdash.prg => EDITBILL( 363 )
Called from: ualdash.prg => (b)MAIN( 105 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:CLICK( 693 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:LBUTTONUP( 944 )
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1721 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:HANDLEEVENT( 1909 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3368 )
Called from: => WINRUN( 0 )
Called from: .\source\classes\WINDOW.PRG => TWINDOW:ACTIVATE( 1043 )
Called from: ualdash.prg => MAIN( 158 )
// Code
REDEFINE DBCOMBO aGet[07] VAR nVessel ID 4007 OF oDlg ALIAS aVessel ITEMFIELD "1" LISTFIELD "2"
//-----------------------------------------------------------------------------
FUNCTION _SqlLoad( cSqlTable )
local oSqlLoad, cSqlLoad := "", aReturn := {}, cDat1 := "", cDat2 := "", cDat3 := "", cToday := "", cYr, cMon, cDay
IF PCOUNT()<1
cSqlTable := ""
ENDIF
AADD( aReturn, "" )
IF EMPTY(cSqlTable)
RETURN aReturn
ENDIF
cSqlTable := UPPER( cSqlTable )
TRY
oSqlLoad:=TOleAuto():New("ADODB.Recordset")
CATCH
MsgWait( "Unable to Load SQL Driver", Ptitle )
RETURN (.F.)
END
// Set...
oSqlLoad:CursorType := 1 // opendkeyset
oSqlLoad:CursorLocation := 3 // local cache
oSqlLoad:LockType := 3 // lock opportunistic
// Set SQL string...
cSqlLoad := "SELECT * FROM vessels WHERE Active=1 ORDER BY [DateCreated] DESC"
TRY
oSqlLoad:Open( cSqlLoad, 'Provider='+xPROVIDER+';Data Source='+xSOURCE+';Initial Catalog='+xDATABASE+';User Id='+xUSERID+';Password='+xPASSWORD )
CATCH oError
MsgInfo("Failed to Connect to the Database" + cEol + cSqlLoad + cEol + oError:Description, Ptitle )
RETURN .F.
END
DO WHILE (! oSqlLoad:BOF) .AND. (! oSqlLoad:EOF)
cDat1 := oSqlLoad:Fields( "id" ):Value
cDat2 := oSqlLoad:Fields( "Vessel Name" ):Value
cDat3 := oSqlLoad:Fields( "Voyage CSA" ):Value
IF (VALTYPE(cDat1)<>"U") .AND. (VALTYPE(cDat2)<>"U") .AND. (VALTYPE(cDat3)<>"U")
AADD( aReturn, { cDat1, ALLTRIM(cDat2) + " V." + ALLTRIM(cDat3) } )
ENDIF
oSqlLoad:Move( 1 )
ENDDO
oSqlLoad:Close()
oSqlLoad:=NIL
RETURN (aReturn)
- cdmmaui
- Posts: 653
- Joined: Fri Oct 28, 2005 9:53 am
- Location: The Woodlands - Dallas - Scottsdale - London
- Contact:
Re: Multiple Dimension Array in Combobox
Rao,
Also, here is the resource code. Should that change? I could not find DBCOMBO in samples that uses RC file
CONTROL "", 4007, "ComboBox", WS_BORDER|CBS_DROPDOWNLIST|CBS_SORT|WS_VSCROLL|WS_TABSTOP, 425, 10, 225, 100
Also, here is the resource code. Should that change? I could not find DBCOMBO in samples that uses RC file
CONTROL "", 4007, "ComboBox", WS_BORDER|CBS_DROPDOWNLIST|CBS_SORT|WS_VSCROLL|WS_TABSTOP, 425, 10, 225, 100
- joseluisysturiz
- Posts: 2024
- Joined: Fri Jan 06, 2006 9:28 pm
- Location: Guatire - Caracas - Venezuela
- Contact:
Re: Multiple Dimension Array in Combobox
Saludos, debes estar pendiente que DBCOMBO no admite valores numericos, debes convertirnos a STRING, a menos que esto lo hayan arreglado...gracias, saludos...cdmmaui wrote:Dear Rao,
I am loading data in to an array with the SQLLOAD below, however I am getting the following error message, source code below the error message.
// ERROR MESSAGE------------------------------------------------------------------
Application
===========
Path and name: C:\winapps\ual\ualdash.exe (32 bits)
Size: 3,873,280 bytes
Compiler version: Harbour 3.2.0dev (r1801051438)
FiveWin version: FWH 18.02
C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
Windows version: 6.2, Build 9200
Time from start: 0 hours 0 mins 3 secs
Error occurred at: 05/26/2018, 11:52:55
Error description: Error BASE/1068 Argument error: array access
Args:
[ 1] = C
[ 2] = N 1
Stack Calls
===========
Called from: .\source\classes\DBCOMBO.PRG => TDBCOMBO:FILL( 508 )
Called from: .\source\classes\DBCOMBO.PRG => TDBCOMBO:REDEFINE( 174 )
Called from: ualdash.prg => EDITBILL( 363 )
Called from: ualdash.prg => (b)MAIN( 105 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:CLICK( 693 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:LBUTTONUP( 944 )
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1721 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:HANDLEEVENT( 1909 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3368 )
Called from: => WINRUN( 0 )
Called from: .\source\classes\WINDOW.PRG => TWINDOW:ACTIVATE( 1043 )
Called from: ualdash.prg => MAIN( 158 )
// Code
REDEFINE DBCOMBO aGet[07] VAR nVessel ID 4007 OF oDlg ALIAS aVessel ITEMFIELD "1" LISTFIELD "2"
//-----------------------------------------------------------------------------
FUNCTION _SqlLoad( cSqlTable )
local oSqlLoad, cSqlLoad := "", aReturn := {}, cDat1 := "", cDat2 := "", cDat3 := "", cToday := "", cYr, cMon, cDay
IF PCOUNT()<1
cSqlTable := ""
ENDIF
AADD( aReturn, "" )
IF EMPTY(cSqlTable)
RETURN aReturn
ENDIF
cSqlTable := UPPER( cSqlTable )
TRY
oSqlLoad:=TOleAuto():New("ADODB.Recordset")
CATCH
MsgWait( "Unable to Load SQL Driver", Ptitle )
RETURN (.F.)
END
// Set...
oSqlLoad:CursorType := 1 // opendkeyset
oSqlLoad:CursorLocation := 3 // local cache
oSqlLoad:LockType := 3 // lock opportunistic
// Set SQL string...
cSqlLoad := "SELECT * FROM vessels WHERE Active=1 ORDER BY [DateCreated] DESC"
TRY
oSqlLoad:Open( cSqlLoad, 'Provider='+xPROVIDER+';Data Source='+xSOURCE+';Initial Catalog='+xDATABASE+';User Id='+xUSERID+';Password='+xPASSWORD )
CATCH oError
MsgInfo("Failed to Connect to the Database" + cEol + cSqlLoad + cEol + oError:Description, Ptitle )
RETURN .F.
END
DO WHILE (! oSqlLoad:BOF) .AND. (! oSqlLoad:EOF)
cDat1 := oSqlLoad:Fields( "id" ):Value
cDat2 := oSqlLoad:Fields( "Vessel Name" ):Value
cDat3 := oSqlLoad:Fields( "Voyage CSA" ):Value
IF (VALTYPE(cDat1)<>"U") .AND. (VALTYPE(cDat2)<>"U") .AND. (VALTYPE(cDat3)<>"U")
AADD( aReturn, { cDat1, ALLTRIM(cDat2) + " V." + ALLTRIM(cDat3) } )
ENDIF
oSqlLoad:Move( 1 )
ENDDO
oSqlLoad:Close()
oSqlLoad:=NIL
RETURN (aReturn)
Dios no está muerto...
Gracias a mi Dios ante todo!
Gracias a mi Dios ante todo!
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Multiple Dimension Array in Combobox
This error means that the first element of aVessal is a empty character string, where as it should be an array.Error description: Error BASE/1068 Argument error: array access
Args:
[ 1] = C
[ 2] = N 1
Stack Calls
===========
Called from: .\source\classes\DBCOMBO.PRG => TDBCOMBO:FILL( 508 )
Please check again.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Multiple Dimension Array in Combobox
From version FWH 1804, item values can be numeric also ( any datatype )
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- joseluisysturiz
- Posts: 2024
- Joined: Fri Jan 06, 2006 9:28 pm
- Location: Guatire - Caracas - Venezuela
- Contact:
Re: Multiple Dimension Array in Combobox
Ok, gracias por la informacion, pero igual no tengo esa version...algun dia...jejeje...saludos...gracias...nageswaragunupudi wrote:From version FWH 1804, item values can be numeric also ( any datatype )
Dios no está muerto...
Gracias a mi Dios ante todo!
Gracias a mi Dios ante todo!
Re: Multiple Dimension Array in Combobox
I would like to revisit this thread.
For the code:
REDEFINE DBCOMBO oCbxA54 VAR oEditWork:oWorkPartsr:paruf2 ALIAS a Src ITEMFIELD "1" LISTFIELD "2" ;
ID 2504 OF oEditWork:oFld:aDialogs[2] UPDATE
and the Resource:
COMBOBOX. 2504, 395, 65, 25, 60, CBS_DROPDOWN | WS_BORDER | WS_VSCROLL | WS_TABSTOP
Using a two element array where 1 is a single character field, and 2 is a longer description.
When running, the field displays, and returns, only the values of LISTFIELD "2" and does not set the proper width for that display.
What is wrong with this code ? I have not been using the DBCOMBO previously.
For the code:
REDEFINE DBCOMBO oCbxA54 VAR oEditWork:oWorkPartsr:paruf2 ALIAS a Src ITEMFIELD "1" LISTFIELD "2" ;
ID 2504 OF oEditWork:oFld:aDialogs[2] UPDATE
and the Resource:
COMBOBOX. 2504, 395, 65, 25, 60, CBS_DROPDOWN | WS_BORDER | WS_VSCROLL | WS_TABSTOP
Using a two element array where 1 is a single character field, and 2 is a longer description.
When running, the field displays, and returns, only the values of LISTFIELD "2" and does not set the proper width for that display.
What is wrong with this code ? I have not been using the DBCOMBO previously.
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
- Silvio.Falconi
- Posts: 4956
- Joined: Thu Oct 18, 2012 7:17 pm
Re: Multiple Dimension Array in Combobox
use an array and combobox instead of dbcombo
@ 36,75 COMBOBOX cFilter ITEMS ArrTranspose( aListini )[ 2] SIZE 120,400 PIXEL OF oInfoTariffe;
ON CHANGE
@ 36,75 COMBOBOX cFilter ITEMS ArrTranspose( aListini )[ 2] SIZE 120,400 PIXEL OF oInfoTariffe;
ON CHANGE
Last edited by Silvio.Falconi on Wed Aug 28, 2019 7:56 pm, edited 1 time in total.
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
Re: Multiple Dimension Array in Combobox
I use RESOURCES ( .rc file ). Thus @ x,y does not work ...
I did try using arrTranspose() and COMBOBOX, and the drop down display does show the 2nd element. However, I need it to return the 1st element to the actual field for saving.
Again, the objective is to display the 2nd element of the array in the drop down, but to return the value of the 1st element to the field being edited by the combobox.
Thanks.
I did try using arrTranspose() and COMBOBOX, and the drop down display does show the 2nd element. However, I need it to return the 1st element to the actual field for saving.
Again, the objective is to display the 2nd element of the array in the drop down, but to return the value of the 1st element to the field being edited by the combobox.
Thanks.
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
- Silvio.Falconi
- Posts: 4956
- Joined: Thu Oct 18, 2012 7:17 pm
Re: Multiple Dimension Array in Combobox
Dear Timm
run also with resources rc!!!!
aListini := Crea_Listini()
the array must not as { "One", "Two", "Three" } but two elements
sample
DEFINE DIALOG oDlg RESOURCE "Combos" BRUSH oBrush TRANSPARENT
REDEFINE COMBOBOX oCbx1 VAR cItem1 ITEMS ArrTranspose( aListini )[ 2] //I wish show trim(oListini:id)
ID 100 OF oDlg;
ON CHANGE Msginfo()
ACTIVATE DIALOG oDlg CENTERED
return nil
Dear Timm
> I need it to return the 1st element to the actual field for saving.
you always told me in the e-mails you sent me that you have been an experienced programmer for 40 years
and you tell me that if you use ArrTranspose () then you can't save because you need the first element ... are you kidding?
We Know the combobox returns a selection number oCbx1: nat
then to save the first element take the array alistini and taking the first element
aListini [oCbx1: nat] [1] ...
it was easy ...
so I know that you wanted joke with me .... to know that I was able,
But the programmer are you instead !!!!
run also with resources rc!!!!
aListini := Crea_Listini()
the array must not as { "One", "Two", "Three" } but two elements
sample
Code: Select all
Function Crea_Listini()
local oListini
Local alist_temp:={}
local nArea := Select()
// create a array of all price list
oListini:= TListini():new()
oListini:gotop()
DO While !oListini:eof()
AaDd(alist_temp,{ oListini:name,trim(oListini:id) })
oListini:skip()
ENDDO
oListini:close()
Select (nArea)
return alist_temp
REDEFINE COMBOBOX oCbx1 VAR cItem1 ITEMS ArrTranspose( aListini )[ 2] //I wish show trim(oListini:id)
ID 100 OF oDlg;
ON CHANGE Msginfo()
ACTIVATE DIALOG oDlg CENTERED
return nil
Dear Timm
> I need it to return the 1st element to the actual field for saving.
you always told me in the e-mails you sent me that you have been an experienced programmer for 40 years
and you tell me that if you use ArrTranspose () then you can't save because you need the first element ... are you kidding?
We Know the combobox returns a selection number oCbx1: nat
then to save the first element take the array alistini and taking the first element
aListini [oCbx1: nat] [1] ...
it was easy ...
so I know that you wanted joke with me .... to know that I was able,
But the programmer are you instead !!!!
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC