TBrowse of Logical 
Author Message
 TBrowse of Logical

One of the fields I am browsing is often a logical value.  The browse
function used is a "One browse fits all" model, so fields, titles and widths
are passed as an array, and the column is created using a fieldblock
function.  Has anyone used such a browse, and displayed a character, or
space, in place of the logical value ?  ( ie. a checkmark ).    How ?

Tim



Sat, 09 Sep 2000 03:00:00 GMT  
 TBrowse of Logical

[cut]

Quote:
> Has anyone used such a browse, and displayed a character, or
> space, in place of the logical value ?  ( ie. a checkmark ).    How ?

In this example :
Mybrowse is TBrowse object.
LFIELD is logical field.
/* Clipper 5.2e */
colm:=TBCOLUMNNEW('Check', { || If(LFIELD, '*', Space(1)) } )
Mybrowse:ADDCOLUMN(colm)
--
Regards, Vladimir (kzm11 at geocities dot com)
http://www.geocities.com/SiliconValley/Pines/7762/index.html


Sun, 10 Sep 2000 03:00:00 GMT  
 TBrowse of Logical

In this case, the logical field is part of an array passed to a browse
function.  Consequently, the name of the field changes depending on the file
used when calling the function.  The array has 3 elements. [1] is the column
title, [2] is the field name, and [3] is the width.   The following would
normally be called:
colm := TBCOLUMNNEW( aFDEF[ac][1], { | | FIELDBLOCK( aFDEF[ac][2] } )
where ac is the counter in a FOR...NEXT loop to handle all of the elements
of AFDEF.

The trick is to change a logical field [ac][2] to a checkmark when it is
passed in this manner.

|colm:=TBCOLUMNNEW('Check', { || If(LFIELD, '*', Space(1)) } )



Sun, 10 Sep 2000 03:00:00 GMT  
 TBrowse of Logical

I made a function that allow to tag/untag the rows of a browse : you pass
an object to it, and it returns an array of the tagged elements.

If you want it, mail to me

--
Sebastien



Quote:

> [cut]
> > Has anyone used such a browse, and displayed a character, or
> > space, in place of the logical value ?  ( ie. a checkmark ).    How ?
> In this example :
> Mybrowse is TBrowse object.
> LFIELD is logical field.
> /* Clipper 5.2e */
> colm:=TBCOLUMNNEW('Check', { || If(LFIELD, '*', Space(1)) } )
> Mybrowse:ADDCOLUMN(colm)
> --
> Regards, Vladimir (kzm11 at geocities dot com)
> http://www.geocities.com/SiliconValley/Pines/7762/index.html



Sun, 10 Sep 2000 03:00:00 GMT  
 TBrowse of Logical



Quote:
>One of the fields I am browsing is often a logical value.  The browse
>function used is a "One browse fits all" model, so fields, titles and widths
>are passed as an array, and the column is created using a fieldblock
>function.  Has anyone used such a browse, and displayed a character, or
>space, in place of the logical value ?  ( ie. a checkmark ).    How ?

I use this BoolDispBlock() function as a replacement for FIELDWBLOCK()
for logical fields in a browse:

----------------------------------

obrowse := tbrowsedb( 2,10,23,69 )

obrowse:addcolumn( tbcolumnnew( "NAME", ;
fieldwblock( "name", select( "dbffile" ) ) ) )

obrowse:addcolumn( tbcolumnnew( "FLAG", ;
BoolDispBlock( "flag", select( "dbffile" ), { "NO", "YES" } ) ) )

do while .t.

   obrowse:forcestable()
   nkey := inkey( 0 )

   do case
   case nkey == K_ESC  ;  exit
   case...   // cursor movement keys

   // spacebar toggles the value of the logical field
   case obrowse:colpos == 2 .and. nkey == K_SPACE
      if tmp->( rlock() )
         tmp->flag := .NOT. tmp->flag
         tmp->( dbunlock() )
         obrowse:refreshcurrent()
      endif

   endcase

enddo

use
return

//------------------------
func BoolDispBlock( cfieldname, nWorkarea, aDispValues )
/*
   replacement for fieldwblock(), returning a set-get block
   for a logical; first two params just like fieldwblock():

   fieldname is the name of a logical field
   nWorkarea is the workarea for the field

   third param, aDispValues, is a two-string array:
      element 1 == FALSE dispay value
      element 2 == TRUE display value
*/
local cWorkarea := LTRIM( STR( nWorkarea, 3, 0 ) ) + "->"
local nMaxWidth := ;
   MAX( LEN( aDispValues[ 1 ] ), LEN( aDispValues[ 2 ] ) )
aDispValues[ 1 ] := PADR( aDispValues[ 1 ], nMaxWidth )
aDispValues[ 2 ] := PADR( aDispValues[ 2 ], nMaxWidth )
return ( &( ;
   '{ |x| IF( x == NIL, IF( ' + ;
   cWorkarea + cFieldname + ', "' + ;
   aDispValues[ 2 ] + '", "' + ;
   aDispValues[ 1 ] + '" ), ' + ;
   cWorkarea + cFieldname + ' := x ) }' ;
   ) )

----------------------------------------

You could use an array: { ' ', CHR(251) ) as the third param to
BoolDispBlock() to get the "check-mark" effect you want.

--
Clark Morrison



Sun, 10 Sep 2000 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Tbrowse help needed - tbrowse [1/1]

2. logical*4 and logical*8?

3. Green Bar effect using TBrowse() or custom function?

4. TBrowse & Mouse

5. TBrowse within a READ GETS?

6. Tbrowse with rows in different colors

7. TBrowse - Stabilizing the database row with Browse:rowpos.

8. Displaying the contents of 2 files via relation in TBrowse

9. TBrowse error 31 in obj:stabilize()

10. TBrowse() help

11. Get within TBrowse

12. Formatting a field for TBrowse

 

 
Powered by phpBB® Forum Software