DC_PopFile

This forum is for eXpress++ general support.
Post Reply
Message
Author
Koverhage
Posts: 151
Joined: Mon Feb 01, 2010 8:45 am

DC_PopFile

#1 Post by Koverhage »

Hello,

i have a Problem with dc_popfile (up to build 258)

This work as expected
cNewFile := DC_PopFile(,,cFileExt,mess67,aFilters)

But if i use
cNewFile := DC_PopFile("help.txt",,cFileExt,mess67,aFilters)

and select a file e.g. "Z:\temp\help.txt

dc_popfile return Z:\temp\

The problem is at line 1647 in _dcfunct.prg
cNewFile is truncated to the length of the original cFilename

Also if i call dc_popfile with a starting file name and a default directory
it does not work as expected.

At Line 1609 it should be

Code: Select all

IF Empty(cFileName) .AND. (!Empty(cDirectory) .OR. !Empty(cWildCard))
  IF !Empty(cDirectory) .AND. Right(cDirectory,1) # '\'
    cDirectory += '\'
  ENDIF
  cFileName := cDirectory + cWildCard
ELSE
  IF !Empty(cDirectory) .AND. Right(cDirectory,1) # '\'
    cDirectory += '\'
  ENDIF
  cFileName := cDirectory + cFileName
ENDIF
Klaus

User avatar
rdonnay
Site Admin
Posts: 4813
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: DC_PopFile

#2 Post by rdonnay »

Klaus -

Thank you for reporting this and your fix.
It has obviously been this way for many years.

Here is the new code in _DCFUNCT.PRG which will be in the next release.

Code: Select all

FUNCTION DC_PopFile( cFileName, cDirectory, cWildCard, cTitle, aFileFilter, ;
                     lSaveAs, lRestoreDir, lMultiple, oParent, oOwner )

LOCAL oXbp, cNewFile, nLength

DEFAULT cFileName := '', ;
        cDirectory := '', ;
        cWildCard := '*.*', ;
        cTitle    := '', ;
        aFileFilter := {}, ;
        lSaveAs := .F., ;
        lRestoreDir := .T.,;
        lMultiple := .F.

oXbp := XbpFileDialog():new( oParent, oOwner )
oXbp:center := .T.
oXbp:restoreDir := lRestoreDir

IF !Empty(cTitle)
   oXbp:Title := cTitle
ENDIF

IF Valtype(aFileFilter)='A'
   oXbp:fileFilters := aFileFilter
ENDIF

oXbp:create(,SetAppWindow())

nLength := Len(cFileName)

IF Empty(cFileName) .AND. (!Empty(cDirectory) .OR. !Empty(cWildCard))
  IF !Empty(cDirectory) .AND. Right(cDirectory,1) # '\'
    cDirectory += '\'
  ENDIF
  cFileName := cDirectory + cWildCard
ELSE
  IF !Empty(cDirectory) .AND. Right(cDirectory,1) # '\'
    cDirectory += '\'
  ENDIF
  cFileName := cDirectory + cFileName
ENDIF

IF lSaveAs
  cNewFile := oXbp:saveAs( Alltrim(cFileName),.t. )
ELSE
  cNewFile := oXbp:open( Alltrim(cFileName),.t.,lMultiple,.t. )        // Modified S.B.Drakos 6/29/2005 0:27AM
ENDIF

oXbp:destroy()

IF Empty(cNewFile)
  RETURN cFileName
ELSE
  //cNewFile := StrTran(cNewFile,'\:\\','\\')                          // Original
  IF ValType(cNewFile) == 'A'                                          // Added S.B.Drakos 6/29/2005 0:27AM
    AEval(cNewFile,{|a| a := StrTran(a,'\:\\','\\')})                  // ...
  ELSE                                                                 // ...
    cNewFile := StrTran(cNewFile,'\:\\','\\')                          // ...
  ENDIF                                                                // ...
ENDIF

IF nLength == 0 .OR. !Empty(cFileName)
  //nLength := Len(cNewFile)                                           // Original
  IF ValType(cNewFile) == 'A'                                          // Added S.B.Drakos 6/29/2005 0:27AM
    AEval(cNewFile,{|a| nLength := Len(a), a := Pad(a,nLength)})       // ...
  ELSE                                                                 // ...
    nLength := Len(cNewFile)                                           // ...
  ENDIF                                                                // ...

ENDIF

nLength := Max(nLength,Len(cNewFile))

RETURN IIF( ValType(cNewFile) == 'A', cNewFile, Pad(cNewFile,nLength)) // Modified S.B.Drakos 6/29/2005 0:27AM

The eXpress train is coming - and it has more cars.

Post Reply