Alaska Software Inc. - ComEvalCollection( o,bCodeblock)
Username: Password:
AuthorTopic: ComEvalCollection( o,bCodeblock)
AUGE_ OHRComEvalCollection( o,bCodeblock)
on Sat, 09 Feb 2013 07:12:07 +0100
hi,

this Code work

   bBlock  := { |oService, n| AADD(aFind,n) }
   ComEvalCollection( objWMIService:Properties_ , bBlock  )

this Code does not crash but aFind Array is empty

   bBlock := "{ |oService, n| AADD(aFind,n) }"
   ComEvalCollection( objWMIService:Properties_ , &bBlock )

i also try

   bBlock := "{ |oService, n| AADD(aFind,n) }"
   bCollBlock := &(bBlock)
   ComEvalCollection( objWMIService:Properties_ , bCollBlock  )

but it fail too ... aFind Array is still empty 

try attach Source to show Difference ( WMI must be enable )
did i made a Error or is it a BUG of ComEvalCollection()

greetings by OHR
Jimmy






WMI_CPU.ZIP
Peter AlderliestenRe: ComEvalCollection( o,bCodeblock)
on Sat, 09 Feb 2013 12:08:52 +0100
Jimmy,

>    bBlock  := { |oService, n| AADD(aFind,n) }
>    ComEvalCollection( objWMIService:Properties_ , bBlock  )
> 
> this Code does not crash but aFind Array is empty
> 
>    bBlock := "{ |oService, n| AADD(aFind,n) }"
>    ComEvalCollection( objWMIService:Properties_ , &bBlock )

Is the array aFind visible for the codeblock when evaluated (public or
private), otherwise it creates a new array and leaves the original
untouched. 
You could have the array as local and pass it as a parameterl.

Peter
AUGE_ OHRRe: ComEvalCollection( o,bCodeblock)
on Sun, 10 Feb 2013 17:42:09 +0100
hi,

> Is the array aFind visible for the codeblock when evaluated (public or
> private), otherwise it creates a new array and leaves the original
> untouched.
> You could have the array as local and pass it as a parameterl.

i have attach WMI_Processor Source as Demo.

Array is LOCAL and does work when use Codeblock "direct"
while Array are "per Reference".

when use a String -> &(bBlock) it does work with EVAL()
but same &(bBlock) does not work with ComEvalCollection() ?

yes i can try PRIVATE ...
or use a detached LOCAL with Function in Codeblock like this

   ComEvalCollection( oWmiInstances , fCollBlock(aFind,cName)  )

FUNCTION fCollBlock(aFind,cProp)
LOCAL bBlock
   bBlock := {|oService,n| AADD(aFind,{ cProp,;
               oService:getProperty(cProp) })}
RETURN bBlock

but i still wonder why ComEvalCollection() seem not to work with &(bBlock)

greetings by OHR
Jimmy
AUGE_ OHRRe: ComEvalCollection( o,bCodeblock)
on Mon, 11 Feb 2013 02:02:56 +0100
hi,

>bBlock := "{ |oService, n| AADD(aFind,n) }"

it is my Error ... made same Error in Demo Sample

      bBlock      := "{|oService,n| AADD(aItem,{ n ,"          + ;
        "oService:getProperty("+cSem+"MaxClockSpeed"+cSem+")," + ;
        "oService:getProperty("+cSem+"Name"+cSem+"),"          + ;
        "oService:getProperty("+cSem+"NumberOfCores"+cSem+")," + ;
        "oService:getProperty("+cSem+"NumberOfLogicalProcessors"+cSem+") })}"

can NOT work while aFind is a Memvar "outside String"

so the only Way to pass a hole Array in a Codeblock seem to be using a 
Function as i show before.

greetings by OHR
Jimmy