File dates

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Templar
Posts: 51
Joined: Sun Apr 01, 2018 5:37 pm
DBs Used: DBF

Re: File dates

Post by Templar »

I was using:

* Program...: AA01.prg
*
#include <hmg.ch>
SETMODE(25,80)

PROCEDURE MAIN
Local oFSO, oFS, cDate
oFSO := CreateObject("Scripting.FileSystemObject")
oFS := oFSO:GetFolder( "C:\*.*" )
cDate := oFS:DateCreated
@3,3 SAY cDate

INKEY(0)
Return

* EOF(): AA01.prg

and this produces the error result: What am I doing wrong? !!
Attachments
ERROR.png
ERROR.png (5.28 KiB) Viewed 3077 times
User avatar
mustafa
Posts: 1175
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: File dates

Post by mustafa »

Hi Templar

See the modification of Daniel's Sample
which was also giving me ERROR

https://www.hmgforum.com/viewtopic.php?f=5&t=6427

Mustafa
Templar
Posts: 51
Joined: Sun Apr 01, 2018 5:37 pm
DBs Used: DBF

Re: File dates

Post by Templar »

Mmm. That runs forever until I stop it with Task Manager! Something funny going on...
Templar
User avatar
serge_girard
Posts: 3364
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: File dates

Post by serge_girard »

Templar,

Error arises when you try:

Code: Select all

oFS                  := oFSO:GetFolder( 'c:\*.*')
Try this with existing foldername!

Code: Select all

DirQz  = 'c:\test'  // or whatever existing foldername!!!!!
oFS                  := oFSO:GetFolder( DirQz )
Serge
There's nothing you can do that can't be done...
Templar
Posts: 51
Joined: Sun Apr 01, 2018 5:37 pm
DBs Used: DBF

Re: File dates

Post by Templar »

That was what I tried buit no different! I put it into a variable, and tried setting that to "C:\" and also "C:\windows" and "C:\windows\*.*"
and got the same error message each time. Very odd!
User avatar
serge_girard
Posts: 3364
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: File dates

Post by serge_girard »

Try this:

"C:\windows\"
There's nothing you can do that can't be done...
Templar
Posts: 51
Joined: Sun Apr 01, 2018 5:37 pm
DBs Used: DBF

Re: File dates

Post by Templar »

That's what just runs forever until I close it with TaskManager. It does seem odd. Does that work for you?
KDJ
Posts: 243
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland

Re: File dates

Post by KDJ »

Templar

For console mode:

Code: Select all

REQUEST HB_GT_WIN_DEFAULT

FUNCTION Main()
  LOCAL cFolder := "C:\Windows"
  LOCAL oFSO    := CreateObject("Scripting.FileSystemObject")
  LOCAL oFolder
  LOCAL tCreated

  SetMode(25, 80)

  @ 3,3 SAY "Folder:"
  @ 4,3 SAY cFolder

  IF oFSO:FolderExists(cFolder)
    oFolder := oFSO:GetFolder(cFolder)

    IF ! oFolder:IsRootFolder
      tCreated := oFolder:DateCreated

      @ 5,3 SAY "has been created: " + hb_TStoStr(tCreated)
    ELSE
      @ 5,3 SAY "is root folder!"
    ENDIF
  ELSE
    @ 5,3 SAY "does not exist!"
  ENDIF

  InKey(0)

RETURN NIL
For GUI mode:

Code: Select all

#include "hmg.ch"

FUNCTION Main()
  LOCAL cFolder := "C:\Windows"
  LOCAL oFSO    := CreateObject("Scripting.FileSystemObject")
  LOCAL oFolder
  LOCAL tCreated

  IF oFSO:FolderExists(cFolder)
    oFolder := oFSO:GetFolder(cFolder)

    IF ! oFolder:IsRootFolder
      tCreated := oFolder:DateCreated

      MsgBox("Folder:" + CRLF + cFolder + CRLF + "has been created: " + hb_TStoStr(tCreated), "Success")
    ELSE
      MsgBox("This is root folder:" + CRLF + cFolder, "Error")
    ENDIF
  ELSE
    MsgBox("Folder does not exist:" + CRLF + cFolder, "Error")
  ENDIF

RETURN NIL
Templar
Posts: 51
Joined: Sun Apr 01, 2018 5:37 pm
DBs Used: DBF

Re: File dates

Post by Templar »

Sir: you are a genius! Thank you very much.

(I will, one of these days, try going onto GUI mode, but my program comprises 60 program files, each about 800 lines, so not far short of 50,000 lines of code altogether and I don't think I am young enough to gte it done during my life time!

Templar
Templar
Posts: 51
Joined: Sun Apr 01, 2018 5:37 pm
DBs Used: DBF

Re: File dates

Post by Templar »

Hold on!! How do I now extract the date element from the variable "tCreated" ? What I need to be able to do is check the date returned (ie the date the directory was created) against the date it should be. It's a "T" type variable and I need to change it either to a character string or a Date variable.
Any suggestions?
Templar
Post Reply