Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calling all FoxPerts!! Can capture !NDIR reply from desk
Message
 
To
22/03/1999 18:32:14
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00197830
Message ID:
00201176
Views:
16
>>>When I type !NDIR /SORT [some sortspec] in command window I can get response on FoxPro desktop ( as with most any DOS/NetWare commands) I am trying...
>>I have the code at work - give me a hint about which parts you'd like to know about.
>I'm sending to dbf also, just interested in what other info/experience others have had. I'm planning on having fields for filename, ext, last access date, pdir [foreign key for Directories.Pdir PKey] One table will have parent dirs id [pdirid] pkey [id] and name [dirname] id will be foriegn key in filename table as apposed to having full path stored. I feel breaking it up into smaller pieces [DIR,SUBDIR,FILENAME,EXT,DATE..] will make for easier management and enhancements down the road. I also understand this may be overkill. Next step I plan is to use this table to generate a listfile for PKZip to move files off server into zipfile on local drive that I can dump onto zipdrive for archiving. One caveat I'm current dealing with a sure fire way to take line I've pulled out of file created with !NIR /sortspec >Files.txt and test for valid filename.
>Currently I'm testing the 1st byte of that line for alpha/numeric if so grab 1st 12 bytes (8.3) using FILE() to test for valid file if so INSERT INTO dbf. Any code, comments, suggestions or pitfalls greatly appreciated.

*************************************
PROCEDURE CleanACAD
*************************************
*
* This procedure erases all AutoCAD files
* not accessed in months
*
*
*************************************
declare integer SetFileAttributes IN kernel32 AS SetAtt STRING, INTEGER
* The above allows for attribute setting to remove ReadOnly
SET DEFAULT TO G:\ACAD\projects\
USE F:\APPS\CADD\DRAWINGS SHARED ORDER PATH
Temp_Name=SYS(3)+".DIR"
*Temp_Name="141707.DIR"
DO CASE
CASE DOW(DATE()) = 1 && It's Sunday Morning.
WAIT WINDOW "Running NDIR.PIF G:\ACAD\PROJECTS\*.BAK /D /FO /S > " + Temp_Name NOWAIT
RUN NDIR G:\ACAD\PROJECTS\*.BAK /D /FO /S > &Temp_Name
CASE DOW(DATE()) = 2 && It's Monday Morning.
WAIT WINDOW "Running NDIR.PIF G:\ACAD\PROJECTS\*.DWG /D /FO /S > " + Temp_Name NOWAIT
RUN NDIR G:\ACAD\PROJECTS\*.DWG /D /FO /S > &Temp_Name
CASE DOW(DATE()) = 3 && It's Tuesday Morning.
WAIT WINDOW "Running NDIR.PIF G:\ACAD\PROJECTS\*.PLT /D /FO /S > " + Temp_Name NOWAIT
RUN NDIR G:\ACAD\PROJECTS\*.MGT /D /FO /S >> &Temp_Name
CASE DOW(DATE()) = 4 && It's Wednesday Morning.
WAIT WINDOW "Running NDIR.PIF G:\ACAD\PROJECTS\*.ZIP /D /FO /S > " + Temp_Name NOWAIT
RUN NDIR G:\ACAD\PROJECTS\*.KEY /D /FO /S >> &Temp_Name
ENDCASE
WAIT WINDOW "Finished running NDIR > " + Temp_Name NOWAIT
mHandle1=FOPEN(Temp_name)
DO Init_Thermometer
RDSize=1000
OldCount=0
OrphanCount=0
TempCount=0
m.EXT=""
DO WHILE !FEOF(mHandle1)
Curr_Line=ALLTRIM(FGETS(mHandle1))
DO CASE
CASE AT("\*.",Curr_Line)>0 && It's the path line
SCATTER MEMVAR MEMO BLANK && Ready for next file
StartLoc=RAT(":",Curr_Line)+1
SubLen=RAT("\",Curr_Line)-StartLoc+1
m.Directory="\"+SUBSTR(Curr_Line, StartLoc, SubLen) && Path ending with \
m.lshProjNo=SUBSTR(m.directory,AT("\",m.directory,3)+1,AT("\",m.directory,4)-AT("\",m.directory,3)-1)
CASE Left(Curr_Line,4)="DOS:" && It's the filename
m.Ext=RIGHT(Curr_Line,3) && File Extension
StartLoc=7
SubLen=RAT(".",Curr_Line)-StartLoc
m.Dwg_Name=ALLTRIM(SUBSTR(Curr_Line,StartLoc,SubLen)) && File Name
CASE LEFT(Curr_Line,6)="Owner:" && File Owner
StartLoc=RAT(":",Curr_Line)+1
SubLen=Len(Curr_Line)-StartLoc+1
m.File_Owner=ALLTRIM(SUBSTR(Curr_Line,StartLoc,SubLen))
CASE "Last update:" $ Curr_Line && Last Update
m.Last_Rev = CTOD(SubStr(Curr_Line,AT("/",Curr_Line)-2,8))
CASE "Last accessed:" $ Curr_Line && Last Update
m.LastAccess= CTOD(SubStr(Curr_Line,AT("/",Curr_Line)-2,8))
CASE "Created/Copied:" $ Curr_Line && Last Update
m.Created = CTOD(SubStr(Curr_Line,AT("/",Curr_Line)-2,8))
CASE "File size:" $ Curr_Line && End of Record - process it!
FullPath = m.Directory + m.Dwg_Name && No Extension here!
IF m.Ext = "DWG"
WAIT WINDOW "Processing " + FullPath + "." + m.EXT NOWAIT
DO CASE
CASE m.LastAccess < DATE()-OLD_DATE && and it's 1 year old!
IF SEEK(Fullpath) && Record Exists
REPLACE Drawings.Purged WITH .T.
ELSE
m.Purged=.T.
DO Get_Cadd
APPEND BLANK
GATHER MEMVAR MEMO
ENDIF
FullPath = FullPath + ".DWG"
* RUN /N2 ATTRIB -R &FullPath
mbhtemp = SetAtt(FullPath,0)
WAIT WINDOW "We erased " + FullPath + " because it's old." NOWAIT
ERASE &FullPath
OldCount=OldCount+1
CASE ("TEMP" $ m.Dwg_Name .OR. "TMP" $ m.Dwg_Name) .AND. m.LastAccess < DATE()-14
FullPath = FullPath + "." + m.EXT
* RUN /N2 ATTRIB -R &FullPath
mbhtemp = SetAtt(FullPath,0)
WAIT WINDOW "We erased " + FullPath + " because it's a temp file." NOWAIT
ERASE &FullPath
TempCount=TempCount+1
OTHERWISE && It's a valid DWG file
IF SEEK(Fullpath) && Record Exists
IF Drawings.LastAccess <> m.LastAccess && File has been Revised
m.DESCRIPT = "AutoCAD Drawing" && Extract Info from MGT File
GATHER MEMVAR MEMO
ENDIF
ELSE Record does NOT Exist
m.DESCRIPT = "AutoCAD Drawing"
APPEND BLANK
GATHER MEMVAR MEMO
ENDIF
SCATTER MEMVAR MEMO BLANK && Ready for next file
ENDCASE
ENDIF
IF (m.Ext = "BAK" .OR. m.Ext = "PLT") .AND. m.LastAccess < DATE()-14
FullPath = FullPath + "." + m.EXT
* RUN /N2 ATTRIB -R &FullPath
mbhtemp = SetAtt(FullPath,0)
WAIT WINDOW "We erased " + FullPath + " because it's a backup or plot file." NOWAIT
ERASE &FullPath
OrphanCount=OrphanCount+1
ENDIF
ENDCASE
DO Update_Thermometer
ENDDO
=FCLOSE(mHandle1)
ERASE &Temp_Name
cTo = "Admin @ lshchicago.com"
cFrom = "ADMIN"
cSubj = "Deleted AutoCAD Files"
cMsg = "There were "+ALLTRIM(STR(OldCount))+" old files deleted during the last run." + ;
" There were "+ALLTRIM(STR(OrphanCount))+" plt or bak files deleted during the last run." + ;
" There were "+ALLTRIM(STR(TempCount))+" old Temp files deleted during the last run." + ;
" Drawing files are deleted if not touched for > " + ALLTRIM(STR(OLD_DATE)) + " days. Thank you."
=MHS_SEND(cTo,cFrom,cSubj,cMsg)
SET SAFETY OFF
SELECT lshprojno FROM drawings DISTINCT INTO TABLE F:\apps\cadd\Projects.dbf
SET SAFETY ON
USE IN Projects
USE IN Drawings
Kogo Michael Hogan

"Pinky, are you pondering what I'm pondering?"
I think so Brain, but "Snowball for Windows"?

Ideate Web Site
Previous
Reply
Map
View

Click here to load this message in the networking platform