Page 1 of 1

Codeblock multiedit pupup

Posted: Wed May 04, 2011 6:54 am
by c-tec
Hello,
I would like to put a individual pupup on gets that I create in a loop. But it does not work, get always the value of the last x from the loop in makegblock. What is wrong in the action block of DCSUBMENU ?

regards
Rudolf


Code: Select all

aGets := {}
for x := 1 to 5
     aadd(aGets,NIL)
     cMenu := "oMenu" + ntrim(x)
     cVar  := "oGet" + ntrim(x)
     @ nTop,nLeft  dcmultiline &cVar size nWidth,nHeight object aGets[x] EVAL { |o| o:RbDown  := { |x,y,z| &cMenu:PopUp ( z, x, 2 , ( 2 + 4 + 64 + 128 + 512 ) + 16  ) } }
     DCSUBMENU &cMenu PROMPT "Zusätze" PARENT aGets[x]
     DCSUBMENU oMenu1 prompt "ins Wörterbuch"    action &("{||makegblock(" + ntrim(x) + ")}") PARENT &cMenu
     ...
next x

function makegblock(x)
dcqdebug x // always 5
return .t.

Re: Codeblock multiedit pupup

Posted: Wed May 04, 2011 7:48 am
by Cliff Wiernik
Roger helped with this sample long ago to do what you want.

Code: Select all

  @ 1.3,.5 DCSTATIC TYPE XBPSTATIC_TYPE_RECESSEDBOX OBJECT d_oPagegroup6 SIZE nTPWidth-1.4,nTPHeight-3+.1 PARENT d_oTabstatic6 ;
             COLOR GRA_CLR_BLACK,m->G_nBGColor 
           
  @ .1,.5 DCGROUP d_oMemo1 SIZE nTPWidth-2.3,22.8 CAPTION 'Miscellaneous Information - Page 1' PARENT d_oPagegroup6 FONT m->G_cGCaptionFont
  
  DCSETGROUP TO 'MEMO1GROUP'
  DCSETPARENT TO d_oTabstatic6

  nRow := 2.3

  @ nRow,  3 DCSAY 'Code' SAYSIZE 10 SAYCENTER
  @ nRow, 16 DCSAY 'Comments' SAYSIZE 55 SAYCENTER
  
  FOR i := 1 TO 18
    bGetSet  := &('{|u|IIF(u==nil,m->DM'+Alltrim(Str(i))+',m->DM'+Alltrim(Str(i))+':=u)}')
    bValid   := &('{|oGet| LB_valfile(m->DM'+Alltrim(Str(i))+',{|| CODEFILE->code},"CODEFILE",oGet,"P",,"P","P") }')
    bMessage := &('{|| LB_DataDict("DEALER","dm'+alltrim(str(i))+'") }')
    @ nRow+i, 3 DCGET bGetSet VALID bValid ;
           MESSAGE bMessage ;
           POPUP {|c| BrowseFile('CODEFILE',c,{|| CODEFILE->code},'P',,,'P','P')}  ;
           POPCAPTION BITMAP_LOOKUP_LB POPHEIGHT 18 
    bGetSet  := &('{|u|IIF(u==nil,m->DC'+Alltrim(Str(i))+',m->DC'+Alltrim(Str(i))+':=u)}')
    bMessage := &('{|| LB_DataDict("DEALER","dc'+alltrim(str(i))+'") }')
    @ nRow+i, 16 DCGET bGetSet SIZE 55,1 ;
           MESSAGE bMessage 
  NEXT

Re: Codeblock multiedit pupup

Posted: Thu May 05, 2011 12:22 am
by c-tec
Hello Cliff,
thank you, but I think that is what I do in this line:

Code: Select all

 DCSUBMENU oMenu1 prompt "ins Wörterbuch"    action &("{||makegblock(" + ntrim(x) + ")}") PARENT &cMenu
I will dig in the preprocessor code, maybe I find there something
regards
Rudolf

Re: Codeblock multiedit pupup

Posted: Thu May 05, 2011 6:30 am
by Cliff Wiernik
I think the issue is that your code block is being compiled and executed at the time of dcread first time, not with each iteration.

Code: Select all

DCSUBMENU oMenu1 prompt "ins Wörterbuch"    action &("{||makegblock(" + ntrim(x) + ")}") PARENT &cMenu


Try this:
[code]

dblock := &("{||makegblock(" + ntrim(x) + ")}")

DCSUBMENU oMenu1 prompt "ins Wörterbuch"    action  doblock PARENT &cMenu
That is something I see different in the approach Roger gave to me. I think your approach keeps the link to x (detached local) where the separation of the two, keeps it separately.

Cliff.

Re: Codeblock multiedit pupup

Posted: Mon May 09, 2011 4:29 am
by c-tec
Hello Cliff,
thank you, have solved it, it was the eval codeblock for the menu pupup, here I also have to make the codeblock with the variable like the menues
regards
Rudolf