Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Passing array's by reference
Message
From
17/07/2003 14:30:29
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00810463
Message ID:
00811197
Views:
14
hmm, i have come across that a view times by now. how does anyone else think about this? maybe that would be something for europa?

anyway, i ended up changing that class completely. what that class was doing was giving me the possibility to to handle 'options' like the messagebox() for instance does.

with the messagebox i can pass parameters in form of numbers like
messagebox("hello World", 0+64+0, "I've got a message...")
we all have seen this, however i never figured out how to check a number comming in, like 308.

well the class i was talking about earlier is able to tell me that is a:
4 (yes and no button)
48 (Exclamation Point)
256 (Second Button)

However, it was done with array's, initializing them with all possible number solutions, and the doing an ascan() to give me a result.

well, maybe its just me but i did not know how else to do this in a more efficient way. BUT i came up with a much better solution and for all who do not know how to do this (most of you propebly do) here is the trick:

you have to work with binary numbers and compare the bits.
* *** let's stay with the earlier example of 308
* *** options start at 1 and are beeing doubled for each next option, so we have 
* *** 1 2 4 8 16 32 64 128 256 512 etc.

* *** all you got to do is check each option against the total number (308)
if BitAnd(308, 1) = 1
   * *** optin 1 was includet
endif
if BitAnd(308, 2) = 2
   * *** optin 2 was includet
endif
if BitAnd(308, 4) = 4
   * *** optin 3 was includet
endif
if BitAnd(308, 8) = 8
   * *** optin 4 was includet
endif
* *** and so on
the end result is that the numbers 4, 48, 256 were chosen - the rest is up to you.

as i have mentioned before, maybe that's an old hat to you all, but it sure made my day!

thanks Fred!


>Same rules for VFP8. Another way you could do it is to create a bunch of local arrays, pass those by reference to your method, and then copy them to the property arrays once you've returned.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform