Page 1 of 1

Making it easier to use Browses for arrays

PostPosted: Sat Aug 18, 2007 11:18 am
by xProgrammer
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

PostPosted: Sat Aug 18, 2007 5:59 pm
by Antonio Linares
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