xBrowse one dimensional array

xBrowse one dimensional array

Postby Otto » Mon Jun 23, 2008 3:21 pm

Does xBrowse work on a one dimensional array.

Regards,
Otto
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Postby nageswaragunupudi » Mon Jun 23, 2008 3:42 pm

No :(
Wish it works. Right ?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Otto » Mon Jun 23, 2008 4: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
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Postby nageswaragunupudi » Mon Jun 23, 2008 5:03 pm

Mr Otto

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


Code: Select all  Expand view
#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
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Otto » Mon Jun 23, 2008 6: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
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Postby nageswaragunupudi » Tue Jun 24, 2008 9: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
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby nageswaragunupudi » Sat Jun 28, 2008 1: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
Code: Select all  Expand view
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.
Code: Select all  Expand view
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
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Otto » Sun Jun 29, 2008 4:28 am

Thank you very much for your help.
Regards,
Otto
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Postby Antonio Linares » Sun Jul 06, 2008 8:49 pm

FWH 8.06 handles single dimensional arrays ( even with mixed type values ) easily:

Example
Code: Select all  Expand view
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 74 guests