Re: Odd VFP DO WHILE Behavior



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?


.



Relevant Pages

  • Re: Common Procedure
    ... A common procedure is great idea. ... Further, I would avoid using "domenuItem", as that suggests a particular ... You standard code module can thus be: ... try and stay away from those old style menu commands. ...
    (microsoft.public.access.formscoding)
  • Re: Odd VFP DO WHILE Behavior
    ... Jack Jackson napsal: ... For these commands are the oldest commands of FoxBase/FoxPro and support for NULL is new, you can expect difficulties using NULL here. ... The loop code is not executed, which is what I would expect. ... The loop code is executed forever. ...
    (microsoft.public.fox.vfp.forms)
  • Re: How to log all commands?
    ... The users will be able to run several potentially dangerous tools (like ... The main point is that in the "front" of dangerous machines restriction ... I can avoid the use of other shells by having only bash, ... PROBABLY I'll implement the commands using sudo, ...
    (comp.os.linux.security)
  • Re: Slightly OT: DVD players
    ... as slow to respond to commands as its predecessor and noisy in ... (so that I can avoid it!) ...
    (uk.tech.digital-tv)
  • Re: Slightly OT: DVD players
    ... as slow to respond to commands as its predecessor and noisy in ... (so that I can avoid it!) ...
    (uk.tech.digital-tv)

Loading