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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checkbox, controlsource, bittest()

Status
Not open for further replies.

metron9

Programmer
Mar 5, 2002
94
US
I have a form with 30 check boxes on it. I plan on using a table with a 4 bit integer field to hold the data values of the check boxes using the bitor() to set the bits.
Example
checkbox1 checked
checkbox2 not checked
.
.
checkbox30 checked
I would then set bit 30 bit 2 and bit 1 in the integer field

Each time a record is displayed on the form I would read all the bits and set the value of the checkbox with
thisform.checkbox1.value=1 (or 0 if the bit is zero)

Question:
Can I set the checkbox controlsource with an expression such as: bitand(table.field,1) to test bit 1 and if it is set the check box .value automatically is set to 1 and the checkbox shows is checked?

My Answer: I don't think so as the user clicking the checkbox would have to set or clear the bit in the table.

I know I can set the controlsource to a Logical TYPE field.
Would it be best to set up the table with 30 logical fields and set the control source for each checkbox to that field?
I could then read all 30 fields and still set an integer field with the proper bits so I can index that field for my search. I think this is the best way with the exception that it takes 30 fields in the datatable.


 
I would just go with the thirty fields and skip the integer field alltogether. Just do the search on the logical fields, foxpro will take care of the rest.

What you are proposing to do is basically a copy of what rushmore does when you do a query. I would be really supprised if your approach ends up being significantly faster.

 
How would I go about setting up the index for the table.
What would a search query look like.
Could you give me an example of say 5 logical fields and search for fields 1 and 3 as .T. and all others .F.
If the logical fields are not indexed would not the whole file have to be searched with compares on each field?
If they are indexed would that not be a huge amoubt of indexes?
I am from the old CLIPPER dos days and not a very good oop programmer so I can only see a search like
locate for field1=.t. .and. field3 = .T. .and. field2 = .F. .and. field4 = .F. .and. field5=.F.
I know that is not what you are suggesting.
 
metron9

your idea is very good, I use a simpler version for options presented to the user. I have not used this to store choices in foxpro. I have done this is early dos days working with C. you will have to put the code in the check boxes to do the bit on/off. I would start in making a class to perfomr the basics then work in subclassing to have the bits on/off. Attitude is Everything
 
Actually that is exactly what I am suggesting.
Let foxpro do the work and stop trying to outthink it.
Create an index on each field and write the where clause as needed.

Remember foxpro uses a cdx so there is only one index file. You do not have to 'set' the index.

 
darn it I willjust give it a go then using the locate and set filter to commands.

I think I could learn quite a bit about oop if I were to explore the dancemans Idea of making a class. However the term "making a class" is still dosn't click as I have never "made a class" before. Can I start from scratch and make my own CHECKBOX control? I don't even have a clue where to find the documentation on why the logical TYPE field in a table can be can be set to the control source method of the control "checkbox". I just played around with it until it worked. Where is the documentation on the checkbox control that says the control source can be set to a logical variable type? When I installed visual foxpro 6.0 I don't even have a HELP file that I would think would have been installed when I installed foxpro from the visual studio 6.0 package. The hackers guide, 1001 things you wanted to know about foxpro and effective techniques don't have any SYNTAX code listings detailing each and every aspect of any of the controls you can put on a form. They give overviews of things. I want a manual like assembly language or C code library functions
 
When I installed visual foxpro 6.0[I/]

if you used visual studio. you most likely said no to installing the MSDN disk.
this is the file option in foxpro for my help file.

c:\program files\microsoft visual studio\msdn98\98vsa\1033\msdnvs6a.col

if you don't have this, then look in your package for the MSDN library disk and install this. visual studio has a lot of resources available,they just need to be installed. Attitude is Everything
 
metron9,
In fact, The Tip of The Month in the August 2002 FoxPro Advisor Magazine showed how to do your exact request - it uses the Access() and Assign() methods. While the code is simple, it is in a copyrighted article, so I can't reproduce it here. Perhaps you know someone who gets the magazine, or it may be available on the FPA site -
Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top