Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What is ASSERT used for?
Message
From
29/09/1998 08:34:50
 
 
To
28/09/1998 19:09:22
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00141677
Message ID:
00141860
Views:
31
>I recently aquired Visual Studio 6 and I bought a copy of FoxPro Advisor with that (October issue).
>
>In his article about the report-wrapper class (p.41 to 49), Chistof Lange uses the ASSERT command (like ASSERT TYPE("tcOption") == "C").
>
>I fail to see what this command does, and VFP's help isn't helping...
>
>Anyone care to elaborate?

ASSERT checks a condition, and if it isn´t true, shows up an error message. (There even is a MESSAGE option to allow for your own text.)

We use ASSERT regularly to check for all "expected" conditions. For example, all routines verify that their parameters are of the correct type (as in the FP Advisor example). We also use ASSERTs in DO CASE structures as shown:
DO CASE
CASE condition1
...
CASE condition2
...
...
OTHERWISE
ASSERT .F.
ENDCASE
We try to check for all conditions in the CASE (even if it means that some CASE will have no associated code) so the OTHERWISE clause should never be executed.

Believe me, I will use anything that helps avoiding errors!!

HTH!
Previous
Reply
Map
View

Click here to load this message in the networking platform