How to use TXBrowse():bBmpData condition?

How to use TXBrowse():bBmpData condition?

Postby dutch » Sat Aug 16, 2008 7:01 pm

I try to show 'GO.BMP' in each one has '1' but it alway error. I don't know why.

Thanks,
Dutch

Code: Select all  Expand view  RUN
#include 'fivewin.ch'
#include 'xbrowse.ch'

Function Main
local oDlg, oLbx, oBtn, oSay, oGet
local aMonths := {}
local n, o, x, z, cField, nMonth, nYear, dStart, lSave, cPeriod, cOpen

for n := 1 to 12
    aadd( aMonths , { 'Month '+str(n), ;
                       ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ;
                       '1', '1', ' ', ' ', '1', ' ', ' ', ' ', ' ', ' ', ;
                       ' ', ' ', ' ', '1', ' ', ' ', ' ', ' ', ' ', ' ', ;
                      ' ' } )
next


   DEFINE DIALOG oDlg FROM 0, 0 TO 500,800 TITLE 'Yield Management' PIXEL


   REDEFINE XBROWSE oLbx ARRAY aMonths ;
            COLUMNS  1,  2,  3,  4,  5,  6,  7,  8,  9, 10 ,;
                    11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ,;
                    21, 22, 23, 24, 25, 26, 27, 28, 29, 30 , 31, 32 ;
              HEADERS 'Month/Year',  '1',  '2',  '3',  '4',  '5',  '6',  '7',  '8',  '9', '10', ;
               '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', ;
                       '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31' ;
              FIELDSIZES 130, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, ;
                    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, ;
                    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20 ;
              OF oDlg

// error on following lines
   for x := 2 to 32
     oLbx:aCols[x]:AddBmpFile("GO.BMP")
     oLbx:aCols[x]:bBmpData   := {|| iif(Eval(oLbx:aCols[x]:bStrData)='1',1,0) }
     oLbx:aCols[x]:nDataBmpAlign := AL_CENTER
   next


   oLbx:CreateFromCode()

   oDlg:oClient := oLbx

   ACTIVATE DIALOG oDlg ON INIT oLbx:SetFocus()

return nil
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Postby Antonio Linares » Sat Aug 16, 2008 7:37 pm

Dutch,

What error do you get ? Please write here the error description, thanks
regards, saludos

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

Postby Antonio Linares » Sat Aug 16, 2008 7:44 pm

Dutch,

This code is working fine here:
Code: Select all  Expand view  RUN
#include 'fivewin.ch'
#include 'xbrowse.ch'

Function Main
local oDlg, oLbx, oBtn, oSay, oGet
local aMonths := {}
local n, o, x, z, cField, nMonth, nYear, dStart, lSave, cPeriod, cOpen

for n := 1 to 12
    aadd( aMonths , { 'Month '+str(n), ;
                       ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ;
                       '1', '1', ' ', ' ', '1', ' ', ' ', ' ', ' ', ' ', ;
                       ' ', ' ', ' ', '1', ' ', ' ', ' ', ' ', ' ', ' ', ;
                      ' ' } )
next


   DEFINE DIALOG oDlg FROM 0, 0 TO 500,800 TITLE 'Yield Management' PIXEL


   @ 0, 0 XBROWSE oLbx ARRAY aMonths ;
            COLUMNS  1,  2,  3,  4,  5,  6,  7,  8,  9, 10 ,;
                    11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ,;
                    21, 22, 23, 24, 25, 26, 27, 28, 29, 30 , 31, 32 ;
              HEADERS 'Month/Year',  '1',  '2',  '3',  '4',  '5',  '6',  '7',  '8',  '9', '10', ;
               '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', ;
                       '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31' ;
              FIELDSIZES 130, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, ;
                    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, ;
                    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20 ;
              OF oDlg

   for x := 2 to 32
     oLbx:aCols[x]:AddBmpFile("GO.BMP")
     oLbx:aCols[x]:bBmpData   := GenBlock( oLbx, x )
     oLbx:aCols[x]:nDataBmpAlign := AL_CENTER
   next


   oDlg:oClient := oLbx

   ACTIVATE DIALOG oDlg ON INIT ( oLbx:SetFocus(), oDlg:ReSize() )

return nil

function GenBlock( oLbx, x )

return { || If( Eval( oLbx:aCols[ x ]:bStrData ) == '1', 1, 0 ) }
regards, saludos

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

Postby Antonio Linares » Sat Aug 16, 2008 7:47 pm

Image
regards, saludos

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

Postby nageswaragunupudi » Sat Aug 16, 2008 7:56 pm

Mr Dutch

For this purpose or any other purpose, please never generate codeblocks within a loop using the loop index. In the above sample, value of x is 33 when the codeblock is evaluated.

While there are several ways of coding, I advise you to replace the for loop in your sample with this code:
Code: Select all  Expand view  RUN
<< your code >>
AEval( oLbx:aCols, { |oCol| SetBmpData( oCol ) }, 2  )
<< your code >>

// separate function

static function SetBmpData( oCol )

   oCol:AddBmpFile( 'GO.BMP' )
   oCol:bBmpData := { || Val( oCol:Value ) }
   
return nil
Regards

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 63 guests