Changes in build 255 (beta - not released yet)

Postings of changes to eXpress++ and/or XCodeJock

Changes in build 255 (beta - not released yet)

Postby rdonnay » Tue Mar 02, 2010 4:04 pm

1107. New function: DC_FileNameDupe() returns the next file name in a series
so multiple files of the same name may be saved in the same directory.

1106. Fixed a regression bug in DC_GetWhen() when using a menu system that
was not created using eXpress++ DCMENU*.commands.

1105. Fixed a regression bug in DC_GraPaintControls(). This function is
called only when using DCGRA* commands.

1104. DCSTATIC and DCGROUP objects will now behave correctly when using the
WHEN clause. Child objects will be properly disabled.

1103. Added a COLOR clause to DCMSGBOX.

1102. Fixed regression error in DCPUSHBUTTON STATIC and DCBARCHART.

1101. Lots of improvements to the XCodeJock system. See sample programs.

1100. Added keyboard tagging to the TAGENABLE feature of DCBROWSE. Now can
use Ctrl-Up, Ctrl-Down and Space bar for tagging/untagging.

1099. Added new WHEN and REFRESHBLOCK subclauses to the AUTOREFRESH clause of
@ DCBROWSE.

Example: @ .. DCBROWSE .. AUTOREFRESH 1000 WHEN {||NotBusy()} ;
REFRESHBLOCK {||MyRefreshRoutine()}

1098. New function: DC_WindowList().
The eXpress train is coming - and it has more cars.
User avatar
rdonnay
Site Admin
 
Posts: 422
Joined: Thu Jan 28, 2010 1:58 am
Location: Boise, Idaho USA

New function: DC_FileNameDupe()

Postby rdonnay » Tue Mar 02, 2010 6:40 pm

Here is a new function that is used to check if a file already exists and assigns a duplicate name.
This allows files with the same name to be saved in the same directory as follows:

myprg.prg
myprg(1).prg
myprg(2).prg

The function is used as follows:
Code: Select all
cText := 'Some text'
cFileName := DC_FileNameDupe('C:\download\readme.txt')
MemoWrit( cFileName, cText )


Code: Select all
FUNCTION DC_FileNameDupe( cFileName )

LOCAL aDir, cPrimary, cExtension, i, cChar, nStart, nEnd, nCount

IF '.' $ cFileName
  FOR i := Len(cFileName) TO 1 STEP -1
    cChar := cFileName[i]
    IF cChar == '.'
      cPrimary := Substr(cFileName,1,i-1)
      cExtension := Substr(cFileName,i)
      EXIT
    ENDIF
  NEXT
ELSE
  cPrimary := cFileName
  cExtension := ''
ENDIF

aDir := Directory( cPrimary + '*' + cExtension )

ASort(aDir,,,{|a,b|a[1]<b[1]})

IF Len(aDir) > 1
  IF Upper(Alltrim(Atail(aDir)[1])) == Upper(Alltrim(cFileName))
    cFileName := aDir[Len(aDir)-1][1]
    nStart := 0
    nEnd := 0
    FOR i := Len(cFileName) TO 1 STEP -1
      cChar := cFileName[i]
      IF cChar == ')'
        nEnd := i
      ELSEIF cChar == '('
        nStart := i
        EXIT
      ENDIF
    NEXT
    IF nStart > 0 .AND. nEnd > 0
      nCount := Val(Substr(cFileName,nStart+1,nEnd-nStart-1))
      cFileName := Strtran(cFileName, ;
                   '('+Alltrim(Str(nCount)) + ')', ;
                   '('+Alltrim(Str(nCount+1)) + ')')
    ENDIF
  ELSE
    cFileName := cFileName
  ENDIF
ELSEIF Len(aDir) == 1
  cFileName := cPrimary + '(1)' + cExtension
ELSE
  cFileName := cFileName
ENDIF

RETURN cFileName
The eXpress train is coming - and it has more cars.
User avatar
rdonnay
Site Admin
 
Posts: 422
Joined: Thu Jan 28, 2010 1:58 am
Location: Boise, Idaho USA

Re: Changes in build 255 (beta - not released yet)

Postby bwolfsohn » Tue Mar 02, 2010 7:25 pm

Roger,

This is what we use.. it seems much more straightforward..
it could be easily modified to handle (1) (2) etc

So, what am i missing..

Code: Select all
cLastZip := cFilename + '_0000.ZIP'
cNextZip := DC_NumIncr( cLastZip )
  // 6/22/2009 12:35PM do not allow duplicate zip names
do while fexists(cTargetDir +'\' + cNextZip)
   cNextZip := DC_NumIncr( cLastZip )
enddo



Brian
bwolfsohn
 
Posts: 48
Joined: Thu Jan 28, 2010 2:07 pm
Location: Southwest Ranches, Florida USA

Re: Changes in build 255 (beta - not released yet)

Postby rdonnay » Tue Mar 02, 2010 7:37 pm

I thought about using DC_NumIncr() but it didn't work for every possibility of file names.

Bobby has names like this:

DriverRegistration_23456.jpg

This may be more code, but I feel that it is more reliable.
The eXpress train is coming - and it has more cars.
User avatar
rdonnay
Site Admin
 
Posts: 422
Joined: Thu Jan 28, 2010 1:58 am
Location: Boise, Idaho USA


Return to Changes

Who is online

Users browsing this forum: No registered users and 1 guest