Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CSelect
Message
General information
Forum:
Visual FoxPro
Category:
The Mere Mortals Framework
Title:
Miscellaneous
Thread ID:
00254550
Message ID:
00254644
Views:
25
>Kevin,
>
>I have a simple question about the cSelect class. Lets say I have a custom method in a bizobj that scans a lookup table and does inserts into my alias. How would the code look?
>Example:
>
>loLookup = CREATEOBJ('cSelect', 'v_lookup')
>SCAN
> IF SOMETHING
> loAlias = CREATEOBJ('cSelect', This.GetAlias())
> Replace ...
> Endif
>loLookup = CREATEOBJ('cSelect', 'v_lookup')
>ENDSCAN
>
>Is it best to not create loLookup again and just select the named alias? I normally just select the alias, but there are times when I want to be sure my bizobj restores the previously selected alias. Saving the alias and restoring it later is a tried and true procedural approach, but what do your recommend?

James,

I would only create one instance of cSelect as loLookup. The two additional CREATEOBJ calls you have are not necessary and may cause a problem. You would be better off to just select the alias.

If you look at the INIT event of cSelect, you will see that the currently selected work area is saved. Then in the DESTROY event, the saved work area is reselected. This takes the place of code like:

LOCAL lnSelect

* save current work area
lnSelect = SELECT

.
. other code
.


* return to saved work area
SELECT (lnSelect)

RETURN .T.

By making multiple calls, you are saving a different currently selected alias and then reseting during each objects destroy event.

Kind regards,

Mat
Matthew Kennedy
Decision Support Technology Inc.

"I try to take one day at a time, but sometimes several days attack me all at once." ~ Ashleigh Brilliant

New Jersey Dot Net User Group
Previous
Reply
Map
View

Click here to load this message in the networking platform