Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Parameters Command Giving .F
Message
De
03/02/2014 11:49:48
Mike Yearwood
Toronto, Ontario, Canada
 
 
À
02/02/2014 11:35:13
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01592937
Message ID:
01593014
Vues:
56
Hi Harsh

LOCAL variables are restricted to the current code. That is the best way to go. I congratulate your choice. Because they are restricted you must pass them to called routines/modules/components. Others might suggest you use PRIVATE so they would be visible to the called module. That is a riskier approach. You should aim to make your routines encapsulated.

You could do this...
LOCAL lcPSFILEPATH, lcNEWPATH
Select NEW_BILLS
Scan  && Scans for New_bills up to EOF()
lcPSFILEPATH=Alltrim(NEW_BILLS.oldpath)
lcNEWPATH=Alltrim(NEW_BILLS.NEWPATH)

DO Compress with m.lcPSFILEPATH, m.lcNEWPATH

ENDSCAN
Use LPARAMETERS not PARAMETERS
Change the variable names to indicate they are received in this routine
and are not the same ones DEFINED in the calling program.
The reason is the compress module is then completely self-contained - "encapsulated".
PROCEDURE Compress
LPARAMETERS m.tcPSFILEPATH,m.tcNEWPATH
Create Cursor BILLCOMPRESS (POS C(254))  && Create Temporary Cursor Billcompress to Check Page Numbers,Compressed File and Invoice Date.
Select BILLCOMPRESS
WAIT WINDOW m.tcPSFILEPATH
WAIT WINDOW m.tcNEWPATH
Append From (m.tcPSFILEPATH) Sdf  && Nothing is appeneded as I get .F. as value for m.tcPSFILEPATH
ENDPROC
BUT - I would have created cursor billcompress in the calling code. Your compress routine is not doing anything significant yet. It will be slow. The cursor is destroyed and recreated as the scan runs. This is what I have been asking you to do. Explain what you want to do then we can show you a more complete example which will be fast, efficient. The append from is not really part of the work of compressing the sdf.

I am going to assume you intend to do something with the SDF file - maybe drop some stuff from it, so it is smaller (compressed - which is the name of the called routine).


Here's what I'd do...
LOCAL m.lcPSFILEPATH, m.lcNEWPATH
Create Cursor BILLCOMPRESS (POS C(254))  && Create Temporary Cursor Billcompress to Check Page Numbers,Compressed File and Invoice Date.
Select NEW_BILLS
Scan
  lcPSFILEPATH=Alltrim(NEW_BILLS.oldpath)
  lcNEWPATH=Alltrim(NEW_BILLS.NEWPATH)
  SELECT BILLCOMPRESS
  Append From (m.lcPSFILEPATH) Sdf
  DO Compress with m.lcPSFILEPATH, "BILLCOMPRESS", RECNO("BILLCOMPRESS")
ENDSCAN

PROCEDURE Compress
LPARAMETERS m.tcPSFILEPATH, m.tcAlias, m.tnRec
SELECT (m.tcAlias)
GO m.tnRec
*Process the POS field.
ENDPROC
OR!

You could do the appends in the calling code and then do the compressing on all the appended records. I'm separating the processing into clear logical blocks. Each module does one thing clearly.
LOCAL m.lcPSFILEPATH, m.lcNEWPATH
Create Cursor BILLCOMPRESS (POS C(254))  && Create Temporary Cursor Billcompress to Check Page Numbers,Compressed File and Invoice Date.
Select NEW_BILLS
Scan
  lcPSFILEPATH=Alltrim(NEW_BILLS.oldpath)
  lcNEWPATH=Alltrim(NEW_BILLS.NEWPATH)
  SELECT BILLCOMPRESS
  Append From (m.lcPSFILEPATH) Sdf
ENDSCAN
DO Compress with m.lcPSFILEPATH, "BILLCOMPRESS"

PROCEDURE Compress
LPARAMETERS m.tcPSFILEPATH, m.tcAlias
SELECT (m.tcAlias)
SCAN
*Process the POS field.
ENDSCAN
ENDPROC
>I am using the following code. I am not getting the value for cPSFILEPATH,cNEWPATH in my compress procedure. Instead I am getting .F.
>
>What is the correct code. Kinldy Advice.
>
>
>
>Select NEW_BILLS
>LOCAL cPSFILEPATH as Character
>LOCAL cNEWPATH as Character
>
>Scan  && Scans for New_bills up to EOF()
>*Define Variables
>cPSFILEPATH=Alltrim(oldpath)
>cNEWPATH=Alltrim(NEWPATH)
>DO Compress
>ENDSCAN
>
>PROCEDURE Compress
>PARAMETERS cPSFILEPATH,cNEWPATH
>Create Cursor BILLCOMPRESS (POS C(254))  && Create Temporary Cursor Billcompress to Check Page Numbers,Compressed File and Invoice Date.
>Select BILLCOMPRESS
>WAIT WINDOW cPSFILEPATH
>WAIT WINDOW cNEWPATH
>Append From (m.cPSFILEPATH) Sdf  && Nothing is appeneded as I get .F. as value for cPSFILEPATH
>ENDPROC
>
>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform