FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour WMI / FOR EACH / does "Property" Exist ?
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
WMI / FOR EACH / does "Property" Exist ?
Posted: Tue Jun 13, 2023 04:27 AM
hi,

i use WMI to ask for some Hardware Information like RAM
Code (fw): Select all Collapse
   FOR EACH oMemory IN oWmi:ExecQuery( "SELECT * FROM Win32_PhysicalMemory" )
       nSumRAM += VAL( oMemory:Capacity )
       cFormFactor := GetFormFaktorText( oMemory:FormFactor )
       cMemoryType := GetRAMtype( oMemory:SMBIOSMemoryType )

       // ask for "SPEED"
       IF __ObjHasData( oMemory, "SPEED" )
       IF __ObjHasMethod( oMemory, "SPEED" )
both IF __Obj* give me .F. :?

but this work
Code (fw): Select all Collapse
       cSpeed := oMemory:Speed
       cSpeed := oMemory:GETPROPERTY("SPEED")
Problem : it does not work on every PC
if i use TRY / CATCH / END than line after Error will not execute

so how to "ask" in FOR EACH if a "Property" Exist :?:
greeting,

Jimmy
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: WMI / FOR EACH / does "Property" Exist ?
Posted: Tue Jun 13, 2023 01:13 PM
__ObjHasData and __ObjHasMethod work only with Harbour classes.
if i use TRY / CATCH / END than line after Error will not execute
Suggested:
Code (fw): Select all Collapse
TRY
  speed := o:Speed
CATCH
  speed := 0
END
? speed
so how to "ask" in FOR EACH if a "Property" Exist
FOR EACH works with Harbour Arrays and objects only.

Can you please share with us how are you now doing this with HMG, to help me to learn more about this subject?
Regards



G. N. Rao.

Hyderabad, India
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: WMI / FOR EACH / does "Property" Exist ?
Posted: Tue Jun 13, 2023 04:51 PM
hi,

thx for Answer

under Xbase++ "Property" aof COM/ActiveX are same as Member VAR (DATA)
Eigenschaft (engl.: Property)
Instanzvariable einer COM/ActiveX-Komponente, entspricht einer Membervariablen (IVar) eines Xbase++-Objektes.
thats why i try __ObjHasData but fail

-
Code (fw): Select all Collapse
   TRY
      a := 1
      b := 1/0
      c := "not execute"
   CATCH
      FWLOG a,b,c
   END
as "b" gave a Error Line with "c" will not be execute
i have to use it for every "Property" to CATCH Error
greeting,

Jimmy
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: WMI / FOR EACH / does "Property" Exist ?
Posted: Tue Jun 13, 2023 04:58 PM
i have to use it for every "Property" to CATCH Error
Yes.
Better we make a function with TRY/CATCH
under Xbase++ "Property" aof COM/ActiveX are same as Member VAR (DATA)
That's nice. Good to know.
What about HMG?
ps: I am asking because I never used them
Regards



G. N. Rao.

Hyderabad, India
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: WMI / FOR EACH / does "Property" Exist ?
Posted: Tue Jun 13, 2023 05:15 PM
hi,
nageswaragunupudi wrote:What about HMG?
ps: I am asking because I never used them
i did not know __Obj* Function until Antonio told me so i have not use it under HMG
i will ask in HMG Forum if they have a Solution
greeting,

Jimmy

Continue the discussion