Help with PATH problems

Xbase++ 2.0 Build 554 or later
Post Reply
Message
Author
User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Help with PATH problems

#1 Post by rdonnay »

The \exp20\util folder now contains a file named PATHFOUND.PRG and PATHFOUND.EXE.
This utility searches your path for each occurrence of a file to help debug pathing problems.

Usage:

PATHFOUND ace32.dll will search the path established by SET PATH for aced32.dll.

PATHFOUND dcdialog.ch INCLUDE will search the path established by SET INCLUDE for dcdialog.ch.

Here is the source code:

Code: Select all

#INCLUDE "dcdialog.CH"

FUNCTION Main ( cFileName, cEnv )

LOCAL cFilePath, nPointer, cFileDir, aFiles[0], i, GetList[0], aDir, ;
      nLength := 0

IF Empty(cEnv)
  cEnv := 'PATH'
ENDIF
cEnv := Upper(cEnv)

cFilePath := GetEnv(cEnv)

DO WHILE .t.
  nPointer := AT(';',cFilePath)
  cFileDir := ''
  IF nPointer > 0
    cFileDir := ALLTRIM(SUBSTR( cFilePath, 1, nPointer-1 )) + '\'
    IF File( cFileDir+cFileName )
      nLength := Max(Len(cFileDir+cFileName),nLength)
      aDir := Directory(cFileDir+cFileName)
      AAdd(aFiles, {.f.,cFileDir + cFileName, aDir[1] })
    ENDIF
    cFilePath := SUBSTR( cFilePath, nPointer + 1 )
  ELSE
    cFileDir := ALLTRIM(cFilePath) + '\'
    IF !File(cFileDir+cFileName)
      cFileDir := ''
    ENDIF
    EXIT
  ENDIF
ENDDO

IF Empty(aFiles)
  DCMSGBOX 'File: ' + cFileName + ' not found in ' + cEnv + ' environment'
  RETURN .f.
ENDIF


@ 1,7 DCSAY 'Folder Name' SAYSIZE 0 FONT '12.Lucida Console Bold'
@ 1, 95 DCSAY ' Size     Date      Time' FONT '12.Lucida Console Bold' SAYSIZE 0

FOR i := 1 TO Len(aFiles)
  @ i+2,0 DCSAY Str(i,2) SAYSIZE 0 FONT '12.Lucida Console Bold' SAYBOTTOM
  @ i+2,5 DCCHECKBOX aFiles[i,1] PROMPT Pad(aFiles[i,2],nLength) FONT '11.Lucida Console'
  @ i+2,95 DCSAY ;
        DC_XtoC(aFiles[i,3,2]) + '   ' + ;
        DC_XtoC(aFiles[i,3,3]) + '   ' + ;
        DC_XtoC(aFiles[i,3,4]) ;
        FONT '12.Lucida Console' SAYSIZE 0
NEXT

@ i + 3 DCPUSHBUTTON CAPTION 'Delete Checked File(s)' SIZE 20,1.2 ;
     ACTION {||DeleteCheckedFiles(aFiles)}

DCREAD GUI FIT TITLE 'File(s) found in ' + cEnv + ' environment'

RETURN nil

* ---------

PROC appsys ; return

* ---------

STATIC FUNCTION DeleteCheckedFiles(aFiles)

LOCAL i, nCount := 0

FOR i := 1 TO Len(aFiles)
  IF aFiles[i,1]
    Ferase(aFiles[i,2])
    nCount++
  ENDIF
NEXT

DCMSGBOX Alltrim(Str(nCount)) + ' files deleted!'

RETURN nil
Here is a screen shot:
Capture.JPG
Capture.JPG (41.1 KiB) Viewed 6270 times
The eXpress train is coming - and it has more cars.

Post Reply