REDEFINE BTNBMP Within FOR NEXT LOOP

REDEFINE BTNBMP Within FOR NEXT LOOP

Postby reds » Sat Jul 27, 2019 12:07 pm

I have quite a lot of On/Off settings to include so was hoping to set them up using a for next loop
but I'm gettting a bound array error (n=3) on selection

Can this be done if so what do I need to change

Thanks
Peter
Code: Select all  Expand view  RUN

  #include "FiveWin.ch"

function Main()
   LOCAL oBtn[2]
   LOCAL oDlg  
   LOCAL lOn := {.f.,.t.}
   LOCAL n
   DEFINE DIALOG oDlg  RESOURCE 'DIALOG1'  
   
   FOR n = 1 to 2
   REDEFINE BTNBMP oBtn[n] CENTER NOBORDER UPDATE ID 4029 + n OF oDlg ;
        RESOURCE IIF( lOn[n], 8002,8001 ) ACTION ( lOn[n] := ! lOn[n],::SetImages(IIF( lOn[n], 8002,8001 )),ShowStatus(lOn[n]))    
   NEXT
 
   ACTIVATE DIALOG oDlg  
   
RETURN nil
  FUNCTION ShowStatus(lOn)
   
  @ 6,1 SAY IIF(lOn,"On ","Off")
   RETURN NIL
 
reds
 
Posts: 50
Joined: Tue May 16, 2017 12:19 pm
Location: North London

Re: REDEFINE BTNBMP Within FOR NEXT LOOP

Postby nageswaragunupudi » Sat Jul 27, 2019 4:15 pm

Please test this and adapt this logic:
Code: Select all  Expand view  RUN
#include "fivewin.ch"

function Main()

   local aOn   := { .f., .t., .f., .t. }
   local oDlg, oBtn, n
   local nRow, nCol

   DEFINE DIALOG oDlg SIZE 380,150 PIXEL TRUEPIXEL

   nRow  := 40
   nCol  := 40

   for n := 1 to Len( aOn )

      @ nRow, nCol BTNBMP oBtn RESOURCE FWBmpOn(),nil,FWBmpOff() ;
         SIZE 64,64 PIXEL OF oDlg UPDATE 2007 ;
         ACTION aOn[ ::Cargo ] := !aOn[ ::Cargo ]

      WITH OBJECT oBtn
         :Cargo      := n
         :bBmpNo     := { |Self| If( aOn[ ::Cargo ], 1, 3 ) }
      END

      nCol  += 70

   next

   ACTIVATE DIALOG oDlg CENTERED

return nil
 
Regards

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

Re: REDEFINE BTNBMP Within FOR NEXT LOOP

Postby reds » Mon Jul 29, 2019 6:02 pm

Many thanks
Peter
reds
 
Posts: 50
Joined: Tue May 16, 2017 12:19 pm
Location: North London


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 38 guests

cron