Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array problem 2

Status
Not open for further replies.

DannC

Programmer
Apr 5, 2001
75
RO
I have set a property of a form like this aArray(1,1) and after that i've used a SQL statement wich "filled" this array which is displayed in a listbox. My question is if is a way to filter this array. By example is aArray has (1,1)='A', (1,2)='B' (2,1)='AA', (2,2)='C', (3,1)='D', (3,2)='F' i want my aArray to contain just rows with "A". I've tried with adel() but is to slow. Thanks !!!
 
Hi my friend
Unfortunately, there is no direct way to do this in FOX even though it is a common need in every day developing, what I am doing – just one of many possible solution – is create cursor in the memory and insert each row of the array as record then I can issue select – SQL against this cursor to select just a scope of records into another array, or to the master array (FOXPRO will over write it as a result of SELECT-SQL) since I can always recover it back by issuing SELECT-SQL without scope.
Again this is just one of many solutions.
Hope this will help
Thanks
Walid Magd
Engwam@Hotmail.com
 
Suggestion 1:
Cant the SQL tatement contain a filter condition to avoid loading the unwanted rows? I feel this can be the real solution.

Suggestion 2: (If SQL filtering cannot be done)
Just to remind that ADEL function will be slow because,
deleting an element, row, or column from an array doesn't change the size of the array; instead, the trailing elements, rows, or columns are moved towards the start of the array, and the last element, row, or column in the array is set to false (.F.). So, I suggest, do a ASCAN of the source array and copy only wanted rows into a working array which can be used in the list box.

Suggestion 3:
I remember that list box rows will be omitted if the first character is '\' or '/'. I have to verify this as I am writing off memory. So to use this effectively,
a. Make the array with one dimension more
b. Make the additional dimension to hold a character value and fill it up with '/' or '\' (whichever is applicable) herever the row is not wanted
c. if the list box value is set as comination of two array elements, one as built above+your row
This suggestion 3 is just off my vision and I cannot confirm, if it works... (worth a try for sure!)

Hope I am useful to you.

ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top