Re: Odd VFP DO WHILE Behavior
- From: "Dan Freeman" <spam@xxxxxxxxxxxxx>
- Date: Wed, 25 Apr 2007 08:36:00 -0700
NULL is almost impossible to avoid. Try this:
Set Null Off
Create Cursor test (mychar c(10) NOT NULL)
Set Multilocks On
CursorSetProp("Buffering",5)
Append Blank
?Oldval("test.mychar")
Note that I've SET NULL OFF, and defined the cursor's field as NOT NULL, but
Oldval() still returns null!
So, in other words, avoid null where you can BUT write ALL of your code to
defend against it. <g>
Dan
Jan Bucek wrote:
Jack Jackson napsal(a):
Which part of NULL in Help? I can't find anything that speaks
directly to this issue.
I want only say: be careful using NULL anywhere. All topics in HELP
concerning NULL make me to avoid to use NULL if possible. To use NULL
in commands expecting logical walue like WHILE DO or FOR ENDFOR is
allways dangerous. For these commands are the oldest commands of
FoxBase/FoxPro and support for NULL is new, you can expect
difficulties using NULL here.
The topic "Behavior of Null Values in Logical Expressions says
nothing about DO WHILE, but it does say:
"For example, a FOR clause that evaluates to .NULL. is treated as
false (.F.)".
It seems to me that DO WHILE should examine the parameter at each
iteration, and iterations after the first should behave exactly like
the first.
I normally don't rely on NULL values behaving in any specific way, I
just forgot to check in this case. I have fixed the code, but I am
curious if there is a reason it behaves this way.
On Tue, 24 Apr 2007 14:12:49 +0200, Jan Bucek <bucek.jan@xxxxxxx>
wrote:
See HELP - topic NULL. And careful with using null anywhere.
Jack Jackson napsal(a):
I noticed the following odd behavior (in VFP9).
LOCAL xx
xx = .NULL.
DO WHILE xx
...
ENDDO
The loop code is not executed, which is what I would expect.
LOCAL xx
xx = .T.
DO WHILE xx
xx = .NULL.
ENDDO
The loop code is executed forever. Doesn't that seem wrong?
.
- References:
- Odd VFP DO WHILE Behavior
- From: Jack Jackson
- Re: Odd VFP DO WHILE Behavior
- From: Jan Bucek
- Re: Odd VFP DO WHILE Behavior
- From: Jack Jackson
- Re: Odd VFP DO WHILE Behavior
- From: Jan Bucek
- Odd VFP DO WHILE Behavior
- Prev by Date: Re: Application/Executable Path References
- Next by Date: Re: Application/Executable Path References
- Previous by thread: Re: Odd VFP DO WHILE Behavior
- Next by thread: Application/Executable Path References
- Index(es):
Relevant Pages
|
Loading