Shop OBEX P1 Docs P2 Docs Learn Events
Nested If...Then — Parallax Forums

Nested If...Then

ArchiverArchiver Posts: 46,084
edited 2002-09-18 12:34 in General Discussion
I am using the RCTIME command to determine the
operational status of a variable reluctance speed
sensor during shock and vibration testing. My goal is
to measure the resistance of the winding to ensure
that during the testing it does not open or short.
Also, I need to determine if the winding shorts to the
metal enclosure of the speed sensor.

I am thinking that I can use the TCTIME to determine
the static values when the sensor is OK. When RCTIME
returns the result variable, the value would then be
evaluated and then a LED whould be turned ON if one of
my three test conditions is met.

My question is can I use the IF...Then command as a
nested function. If so how would I go about doing it.

Thanks



=====
John DeFeo
Director, Engineering
Motion Sensors Inc.
PH: 252-331-2080
FAX: 252-331-1999
e-mail: jdefeo@m...
web-site: http://www/motionsensors.com

__________________________________________________
Do you Yahoo!?
Yahoo! News - Today's headlines
http://news.yahoo.com

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-09-18 12:34
    If I follow your question, here's a possible answer:

    In Pbasic, the only thing you can do with an IF is to GOTO a label. So,

    If x=0 then foo

    Is the same as the illegal statement:

    If x=0 then goto foo ' not legal syntax


    So you have to "unroll" your nesting to a series of labels. One handy
    trick is to reverse your test. For example if you want to write:

    IF x=0 then
    gosub xyz
    debug ?x
    END IF ' not legal syntax

    You might considering writing:

    If x<>0 then endif01
    gosub xyz
    debug ?x
    Endif01:


    Or if you wanted to write:
    IF x=0 then
    gosub xyz
    debug ?x
    ELSE
    gosub abc
    debug ?y
    ENDIF ' all illegal syntax!

    You might try:

    If x<>0 then else01
    gosub xyz
    debug ?x
    goto endif01
    Else01:
    gosub abc
    debug ?y
    Endif01:


    Not perfect, and you have to train yourself to remember that the
    condition is reversed. That is, the first block of code is for x=0 and
    the 2nd block is for x<>0!

    Of course, the opposite of < is >=, <= is >, etc.

    Al Williams
    AWC
    * Easy RS-232 Prototyping
    http://www.al-williams.com/awce/rs1.htm





    >
    Original Message
    > From: John DeFeo [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=DvwjF7HRq_5EGw-dmAtMJu7T5ASVLMQ16DDCrM5QO-AGg3JRCcDkBgstUV7BLEYC1PChx8J9Cyq-pA]jwdefeo@y...[/url
    > Sent: Tuesday, September 17, 2002 9:42 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] Nested If...Then
    >
    >
    > I am using the RCTIME command to determine the
    > operational status of a variable reluctance speed
    > sensor during shock and vibration testing. My goal is
    > to measure the resistance of the winding to ensure
    > that during the testing it does not open or short.
    > Also, I need to determine if the winding shorts to the
    > metal enclosure of the speed sensor.
    >
    > I am thinking that I can use the TCTIME to determine
    > the static values when the sensor is OK. When RCTIME
    > returns the result variable, the value would then be evaluated and
    > then a LED whould be turned ON if one of my three test conditions is
    > met.
    >
    > My question is can I use the IF...Then command as a
    > nested function. If so how would I go about doing it.
    >
    > Thanks
    >
    >
    >
    > =====
    > John DeFeo
    > Director, Engineering
    > Motion Sensors Inc.
    > PH: 252-331-2080
    > FAX: 252-331-1999
    > e-mail: jdefeo@m...
    > web-site: http://www/motionsensors.com
    >
    > __________________________________________________
    > Do you Yahoo!?
    > Yahoo! News - Today's headlines
    > http://news.yahoo.com
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the
    > Subject and Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to
    > http://docs.yahoo.com/info/terms/
    >
    >
Sign In or Register to comment.