Array of gets
Array of gets
Hi !
I want to assign gets in for .. next . Here is a small sample :
local oGets[ len( aFlds ) ]
...
for nGt := 1 to len( aFlds )
cFld := aFlds[ nGt ]
@ nRw, nCol GET oGets[ nGt ] VAR aGets[ nGt ] PICTURE aPct[ nGt ] PIXEL SIZE nSz, nFh VALID n_pas( cAlias, cFld )
next
It seems that this isn't working .. ( I remmember something about deattached locals , but at this moment i can't to find about them . Thanks in advance for any help !
With best regards !
I want to assign gets in for .. next . Here is a small sample :
local oGets[ len( aFlds ) ]
...
for nGt := 1 to len( aFlds )
cFld := aFlds[ nGt ]
@ nRw, nCol GET oGets[ nGt ] VAR aGets[ nGt ] PICTURE aPct[ nGt ] PIXEL SIZE nSz, nFh VALID n_pas( cAlias, cFld )
next
It seems that this isn't working .. ( I remmember something about deattached locals , but at this moment i can't to find about them . Thanks in advance for any help !
With best regards !
Rimantas U.
Re: Array of gets
Alreday found samples for that - testarr4.prg and tesloop.prg . But I have an problem with bValid for oGets arrays . My function n_pas( cAlias, cFld ) get an lats cFld value . How it make true ? One solution it can be at oDlg close moment , but I want to do that in oGet stage .Rimantas wrote: local oGets[ len( aFlds ) ]
...
for nGt := 1 to len( aFlds )
cFld := aFlds[ nGt ]
@ nRw, nCol GET oGets[ nGt ] VAR aGets[ nGt ] PICTURE aPct[ nGt ] PIXEL SIZE nSz, nFh VALID n_pas( cAlias, cFld )
next
It seems that this isn't working .. ( I remmember something about deattached locals , but at this moment i can't to find about them .
With best regards !
Rimantas U.
Re: Array of gets
All is workig OK . Simply create codeblockRimantas wrote: Alreday found samples for that - testarr4.prg and tesloop.prg . But I have an problem with bValid for oGets arrays . My function n_pas( cAlias, cFld ) get an lats cFld value . How it make true ? One solution it can be at oDlg close moment , but I want to do that in oGet stage
local bCdb := { |oGet, nGt, others params...| get_blc( oGet, nGt, other params ..) }
Now in the loop evaluate codeblock
for nGt := 1 to len( aFlds )
oGet[ nGt ] = eval( bCdb, oGet[ nGt ], nGt, other params )
next
mine get_blc function :
static function get_blc( oDlg, oGt, cAlias, cFld, nGt, aGet, cPict, nRow, nCol )
oGt := TGet():New( nRow, nCol, GenLocalBlock( aGet, nGt ), oDlg,,, cPict,,,,,,, .t. )
if fieldtp( cAlias, cFld ) == "C"
oGt:bValid := { |oGet| n_pas( cAlias, cFld,, oGet:Value(), .t. ) }
endif
return( oGt )
static function GenLocalBlock( aGet, n )
return bSETGET( aGet[ n ] )
Now all is working OK ! With best regards !
Rimantas U.
-
- Posts: 142
- Joined: Sun Oct 09, 2005 10:59 am
Why not using hash arrays ?
They are very usefull for building dialog's , also afterwards when they must be referenced in another get
LOCAL oGets := Hash()
LOCAL aPct := Hash()
for nGt := 1 to len( aFlds )
cFld := aFlds[ nGt ]
@ nRw, nCol GET oGets[ cFld ] VAR aGets[ nGt ] PICTURE aPct[ cFld ] PIXEL SIZE nSz, nFh VALID n_pas( cAlias, cFld )
next
Frank
They are very usefull for building dialog's , also afterwards when they must be referenced in another get
LOCAL oGets := Hash()
LOCAL aPct := Hash()
for nGt := 1 to len( aFlds )
cFld := aFlds[ nGt ]
@ nRw, nCol GET oGets[ cFld ] VAR aGets[ nGt ] PICTURE aPct[ cFld ] PIXEL SIZE nSz, nFh VALID n_pas( cAlias, cFld )
next
Frank
Frank , very good sample ! I'm using hash , but in that way - no so much brains . Many thanks to you !Frank Demont wrote:Why not using hash arrays ?
They are very usefull for building dialog's , also afterwards when they must be referenced in another get
LOCAL oGets := Hash()
LOCAL aPct := Hash()
for nGt := 1 to len( aFlds )
cFld := aFlds[ nGt ]
@ nRw, nCol GET oGets[ cFld ] VAR aGets[ nGt ] PICTURE aPct[ cFld ] PIXEL SIZE nSz, nFh VALID n_pas( cAlias, cFld )
next
With best regards !
Rimantas U.
This isn't working Frank ... . I tried that . Simply add MsgInfo() to valid clauseRimantas wrote: Frank , very good sample ! I'm using hash , but in that way - no so much brains . Many thanks to you !
@ CRow( 0 ), nCl GET oGets[ cFld ] VAR aGets[ cFld ] PICTURE aPct[ cFld ] PIXEL VALID ( MsgInfo( aGets[ cFld ] + " ; " + cFld ), ;
n_pas( ::aAlias[ ::nFld ], cFld,, aGets[ cFld ], .t. ) )
I did hash'es all clauses : oGets , aPct, aGets . But validation will receive only the last cFld . Have you ideas , how to nake to work this ?
With best regards !
Rimantas U.
-
- Posts: 142
- Joined: Sun Oct 09, 2005 10:59 am
-
- Posts: 3
- Joined: Thu Oct 27, 2005 1:31 pm
- Location: Sisak, Croatia
FOR ... GET ...NEXT
I had a same problem in FW1.9.2 and I solved it by replacing aGets array with vars:
for nGt := 1 to len( aFlds )
cFld := aFlds[ nGt ]
xVar="x"+strzero(nGt,3)
@ nRw, nCol GET oGets[ nGt ] VAR &xVar .....
next
I hope that it works in FW for Harbour too.
Regards
Goran
for nGt := 1 to len( aFlds )
cFld := aFlds[ nGt ]
xVar="x"+strzero(nGt,3)
@ nRw, nCol GET oGets[ nGt ] VAR &xVar .....
next
I hope that it works in FW for Harbour too.
Regards
Goran
Re: FOR ... GET ...NEXT
Yes Goran , your sample is working in that way , I know . I used in early something similar . Simply it's interesting to do in others ways , like Frank's sample with hashes .Goran Papic wrote:I had a same problem in FW1.9.2 and I solved it by replacing aGets array with vars:
for nGt := 1 to len( aFlds )
cFld := aFlds[ nGt ]
xVar="x"+strzero(nGt,3)
@ nRw, nCol GET oGets[ nGt ] VAR &xVar .....
next
I hope that it works in FW for Harbour too
With best regards !
Rimantas U.
-
- Posts: 6
- Joined: Thu Oct 13, 2005 3:41 pm
- Location: Quebec City, Canada
Marc Boissinot wrote:Here's a way with the detached local method...
for i := 1 to Len( aGets )
@i,0 GET oGets VAR aGets
oGets:bSetGet := oGets:oGet:Block := ArrayGetBlock(aGets,i)
next
function ArrayGetBlock(aGets,i)
return { | u | If( PCount()==0, aGets, aGets:= u ) }
Hello Marc !
I'm using that "deatached" . Also I'm using codeblock to check validation of my vars . Evaluting of that works fine for array of gets . From codeblock it's direction to deatached function .
With best regards ! Rimantas .
Rimantas U.