FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour FOR/NEXT into FOR EACH
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
FOR/NEXT into FOR EACH
Posted: Mon Jan 02, 2023 02:48 PM
hi,

i like to change FOR / NEXT into FOR EACH
Code (fw): Select all Collapse
FUNCTION GetMetaData( cPath, cFilename )
LOCAL nItem, iMax := 333
LOCAL objShell := CreateObject( "Shell.Application" )

   objFolder := objShell:Namespace( cPath )
   objFolderItem := objFolder:ParseName( cFilename )
   FOR nItem := 1 TO iMax
      cFileInfo := objFolder:GetDetailsOf( objFolderItem, nItem )
      cHeaderInfo := objFolder:GetDetailsOf( objFolder:Items, nItem )
      IF !EMPTY( cHeaderInfo ) .AND. !EMPTY( cFileInfo )
         AADD( aRet, { STRZERO( nItem, 3 ),; 
                       TRIM( cHeaderInfo ),;
                       STRTRAN( TRIM( aData[ 2 ]  ), "?", "" ) } )
      ENDIF
   NEXT
   objShell := NIL

RETURN ACLONE( aRet )
who can help me please
greeting,

Jimmy
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: FOR/NEXT into FOR EACH
Posted: Tue Jan 03, 2023 07:05 AM

Dear Jimmy,

It seems as you can't. Where do you get the 333 from ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: FOR/NEXT into FOR EACH
Posted: Tue Jan 03, 2023 08:31 PM
hi Antonio,
Antonio Linares wrote:Where do you get the 333 from ?
i have found "somewhere" that Explorer can show uo to 329 Property of File ,,, so i use 333

---

i have ask ChatGPT for CODE (using Keywords) and got
Code (fw): Select all Collapse
* Create an instance of the Shell.Application object
oSA = CREATEOBJECT( "Shell.Application" )

* Get the current namespace
oNS = CREATEOBJECT( "Namespace" )
oDir = oSA.NameSpace( oNS )

* Set the directory path
cPath = "C:\Windows"
oDir = oSA.NameSpace( cPath )

* Set the file name
cFile = "test.txt"
oFile = oDir.ParseName( cFile )

* Get the number of properties
nCount = oDir.Count

* Iterate through the properties
FOR EACH oProp IN oDir
   * Get the property name
   cName = oDir.GetDetailsOf( oProp, 0 )
   ? cName + ": "

   * Get the property value
   cValue = oFile.GetDetailsOf( oProp, 0 )
   ? cValue
ENDFOR
after re-write OOP Syntax i try to run and got Error "Count" ... but i saw FOR EACH :idea:

---

so it was not my Idea which i try to get run
greeting,

Jimmy

Continue the discussion