FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Array of gets
Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM

Array of gets

Posted: Wed Oct 26, 2005 07:07 AM

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 !

Rimantas U.
Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM

Re: Array of gets

Posted: Wed Oct 26, 2005 10:30 AM
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 .


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 .

With best regards !
Rimantas U.
Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM

Re: Array of gets

Posted: Wed Oct 26, 2005 11:49 AM
Rimantas 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


All is workig OK . Simply create codeblock

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

Array of gets

Posted: Wed Oct 26, 2005 02:32 PM

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

Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM

Array of gets

Posted: Thu Oct 27, 2005 05:00 AM
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


Frank , very good sample ! I'm using hash , but in that way - no so much brains :-) . Many thanks to you !

With best regards !
Rimantas U.
Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM

Array of gets

Posted: Thu Oct 27, 2005 07:41 AM
Rimantas wrote: Frank , very good sample ! I'm using hash , but in that way - no so much brains :-) . Many thanks to you !


This isn't working Frank ... :-) . I tried that . Simply add MsgInfo() to valid clause
@ 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

Array of gets

Posted: Thu Oct 27, 2005 08:19 AM

You can try :

FOR EACH xKey in hHash:Keys
? xKey, hHash[ xKey ]
NEXT

or

FOR EACH xVal IN hHash:Values
? xVal
NEXT

Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM

Array of gets

Posted: Thu Oct 27, 2005 09:04 AM
Frank Demont wrote:You can try :

FOR EACH xKey in hHash:Keys
? xKey, hHash[ xKey ]
NEXT

or

FOR EACH xVal IN hHash:Values
? xVal
NEXT


Tried , the same result ... :-) . The first get receive the last get's parameter .
Rimantas U.
Posts: 3
Joined: Thu Oct 27, 2005 01:31 PM

FOR ... GET ...NEXT

Posted: Fri Oct 28, 2005 09:27 AM

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

Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM

Re: FOR ... GET ...NEXT

Posted: Fri Oct 28, 2005 12:59 PM
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


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 :-) .

With best regards !
Rimantas U.
Posts: 6
Joined: Thu Oct 13, 2005 03:41 PM

Array of gets

Posted: Fri Oct 28, 2005 01:29 PM
Here's a way with the detached local method...

for i := 1 to Len( aGets )
@i,0 GET oGets[i] VAR aGets[i]
oGets[i]:bSetGet := oGets[i]:Block := ArrayGetBlock(aGets,i)
next


function ArrayGetBlock(aGets,i)

return { | u | If( PCount()==0, aGets[i], aGets[i]:= u ) }
Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM

Array of gets

Posted: Mon Oct 31, 2005 05:43 PM
Marc Boissinot wrote:Here's a way with the detached local method...

for i := 1 to Len( aGets )
@i,0 GET oGets[i] VAR aGets[i]
oGets[i]:bSetGet := oGets[i]:Block := ArrayGetBlock(aGets,i)
next


function ArrayGetBlock(aGets,i)

return { | u | If( PCount()==0, aGets[i], aGets[i]:= 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.

Continue the discussion