FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour xBrowse one dimensional array
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
xBrowse one dimensional array
Posted: Mon Jun 23, 2008 03:21 PM

Does xBrowse work on a one dimensional array.

Regards,
Otto

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
xBrowse one dimensional array
Posted: Mon Jun 23, 2008 03:42 PM

No :(
Wish it works. Right ?

Regards



G. N. Rao.

Hyderabad, India
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
xBrowse one dimensional array
Posted: Mon Jun 23, 2008 04:20 PM

Hello NageswaraRao,

Thank you.
I tested the printer code from Richard and wanted to show the result in a Xbrowse.

http://forums.fivetechsoft.com/viewtopic.php?t=11640

But it didn’t work. I added a extra field and then all was ok.
Regards,
Otto

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
xBrowse one dimensional array
Posted: Mon Jun 23, 2008 05:03 PM
Mr Otto

I am extremely sorry for my hasty comment. Single dimentional arrays can be browsed like this.


#include "fivewin.ch"
#include "xbrowse.ch"

function Main()

   local oWnd, oBrw
   local aList := { "One..", "Two..", "Three", "Four.", "Five." }

   DEFINE WINDOW oWnd

   @ 0,0 XBROWSE oBrw ARRAY aList OF oWnd

   ADD TO oBrw DATA oBrw:aRow HEADER 'Item'

   oBrw:CreateFromCode()
   oWnd:oClient := oBrw

   ACTIVATE WINDOW oWnd

return nil

/*
   otherways of writing the above code.

   ADD TO oBrw DATA aList[ oBrw:nArrayAt ] HEADER "item"

   or

   oCol := oBrw:AddCol()
   oCol:bStrData := { || aList[ oBrw:nArrayAt ] }

   But I prefer to write the shortest code as above. XBrowse pampers my laziness.

*/
Regards



G. N. Rao.

Hyderabad, India
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
xBrowse one dimensional array
Posted: Mon Jun 23, 2008 06:30 PM

Hello NageswaraRao,

thank you for your help.

The dBase syntax is working perfectly but trying the other two ways you suggested I get an error.
ADDCOL no method ( I am not sure but I think I am still on FW 8.02)

And the first test errors out with argument error Len from errorsys, line 0.

Would you please be so kind to help me.
Thanks in advance
Otto

STATIC FUNCTION ShowPrinters( oWnd )
local oChild, oBrw, oCol
local ADEVICES := {}
local aStruc:={}

ADEVICES := GETIMPRI(ADEVICES)

DEFINE WINDOW oChild TITLE "DBF structrure without record selector" MDICHILD OF oWnd

oBrw := TXBrowse():New( oChild )
oBrw:SetArray( ADEVICES)
ADD TO oBrw DATA ADEVICES[ oBrw:nArrayAt ] HEADER "item"

// oCol := oBrw:AddCol()
// oCol:bStrData := { || ADEVICES[ oBrw:nArrayAt ] }

// @ 0,0 XBROWSE oBrw ARRAY ADEVICES OF oChild
// ADD TO oBrw DATA oBrw:aRow HEADER 'Item'

oBrw:CreateFromCode()
oChild:oClient := oBrw

ACTIVATE WINDOW oChild ON INIT oBrw:SetFocus()

RETURN NIL

//----------------------------------------------------------------------------//

FUNCTION GETIMPRI(ADEVICES)
*----------------------------------------
LOCAl cAllEntries, cEntry, I, cName, cPrn, cPort, J

cAllEntries := STRTRAN( GetProfString( "Devices" ), Chr( 0 ), CRLF )
FOR I:= 1 TO MlCount( cAllEntries )
cName := MemoLine( cAllEntries,,I)
cEntry := GetProfString( "Devices",cName,"")
J := 2
WHILE ! EMPTY(cPort := StrToken(cEntry,J++,","))
// AADD(aDevices,TRIM(cName))
AADD(aDevices,TRIM(cName) + "," + CENTRY ) // CHIDIAK
ENDDO
NEXT
RETURN aDevices

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
xBrowse one dimensional array
Posted: Tue Jun 24, 2008 09:55 AM

Mr Otto

>
oCol := oBrw:AddCol()
oCol:bStrData := { || ADEVICES[ oBrw:nArrayAt ] }
>

This syntax should work even with the oldest version of XBrowse. I can't think of any reason why it should not work for you. Will you please try again ?

I personally suggest you to use the latest version 8.05. Do you have any techinical problems in upgrading to 8.05 ?

Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
xBrowse one dimensional array
Posted: Sat Jun 28, 2008 01:54 PM
Mr Otto

I checked up the source code of xbrowse in 8.02.
If you are using this version, please make the following change in the orginal XBrowse.Prg
METHOD SetArray( ........... )

<< FWH code >>


   ::aCols := {}    // after this is FWH code
 
   if ValType( aData[ 1 ] ) == 'A'   // insert this line here

   // fwh code  continues
   for nFor := 1 to len( aData[ 1 ] )
      oCol := ::AddCol()
      
      << FWH code >>

   next
  // after this FWH code,
   endif // insert this line here
  << fwh code continues >>


After making this change, you can now use it for single dimentional array.
oBrw  := TXBrowse():New( oChild )
oBrw:SetArray( ADEVICES )
oCol := oBrw:AddCol() 
oCol:bStrData := { || ADEVICES[ oBrw:nArrayAt ] }


Hope this works for you, if you are using version 8.02
Regards



G. N. Rao.

Hyderabad, India
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
xBrowse one dimensional array
Posted: Sun Jun 29, 2008 04:28 AM

Thank you very much for your help.
Regards,
Otto

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
xBrowse one dimensional array
Posted: Sun Jul 06, 2008 08:49 PM
FWH 8.06 handles single dimensional arrays ( even with mixed type values ) easily:

Example
#include 'fivewin.ch'
#include 'xbrowse.ch'

function main()

   local oDlg, oBrw
   local aData := { 'one  ', 'two  ', 'three', 20, DATE() }

   DEFINE DIALOG oDlg SIZE 200,200 PIXEL

   oBrw  := TXBrowse():New( oDlg )
   oBrw:SetArray( aData )
   oBrw:aCols[ 1 ]:nWidth  := 50
   oBrw:aCols[ 1 ]:cHeader := 'Array'

   oBrw:nStretchCol  := 1
   oBrw:CreateFromCode()

   ACTIVATE DIALOG oDlg CENTERED

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion