Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Request suggestions using Collection class
Message
From
09/12/2003 05:50:04
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
08/12/2003 14:39:07
Larry Long
ProgRes (Programming Resources)
Georgia, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00856919
Message ID:
00857108
Views:
30
>I am pulling data into a cursor and an associated value for each field that indicates the value's status, for example
>
>SELECT name, address, zip FROM myTable
>
>and for each field, I have an associated "Current" status (T or F) which is generated in the selection routine.
>
>What I want to do is display a grid showing the cursor and change the background color depending on the associated "Current" value.
>
>I was thinking of doing something along the line of...
>
>DEFINE CLASS RecordSet as Collection
>
>*FOR EACH FIELD IN THE CURSOR
>FOR i= 1 to FCOUNT()
>STORE FIELD(I) TO fldname
>
>*ADD THE VALUE AND STATUS TO THE RECORDSET COLLECTION
>THIS.AddObject(fldname,'RecordValues')
>
>*UPDATE THE VALUES
>THIS.&FLDNAME..VALUE = eval('Cursor.'+fldname)
>THIS.&FLDNAME..CURRENT = GetFieldStatus()
>ENDFOR
>ENDDEFINE
>
>DEFINE CLASS RecordValues as Custom
>Value=""
>Current=.F.
>ENDDEFINE
>
>Then define a grid using the recordset and showing a background color based on the Current property.
>
>What I don't want to do, is to have to requery for the status once I get the data as it would take an inordinate amount of time for large recordsets.
>
>Any ideas or comments would be most appreciated.
>
>TIA,
>Larry Long

Larry,
Why do you need such a thing. Apart from taking considerable time creating many objects is unnecessary IMHO. You might simply add a bitmask field for those 3 fields and set it.

ie:
Name   Address   Zip
----   -------   ---
  0       0       0  = 0
  1       0       0  = 4
  0       1       0  = 2
It's a simple bitset,bittest operation. Another approach for 254(or 5) fields might be adding a single string with T/F's in it representing states.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform