Page 1 of 1

genblock

PostPosted: Mon Jun 12, 2023 10:01 am
by Silvio.Falconi
I have 9 button
when I press a button return allway 9

nRow:=30
For n= 1 to 9
@ nRow,2 BTNBMP aBtnCalc[n] PROMPT ltrim(str(n+1)) FLAT SIZE 20,30 PIXEL of oDlg ;
ACTION AddItems(oInvoice,aItems,GenBlock_(n),@nRowItems,fromdate,Todate)

nRow+=32
NEXt

fUNCTION GenBlock_(n)
RETURN n

and I Wish insert on GenBlock_(n) a right number (n)

Re: genblock

PostPosted: Mon Jun 12, 2023 11:14 am
by Detlef
dear Silvio,

search the forum for detached locals.
Or have a look here http://forums.fivetechsupport.com/viewtopic.php?f=3&t=41373&hilit=detached+local

Regards, Detlef

Re: genblock

PostPosted: Mon Jun 12, 2023 11:38 am
by paquitohm
Because ACTION clause generates an "internal" codeblock, so run ok:

Code: Select all  Expand view
nRow:=30
For n= 1 to 9
   #Define PARAMS1_ oDlg, aBtnCalc, nRow, n, oInvoice, aItems, @nRowItems, fromdate, Todate
   #Define PARAMS2_ oDlg, aBtnCalc, nRow, n, oInvoice, aItems,  nRowItems, fromdate, Todate
   GenButton(PARAMS1_)
   nRow+=32
NEXt

fUNCTION GenButton(PARAMS2_)
@ nRow,2 BTNBMP aBtnCalc[n] PROMPT ltrim(str(n+1)) FLAT SIZE 20,30 PIXEL of oDlg ;
ACTION AddItems(oInvoice,aItems,n,@nRowItems,fromdate,Todate)
RETURN NIL

Re: genblock

PostPosted: Mon Jun 12, 2023 5:10 pm
by Silvio.Falconi
Sorry I explain
I making a multiple invoice for beach management
in managing the beach, in addition to individual customers, there are associations or hotels that can book an x number of umbrellas, instead of placing an order for each umbrella at the hotel, I thought of making a multiple order and assigning XXXX n umbrellas to the hotel.

look this picture

Image

to assign the umbrellas the operator presses one of the numerical buttons that are on the left and then selects a button that is inside the first scrollable panel


on First Scroll Panel If I select one button it return allways 04

on source on a for next cicle I create the buttons into scrollpanel and the assign an action for each button

aBtnEle[n]:bAction :={ || (Elemento:= nProduct ,msginfo(nProduct))}

nProduct id the code of an array

nProduct:= aElements[n][1]

but perhaps n is allways 4

How I can resolve ?

Re: genblock

PostPosted: Mon Jun 12, 2023 7:56 pm
by Jimmy
hi Silvo,

as Detlef say : detached Locals

when build in a "Loop" and use "Counter" you must call a Function to build a String for Codeblock
so your "Counter" Number will be a STR() in a String

Code: Select all  Expand view
     FOR ii := 1 TO 26              // A-Z

         @ 40, ( ii - 1 ) * ( ( nBB * 2 ) + 2 ) BTNBMP oBtn SIZE nBB * 2, nBB PIXEL OF oMain ;
                 PROMPT cDrive LEFT ;
                 RESNAME cBitmap ;
                 FONT oFontDefault COLOR BFcolor, BGcolor

         bBlock := DetachBlock(ii)
         oBtn:bAction  := bBlock


Code: Select all  Expand view
FUNCTION DetachBlock( ii )
LOCAL cBlock := "{|| msgInfo(" + STR( ii ) + ")}"
LOCAL bBlock
   bBlock := &cBlock
RETURN bBlock


---

about "04" : on right side of Button you have some Listbox ... how many Element have 1st Listbox ?

Re: genblock

PostPosted: Tue Jun 13, 2023 7:13 am
by Silvio.Falconi
I resolved with cargo