Making it easier to use Browses for arrays

Making it easier to use Browses for arrays

Postby xProgrammer » Sat Aug 18, 2007 11:18 am

I am trying to make it easier for me to use browses for arrays.

First I wrote a

FUNCTION BrwSetColWidths( oBrw, aWidths )

and that works fine.

Now I am trying to write a

FUNCTION BrwSet4Arrays( oBrw )

The purpose is to write the necessary code blocks (bGoTop, bGoBottom, bSkip, bLogicLen). I want to do this in a way that I can have more than one browse in a dialog/window. I remember the technique of using oBrw:cargo set to ARRAY( 3 ) to hold values. So I thought it would be easy. But my stumbling block is that I can't seem to refer to values of cargo[x] in the blocks in a way that doesn't include the name of the browse object. I thought :: might work ( ie use ::cargo[x] but that is trying to access a cargo array in the object that contains the browse - ie the browse's parent I think . I tried self:cargo[x] but that didn't seem to work either. Is there a generic way I can reference the cargo? Or is there some other solution that I can't see at present.

Obviously I can code around this so it isn't a problem, but it would be nice if I could do it.

Thanks
User avatar
xProgrammer
 
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Postby Antonio Linares » Sat Aug 18, 2007 5:59 pm

Doug,

We have ported our FiveWin Class TWBrowse Method SetArray() to FiveLinux, so now you automatically get the functionality to browse arrays:
Code: Select all  Expand view
METHOD SetArray( aArray ) CLASS TWBrowse

   ::nAt       = 1
   ::cAlias    = "ARRAY"
   ::bLogicLen = { || ::nLen := Len( aArray ) }
   ::bGoTop    = { || ::nAt := 1 }
   ::bGoBottom = { || ::nAt := Eval( ::bLogicLen, Self ) }
   ::bSkip     = { | nSkip, nOld | nOld := ::nAt, ::nAt += nSkip,;
                  ::nAt := Min( Max( ::nAt, 1 ), Eval( ::bLogicLen, Self ) ),;
                  ::nAt - nOld }

return nil

We send you the new LIBs and a new samples\TestArr.prg for a working sample:
Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42097
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveLinux / FiveDroid (Android)

Who is online

Users browsing this forum: No registered users and 4 guests