Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Whether to Use an Array or a Cursor ?
Message
De
12/02/2014 10:07:19
 
 
À
15/08/2013 11:22:27
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:
01580497
Message ID:
01594154
Vues:
100
As this condition
'Usage Charges' $ laArray(I)
can't be rushmore optimized, it'll require a scan even with a cursor.

In this case, arrays and cursors will probably compete in terms of speed.

This is what I would try:
create cursor ...
index on 'Usage Charges' $ fieldx tag Usage binary && assuming you run VFP9
index on 'Minimum Guarantee' $ fieldx tag MinGar binary && assuming you run VFP9
append from ...
scan for 'Usage Charges' $ fieldx && this is now optimized
... your code
endscan
You can also optimize your existing code:
(1) read array elements only once
el = laArray[m.i]
... m.el ...
(2) use
x = iif(cond, y, z)
instead of
if cond
x=y
else
x=z
endif
(3) same for iCase() vs do case ... endcase
(4) using 'm.' may also help a little, especially if alias() has many fields


>Thanks Madam.But ASCAN() Will search for the Exact existence of record. is it possible with ACSN () to search like record, I mean to say that
>If the Array Element consist of "F2 B (Usage Charges)387 530 w" than is it possible to search 'Usage Charges' from Array element and Extract 300 from it using ASCAN.
>
>currently I am Scanning the entire array using For ENFOR and using IF 'Usage Charges' $ laArray(I)=.T., like this
>
>
>FOR I= 1 TO nU1 && nU1 is the Length of Array
>>>>IF 'Usage Charges' $ laArray(I)=.T.
>>>>lnRowposition =    VAL(GETWORDNUM(laArray(I), GETWORDCOUNT(laArray(I)) - 1)) && The second last word
>>>>lnLeftColumnposition = GETWORDNUM(laArray(I), GETWORDCOUNT(laArray(I)) - 2) && The Third last word
>>>>lnLeftColumnposition=VAL(STREXTRACT(lnLeftColumnposition,')',''))
>>>>EXIT
>>>>ENDIF
>>>>ENDFOR
>
>
>Kinldy Guide
>
>
>
>
>>>I am trying to some Extract Data from a Text file and preform some Manipulation on it.
>>>
>>>For Extraction of Data I have two options, 1st create a cursor using Append from abc.txt SDF and Use The Locate Command to find my Data inside and extract it.
>>>
>>>2nd Use an Array. Initially I opted the second option. Now, to extract the Data from The array I am Scaning the entire Array from top Until the record is Matched, but since the volume of Data to be extracted from ech file and the number of files are also too Large, its taking huge time for entire processing.
>>
>>Just want to point out that the fast way to search in an array is with ASCAN().
>>
>>Tamar
Thierry Nivelet
FoxinCloud
Give your VFP application a second life, web-based, in YOUR cloud
http://foxincloud.com/
Never explain, never complain (Queen Elizabeth II)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform