Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cool idea for SET commands
Message
From
27/07/2004 11:43:31
Mike Yearwood
Toronto, Ontario, Canada
 
 
To
27/07/2004 10:04:05
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00928029
Message ID:
00928338
Views:
57
Hi Dragan

>While I agree that the cSet class (which exists as a freebie in the CodeBook, and is inherited in at least one CodeBook-derived framework that I used) makes things simple, your example of an early exit is slightly wrong - the exit is not early enough. If you're exiting early, you should do so before you change any SETtings:
>
>
LPARAMETERS m.tcVar
>IF VARTYPE(m.tcVar) # "C"
>  RETURN .F.
>ENDIF
>IF not somebusinesscondition
>  RETURN .F.
>ENDIF
>* now we're doing business, save settings and do it
>LOCAL m.lcSafety
>m.lcSafety = SET("SAFETY")
>SET SAFETY OFF
>* ... some processing
>DO SOMETHING
>* ...done, restore.
>SET SAFETY &lcSafety.
>RETURN
>
>Of course, there may be other exits that may be required during the business part, but these may be bracketed using a simple status variable:
>
lOK=SomeCheck()
>if lOK
>   * do some more
>   lOK={new check condition}
>endif
>
>if lOK
>   * keep on processing
>   lOK={another check condition}
>endif
>* done, restore
>
>This way you don't have to have other exits but the early exits (before you disturb the settings) and one final exit (where you restore the settings).

That's just one way to do it. You may not always be able to exit before the settings have been changed. IMO the lOK scattered through the block of code makes it harder to follow the logic. I find things much easier to follow if they exit as soon as processing cannot continue. But the point I was trying to make is we have more freedom to decide how to code things with these classes protecting us from ourselves.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform