hexagon logo

Flow Control Using Yes/No Issue

I'm using a series of Yes/No Questions to dictate what is measured and reported vs what is not. My 1st question is essentially "Are all features being measured": If yes, it skips the following questions. The issue is however that when it skips the following questions, their YES/NO answers are still considered later in the program to decide what to skip instead of defaulting to any given value and is effecting the capability of my program. Is there any way for me to get questions that are skipped by If/goto commands to reset to a default value such as yes?

Edit:
I figure I can add "IF Q1=Yes, Goto [label immediately after relevant IF Goto command giving me issues]" to fix the issue
I'm more curious if there are any other ways to accomplish this however, such as but not limited to defaulting to yes for skipped questions
  • Well, you could use IF_GoTo command to simplify.
    You could redundantly assign them immediately afterwards, overridiing them to the values you need.

    pseudocode, not exact syntax:
    Allfeat = Comment, yes/no, Are all features being measured"
    c1= Comment, yes/no,
    c2= Comment, yes/no,
    c3= Comment, yes/no,
    If allfeat.input=="YES"
    Assign\C1.input=="NO"
    Assign\C2.input=="NO"
    Assign\C3.input=="NO"
    end_if/
  • Well, you could use IF_GoTo command to simplify.
    You could redundantly assign them immediately afterwards, overridiing them to the values you need.

    pseudocode, not exact syntax:
    Allfeat = Comment, yes/no, Are all features being measured"
    c1= Comment, yes/no,
    c2= Comment, yes/no,
    c3= Comment, yes/no,
    If allfeat.input=="YES"
    Assign\C1.input=="NO"
    Assign\C2.input=="NO"
    Assign\C3.input=="NO"
    end_if/



    I'm not sure you can set (write) the input values if comments in that way (I may be wrong) but along the same lines if you initialise some variable you can achieve the same result...


    runall = Comment YES/No - Measure all features
    If runall ==yes
    assign section1 = Yes
    assign section2 = Yes
    assign section3 = Yes
    end if
    goto skipquestions

    c1 = Comment YES/No - Run section1?
    if c1.input==yes
    assign section1 = Yes
    if c1.input==no
    assign section1= No

    c2 = Comment YES/No - Run section2?
    if c2.input==yes
    assign section2 = Yes
    if c2.input==no
    assign section2= No

    etc


    Label = skipquestions


    if section1 == yes

    measure stuff here

    end if

    if section2 == yes

    measure stuff here

    end if

    ​​​​​​​etc
  • Use a form and variables rather than the YES/NO questions
  • Myself, I would program the features in sections and use IF/GOTO statements. Use an operator INPUT comment to select what is getting checked
    oper/input
    1=thru OPERATION 1
    2=thru OPERATION 2
    3=thru OPERATION 3
    and so on
    10=finished part

    The use the IF/GOTO to skip what isn't being checked.
    The program in REVERSE order (I would) so that FINISHED PART is first, next to last operation is next, and so on, that way it will just run from the "GOTO" label tot he end of the program. This way tends to help avoid PROBE ROTATION issues.
  • ^^^ This is the way I'd go, similarly, at least.

    Air code:
    ASSIGN/OP1=0
    ASSIGN/OP2=0
    ASSIGN/OP3=0
    
    C1= Comment/YESNO, Op1?
    ASSIGN/OP1=IF(C1.input=="YES",1,0)
    {Lather, rinse, repeat}[\code]
    
    I have a habit of setting variables at the beginning of the program to the safe value even if they'll be evaluated later.