Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can this VFP code be faster? (File Expansion)
Message
De
15/11/2005 14:28:37
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Can this VFP code be faster? (File Expansion)
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01068953
Message ID:
01068953
Vues:
160
Other than the progress display, any ideas on how to speed this code up?
PARAMETERS lcAl3File
IF TYPE('lcAl3File')="L" .OR. EMPTY(lcAl3File)   && no path sent so look for it in temp folder
   RETURN .F.
ENDIF
PRIVATE lcat
lcat=0
lcat=RAT("\",lcAl3File)
IF lcat>0
   PRIVATE lcAL3NewFile
   lcAL3NewFile=LEFT(lcAl3File,lcat)+'AL3.NEW'
ELSE          && no path available so store it in the temporary folder
   lcAL3NewFile=tdir+'AL3.NEW'
ENDIF
m.handle = FOPEN(lcAl3File,0)
IF m.handle < 0
   WAIT WINDOW "Could not open Download file."
   RETURN
ELSE
   m.sizeof = FSEEK(m.handle,0,2)
ENDIF
m.output = FCREATE(lcAL3NewFile,0)
IF m.output < 0
   WAIT WINDOW "An error ocurred expanding the file. Press anykey..."
   RETURN
ENDIF
IF TYPE('oprogress')="O" .and. !ISNULL(oprogress)
   oprogress.RELEASE()
ELSE
   oprogress = NULL
   RELEASE oprogress
ENDIF
=SYS(1104)
oprogress = CREATEOBJECT('therm',m.sizeof,lcAl3File)
oprogress.CAPTION = "IVANS TRANSFER - File Expansion Step 1 of 3"
oprogress.VISIBLE = .T.
Y=0
=FSEEK(m.handle,0)
PRIVATE llabortall
llabortall = .F.
ON KEY LABEL ALT+F10 DO abortall
DO WHILE !FEOF(m.handle)
   IF llabortall
      EXIT
   ENDIF
   m.line=FREAD(m.handle,1)
   Y=Y+LEN(m.line)
   oprogress.updatetherm(Y)
   IF m.line = CHR(250)
      m.count=Hex2Dec(FREAD(m.handle,2))
      m.expChar = FREAD(m.handle,1)
      =FWRITE(m.output,REPLI(m.expChar,m.count))
   ELSE
      =FWRITE(m.output,m.line)
   ENDIF
ENDDO
=FCLOSE(m.handle)
=FCLOSE(m.output)
FLUSH
IF !llabortall
   IF FILE(lcAL3NewFile)
      IF " " $ lcAL3NewFile
         lcAL3NewFile = "'"+lcAL3NewFile+"'"
      ENDIF
      IF " " $ lcAl3File
         lcAl3File = "'"+lcAl3File+"'"
      ENDIF
      COPY FILE &lcAL3NewFile TO &lcAl3File
   ENDIF
ENDIF
IF TYPE('oprogress')="O" .and. !ISNULL(oprogress)
   oprogress.RELEASE()
ELSE
   oprogress = NULL
   RELEASE oprogress
ENDIF
ON KEY LABEL ALT+F10
IF FILE(lcAL3NewFile)
   DELETE FILE (lcAL3NewFile)
ENDIF
IF llabortall
   RETURN .F.
ELSE
   RETURN .T.
ENDIF

************************
PROCEDURE Hex2Dec
************************
* Convert Hex 00 - FF to decimal 0 - 255
PARAMETER hexvalue2
RETURN (DECIVALUE(LEFT(hexvalue2,1))*16)+DECIVALUE(RIGHT(hexvalue2,1))

************************
PROCEDURE DECIVALUE
************************
* Convert single hex number into decimal

PARAMETER hexvalue1
RETURN AT(hexvalue1,'0123456789ABCDEF')-1

PROCEDURE abortall
llabortall = .T.
RETURN
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform