two dimensional array - resolved!!

two dimensional array - resolved!!

Postby Silvio.Falconi » 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
Last edited by Silvio.Falconi on Fri Apr 01, 2022 9:36 am, edited 1 time in total.
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6768
Joined: Thu Oct 18, 2012 7:17 pm

Re: two dimensional array

Postby dutch » Fri Apr 01, 2022 1: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: Select all  Expand view

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 19.01 / 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)
User avatar
dutch
 
Posts: 1535
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: two dimensional array

Postby Silvio.Falconi » Fri Apr 01, 2022 7: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: Select all  Expand view

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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6768
Joined: Thu Oct 18, 2012 7:17 pm

Re: two dimensional array

Postby Silvio.Falconi » Fri Apr 01, 2022 7:50 am

Please try this
if you press each button run ok it change the color

now press "GE"

Code: Select all  Expand view


#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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6768
Joined: Thu Oct 18, 2012 7:17 pm

Re: two dimensional array

Postby Otto » Fri Apr 01, 2022 9:08 am

Silvio,
xBrowsae() is such a mighty function.

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

Best regards,
Otto
Code: Select all  Expand view


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)
 
 
 


 
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Re: two dimensional array

Postby Silvio.Falconi » Fri Apr 01, 2022 9:36 am

opps right!!!
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6768
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 84 guests