Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Cursor VS Array
Message
De
20/04/2001 12:43:51
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Divers
Thread ID:
00497487
Message ID:
00497989
Vues:
18
Larry,
FWIW, see Message #482884

>>Hi Larry and all,
>>
>>
>>>>I'll like to bind some data to some combobox on a form. The data came from SELECT - SQL made by SQLEXEC() from a remote VFP6 database. I want to know if it is better to keep the data in arrays or to keep them in cursors. The arrays or cursors will contain 2 or 3 fields ( 1 key, a description and maybe a code ). Is one more faster than the other? Is one take less memory than the other? etc.
>>
>>>Arrays take memory variable while cursors in essence do not. Cursors are stored using the temporary workfile space that VFP creates.
>>
>>I'm not sure what you mean by this, but In general small cursors are not stored on disk but in memory just like arrays. Only when cursors grows larger VFP decides to store them in a temp file. You can check if a cursor is stored on disk or memory by using ? FILE(DBF("MyCursor"))
>
>I left out one word in when the thoughts were transmitted to my fingers. The text should read "Arrays take memory variable SPACE". While both may be contained in memory, arrays encroach on the MVCOUNT limit while cursors do not.
>
>As for FILE(), I have never seen FILE() return anything other than .F. for these files. VFP creates several TMP files and I believe the files returned by DBF() are somehow contained in the TMP files. I could be wrong but like I said, FILE() has never returned .T. for me. What size result set have you seen it return .T. for?
>
>>
>>>As such, you can usually have more records in a cursor than rows in an array. Also, there is a distinct limit of 65000 elements to an array. With 3 columns, that gives you about 21600 rows. You may not exceed that, but you never know.
>>
>>Though you are correct that arrays are more limited in terms of memory, who wants to store more than a few hundred (or a few thousand, when using autocomplete) rows in a combobox ?
>>
>>Personally, I've got a combobox class with an array property (aSource). If you want to use arrays as a datasource for a combobox you can fill the array property in the init, refresh, when or gotfocus event of the combobox with a SELECT ... FROM .... WHERE ... INTO ARRAY THIS.aSource
>>
>>This way, you'll prevent having a lot of different cursors when your form does have many of these comboboxes and you don't have to worry about the problems that occur when two or more comboboxes generate cursors with the same name.
>>
>
>I don't mind the cursors and I usually associate the cursor with the name of the combo (or other control) that is the source for. The naming is protected in that way as I don't have the same names throughout my forms.
>
>To each his own.
Daniel
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform