Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can this VFP code be faster? (File Expansion)
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01068953
Message ID:
01070540
Vues:
28
Tracy,

There are some general tips on this.

First, test for the nominal case first. For example, if a = b is usually true then
llresult = (a = b)
IF llresult THEN
  * Code here
ENDIF
RETURN llresult
is better than
IF NOT (a = b) THEN
  RETURN .F.
ELSE
  * Code here
ENDIF
This applies to ordering CASE statements as well.

Since this has to do with I/O performance may be affected by how many other applications are running. If it takes long enough, if the screen saver activates that can really slow things down.

In the former case, you might want to prompt the user to shutdown all other apps. In the latter, I've a class in the download section that'll allow you to turn the screen saver off before beginning the procedure, and back on afterwards.

Some general notes follow...

>Other than the progress display, any ideas on how to speed this code up?
PARAMETERS lcAl3File
* Is the below the nominal case?
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)
* I'd make 'AL3.NET' a variable, it'll make the 
* program small and referencing the varible is
* just as fast as the literal. Plus, if you want 
* to ever change the filename, there's only one
* place you'll have to do it.
* You could also do this
* IF (lcA13File == JUSTSTEM(lcA13File)) THEN
*   lcAL3NewFile = ADDBS(JUSTPATH(lcA13File)) + 'AL3.NEW'
* ELSE
*    tdir + 'AL3.NEW'
* ENDIF
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
* Again, what's the nominal case?
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)
* Nominal case?
IF m.output < 0
   WAIT WINDOW "An error ocurred expanding the file. Press anykey..."
   RETURN
ENDIF


************************
PROCEDURE Hex2Dec
************************
* Convert Hex 00 - FF to decimal 0 - 255

PARAMETER hexvalue2
* Why not, RETURN EVALUATE('0x' + hexvalue2)?
RETURN (DECIVALUE(LEFT(hexvalue2,1))*16) + DECIVALUE(RIGHT(hexvalue2,1))
George

Ubi caritas et amor, deus ibi est
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform