' Name: List_Themes
' Title: List all themes in APR file (Slopek P)
' Author: Peter Slopek
' Date: 02-05-2002 10:54
' Requires: System.GetFileDates
' ArcView -- www.quantdec.com
' Description: Original Question: Can someone tell me how to retrieve a file's creation
' date/time? I need to be able to tell when a shapefile was created.
'I apologize for the late SUM - I hoped to implement a solution before
'summing, and then the project specs changed, and I no longer needed to know
'the file's date/time.
'However, I would like to thank the following people for responding to my
'question: Gary Greenberg, Gordon Chinander, Andy Wright, Chris Beckom,
'Madhavi Latha, Ben Logan and Peter Slopek.
'I suspected that the final solution would involve an WinAPI call, and I was
'right.
'Chris sent me an ArcView project called filefunctions.apr that he had picked
'up someplace, but couldn't remember where. It turned out the .apr is
'available from the ArcScripts web page. This apr includes example code for
'doing a number of file functions - it did not include an example for
'retrieving the file date/time, but it did include an example for copying a
'file, which is something I've wanted to know how to do for other scripts
'I've written. He also sent a link to a web site that has a downloadable
'reference to the api calls: http://www.vbapi.com. I checked out the site,
'but couldn't figure out how to find what I wanted - this is my first foray
'into WinAPI.
'Sample code to do what I asked was provided by Peter. He provided 2 scripts
'which are used to create a .dbf file showing the source file path, type
'(polygon, point, etc), theme definition, file date, and file time. The
'script code is found below. One note - it reports the date in European
'format (d/m/y), so you might need to modify the data format in the a =
'av.run("GetFDT",{fname,TRUE,"dd.MM.yy","HH:mm"}) line of code in the List of
'Themes script if you want to use the scripts. The List of Themes script is
'used as a click script on a button/menu item.
'Terese Rowekamp
'============================
'List of Themes script
'Program to list themes and tables in project
'This program will find all the views in a project,
' and then all the themes in each view.
'It will create a table with
' fields View , Theme , Source (the path to the theme) and Typ.
theFName = ("ThemeList.dbf".AsFileName)
theFName = FileDialog.Put(theFName,"*.dbf","List of Themes")
if (nil=theFName) then
return nil
end
srctable = vtab.makenew(theFname,dbase)
viewname = field.make("View",#FIELD_CHAR,40,0)
ThemeName = field.Make("Theme",#FIELD_CHAR,40,0)
SourceName = field.make("Source",#FIELD_CHAR,80,0)
TypName = field.make("Typ",#FIELD_CHAR,20,0)
DefName = field.make("Deftion",#FIELD_CHAR,80,0)
DateName = field.make("date",#FIELD_CHAR,10,0)
TimeName = field.make("time",#FIELD_CHAR,5,0)
fieldlist = {viewname,themename,sourcename,typname,defName,DateName,TimeName}
srctable.addfields(fieldlist)
viewnamefield = srctable.findfield("View")
themenamefield = srctable.findfield("Theme")
sourcenamefield = srctable.findfield("Source")
typnamefield = srctable.findfield("Typ")
defnamefield = srctable.findfield("Deftion")
datenamefield = srctable.findfield("date")
timenamefield = srctable.findfield("time")
srctable.starteditingWithRecovery
docs = av.getproject.getdocs
fname = "Undetermined"
fdate = "Unknown"
ftime = "00:00"
sname = "None"
defn = "None"
aprFile = av.GetProject.GetFileName
fname = aprFile.AsString
theDateStr = av.run("System.GetFileDates",{fname,"w"})
fdate = theDateStr.Left(10)
ftime = theDateStr.Middle(12,5)
srctable.begintransaction
rec = srctable.addrecord
srctable.setvalue(viewname,rec,av.GetProject.asstring)
srctable.setvalue(themename,rec,av.GetProject.asstring)
srctable.setvalue(sourcenamefield,rec,fname)
srctable.setvalue(typnamefield,rec,"Project")
srctable.setvalue(datenamefield,rec,fdate)
srctable.setvalue(timenamefield,rec,ftime)
srctable.setvalue(defnamefield,rec,defn)
for each d in docs
cl = d.getclass.getclassname
if (cl="view") then
thethemes = d.getthemes
themesource = {}
for each t in thethemes
sourcename = t.getsrcname
fname = t.getsrcname.getdatasource
sname = t.getsrcname.GetSubName
if (fname="") then
fname = "Undetermined"
fdate = "Unknown"
ftime = "00:00"
sname = "None"
defn = "None"
else
'a = av.run("GetFDT",{fname,TRUE,"yyyy.MM.dd","HH:mm"}) 'could not find this script!
'c = Creation-Date
'a = Last Access
'w = Last Writing-Access:
theDateStr = av.run("System.GetFileDates",{fname,"w"})
fdate = theDateStr.Left(10)
ftime = theDateStr.Middle(12,5)
if ((t.GetClass.GEtClassName="ITheme").not) then
defn = t.GetFtab.GetDefinition
else
defn = "None"
sname = "Image"
end
end
'allname = sourcename.asstring +" "+ fname + sname
'themesource.add(allname)
srctable.begintransaction
rec = srctable.addrecord
srctable.setvalue(viewname,rec,d.asstring)
srctable.setvalue(themename,rec,t.asstring)
srctable.setvalue(sourcenamefield,rec,fname)
srctable.setvalue(typnamefield,rec,sname)
srctable.setvalue(datenamefield,rec,fdate)
srctable.setvalue(timenamefield,rec,ftime)
srctable.setvalue(defnamefield,rec,defn)
end
elseif (cl="Table") then
'v = " "
'tema = d.GetName.asstring
'zdroj = d.GetVtab.GetBaseTableFileName
'sname = "Table"
'a = av.run("GetFDT",{fname,TRUE,"yyyy.MM.dd","HH:mm"})
'fdate = a.Get(0)
'ftime = a.Get(1)
'srctable.begintransaction
'rec = srctable.addrecord
'srctable.setvalue(viewname,rec,v)
'srctable.setvalue(themename,rec,tema)
'srctable.setvalue(sourcenamefield,rec,zdroj.asstring)
'srctable.setvalue(typnamefield,rec,sname)
'srctable.setvalue(datenamefield,rec,fdate)
'srctable.setvalue(timenamefield,rec,ftime)
end
end
srctable.stopeditingwithrecovery(true)
if (MsgBox.YesNo("Add table to project?","ADD TABLE",true)) then
newTable = Table.Make(srctable)
newTable.SetName(srctable.GetName)
newTable.GetWin.Open
end