FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour two dimensional array - resolved!!
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
two dimensional array - resolved!!
Posted: Wed Mar 30, 2022 10:35 AM

I need to make an array with two dimesion
type oBtnNum[10,9 ]
in order to have the cCaption from 1 to 90
each row ten number

but at the same time having each button recognizable for example

oBtnNum[2,1 ] is the btn with the cCaption number 11 ( Col 1,Row 2)

How do it ?

I made
for k=1 to 10
For j=1 to 9
@ nrow,ncol BTNBMP oBtnNum[k,j] PROMPT "C"+ltrim(str(k))+"R"+lTrim(str(j)) ;
SIZE xWidth,xHeight FLAT PIXEL OF oDlg NOROUND
nrow+=xHeight +xSpace
next
ncol+=xWidth +xSpace
nrow:= 25
next

but the the oBtnNum[k,j] is no good

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: two dimensional array
Posted: Fri Apr 01, 2022 01:45 AM
Silvio.Falconi wrote:I need to make an array with two dimesion
type oBtnNum[10,9 ]
in order to have the cCaption from 1 to 90
each row ten number



but at the same time having each button recognizable for example

oBtnNum[2,1 ] is the btn with the cCaption number 11 ( Col 1,Row 2)

How do it ?

I made
for k=1 to 10
For j=1 to 9
@ nrow,ncol BTNBMP oBtnNum[k,j] PROMPT "C"+ltrim(str(k))+"R"+lTrim(str(j)) ;
SIZE xWidth,xHeight FLAT PIXEL OF oDlg NOROUND
nrow+=xHeight +xSpace
next
ncol+=xWidth +xSpace
nrow:= 25
next

but the the oBtnNum[k,j] is no good


Try this;
Code (fw): Select all Collapse
for k=1 to 90
       For j=1 to 9
             MakeBtn( nrow, ncol, k, j, oDlg )
       nrow+=xHeight +xSpace
    next
    ncol+=xWidth +xSpace
       nrow:= 25
next

function MakeBtn( nrow, ncol, k, j, oDlg )
         @  nrow,ncol BTNBMP oBtnNum[k,j] PROMPT "C"+ltrim(str(k))+"R"+lTrim(str(j)) ;
                          SIZE xWidth,xHeight FLAT PIXEL OF oDlg NOROUND
return nil
Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: two dimensional array
Posted: Fri Apr 01, 2022 07:08 AM
dutch wrote:
Silvio.Falconi wrote:I need to make an array with two dimesion
type oBtnNum[10,9 ]
in order to have the cCaption from 1 to 90
each row ten number



but at the same time having each button recognizable for example

oBtnNum[2,1 ] is the btn with the cCaption number 11 ( Col 1,Row 2)

How do it ?

I made
for k=1 to 10
For j=1 to 9
@ nrow,ncol BTNBMP oBtnNum[k,j] PROMPT "C"+ltrim(str(k))+"R"+lTrim(str(j)) ;
SIZE xWidth,xHeight FLAT PIXEL OF oDlg NOROUND
nrow+=xHeight +xSpace
next
ncol+=xWidth +xSpace
nrow:= 25
next

but the the oBtnNum[k,j] is no good


Try this;
Code (fw): Select all Collapse
for k=1 to 90
       For j=1 to 9
             MakeBtn( nrow, ncol, k, j, oDlg )
       nrow+=xHeight +xSpace
    next
    ncol+=xWidth +xSpace
       nrow:= 25
next

function MakeBtn( nrow, ncol, k, j, oDlg )
         @  nrow,ncol BTNBMP oBtnNum[k,j] PROMPT "C"+ltrim(str(k))+"R"+lTrim(str(j)) ;
                          SIZE xWidth,xHeight FLAT PIXEL OF oDlg NOROUND
return nil


the problem is not in the creation of buttons but in the management that is

we have 90 buttons of 10 columns by 9 rows

if the button that has caption 11 (second row first column 1) is not necessarily the abtn [1,2] or abtn [2,1] button

depending on whether the array is [10,9] or [9,10 ]

When you go to manage the buttons and you have to change the buttons that have the caption
{11, 22, 33, 44, 55, 66, 77, 88}

how do you find them inside the 90 buttons?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: two dimensional array
Posted: Fri Apr 01, 2022 07:50 AM
Please try this
if you press each button run ok it change the color

now press "GE"

Code (fw): Select all Collapse
#include "fivewin.ch"

#define ORANGE  nRGB( 255, 165, 0 )
#define LIGHTORANGE  nRGB( 255, 160, 122 )
function  Select90()
   Local oBtnOK,oBtnCan,oDlg

DEFINE DIALOG oDlg SIZE 800,380  PIXEL TRUEPIXEL RESIZABLE;
   TITLE "test button"

    
     @ 100,10 BUTTON oBtnClose PROMPT "Chiudi" of oDlg  SIZE 80,22 ACTION oDlg:End()


 oDlg:bResized  := <||
          local oRect        := oDlg:GetCliRect()
               
                oBtnClose:nLeft      := oRect:nRight - 100
                oBtnClose:nTop       := oRect:nBottom - 25
               
        return nil
       >

   ACTIVATE DIALOG oDLG ;
   ON INIT ( BuildTable90(oDlg),;
             EVAL( oDlg:bResized))
   return nil


 Function BuildTable90(oDlg)
      local k,j
      local xWidth  := 40
      local xHeight := 30
      local xSpace  := 1
      local nTotCol := 9
      local nTotRow := 10
      local oBtnNum:= Array( nTotCol, nTotRow )
      local nRow:= 25,nCol:= 40
      local nNumber:= 0
      local oOpe[1]
      local oSay

         @ 5,4 GROUP oSay To 345,460 Label "0 selezionati e 0 Colonne" TRANSPARENT PIXEL

        for t := 1 to nTotRow
          for k := 1 to nTotCol
                 nNumber:= nTotRow * ( k -1) +t
                 MakeBtn( nrow, ncol, t,k, oDlg,oBtnNum,nNumber,oSay )
                 nrow+=xHeight +xSpace
        next
        ncol+=xWidth +xSpace
        nrow:= 25

    next
     xRow:=25;xCol:= 6
   @xRow,xCol BUTTONBMP  oOpe[1] Prompt "GE" size 30,30 PIXEL FLAT OF oDlg TOOLTIP "Gemelli" ACTION Gemelli(oBtnNum,oSay)

    return nil
Function Gemelli(oCmb,oSay)
     local atemp:={}
     local k,t

     atemp:={11, 22, 33, 44, 55, 66, 77, 88}

    For n= 1 to Len(atemp)
       k:= val(Left(ltrim(str(atemp[n])),1))
       t:= val(Right(ltrim(str(atemp[n])),1))

        oCmb[k,t]:cargo:=1
        SetStatus( oCmb[k,t],oSay)
     next
     return NIL

     return NIL
PROCEDURE SetStatus( oBtn,oSay )
    //-------------------------
       local n:=0

        switch oBtn:cargo[3]
           case 1
              oBtn:cargo[3] := 2
              n++
             oBtn:SetColor( CLR_WHITE, ORANGE )
             EXIT

           case 2
             oBtn:cargo[3] := 3
             oBtn:SetColor( CLR_BLACK, LIGHTORANGE )
             EXIT

           case 3
              oBtn:cargo[3] := 1
              n--
             oBtn:SetColor( CLR_BLACK, CLR_WHITE )

        end

        oBtn:refresh()
      
        RETURN

function MakeBtn( nrow, ncol, t, k, oDlg,oBtnNum,num ,oSay)
             @  nrow,ncol BTNBMP oBtnNum[k,t] PROMPT ltrim(str(num)) ;
                              SIZE 40,30 FLAT PIXEL OF oDlg NOROUND
             oBtnNum[k,t]:cargo   :={k,t, 1 }
             oBtnNum[k,t]:bAction := { | o |  SetStatus( o,oSay) }
             oBtnNum[k,t]:SetColor( CLR_BLACK, CLR_WHITE )


    return nil
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: two dimensional array
Posted: Fri Apr 01, 2022 09:08 AM
Silvio,
xBrowsae() is such a mighty function.

For debugging, you should insert xBrowse() and check the objects.

Best regards,
Otto
Code (fw): Select all Collapse
Function Gemelli(oCmb,oSay)
     local atemp:={}
     local k,t
      
      xbrowse( oCmb )  


     atemp:={11, 22, 33, 44, 55, 66, 77, 88}

    For n= 1 to Len(atemp)
       k:= val(Left(ltrim(str(atemp[n])),1))
       t:= val(Right(ltrim(str(atemp[n])),1))

        oCmb[k,t]:cargo:=1
        
       xbrowse( oCmb[k,t] )  
        
        SetStatus( oCmb[k,t] ,oSay )
        
        
        
     next
     return NIL

     return NIL
     
PROCEDURE SetStatus( oBtn, oSay )
    //-------------------------
       local n:=0

 xbrowse( oBtn )  
 ? Valtype(oBtn:cargo)
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: two dimensional array
Posted: Fri Apr 01, 2022 09:36 AM

opps right!!!

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com

Continue the discussion