IF GOTO Statements for Reporting

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • IF GOTO Statements for Reporting

    I'm trying to use IF/GOTO statements to control when the report should print and when it should not. COMMENT1.INPUT will always be either STARTUP or a number that is greater than 0. Basically I want a report generated in both cases but only a report printed in the case where COMMENT1.INPUT is not STARTUP. Not sure what I'm doing wrong or missing. Right now it is executing both Print report commands. Any ideas for how to make this work? Thank you!

    IF_GOTO/COMMENT1.INPUT=="STARTUP",GOTO = L1
    IF_GOTO/COMMENT1.INPUT>0,GOTO = L2
    L1 =LABEL/
    PRINT/REPORT,EXEC MODE=END,$
    TO_FILE=ON,OVERWRITE=VAL_FILE,AUTO OPEN=OFF,$
    TO_PRINTER=OFF,COPIES=1,$
    TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
    REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMEN SIONS=NO,$
    TO_EXCEL=OFF,$
    PREVIOUS_RUNS=DELETE_INSTANCES
    L2 =LABEL/
    PRINT/REPORT,EXEC MODE=END,$
    TO_FILE=ON,OVERWRITE=VAL_FILE,AUTO OPEN=OFF,$
    TO_PRINTER=ON,COPIES=1,$
    TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
    REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMEN SIONS=NO,$
    TO_EXCEL=OFF,$
    PREVIOUS_RUNS=DELETE_INSTANCES

  • #2
    For something like this you might want to try a Case statement instead of the IF/GOTO. You can search for threads that cover this subject well.

    The quick fix would be to put a GOTO statement (to L3 or something) after the first print command and then put a L3 label after the second print command

    Comment


    • #3
      https://www.pcdmisforum.com/forum/pc...partial-report
      (In Memory of my Loving wife, "Ronda" who I lost March 7, 2016. I love you baby.)
      They say "Nobody's Perfect." I must be Nobody.

      Comment


      • #4
        Thanks so much. I got it working. Appreciate it.

        Comment


        • KIRBSTER269
          KIRBSTER269 commented
          Editing a comment
          share with people what you did to get it working, so that others may learn.

      • #5
        You have nothing that prevents print report after L1 from jumping over/skipping L2 code. add a goto at end of L1, to skip L2.
        Code:
        IF_GOTO/COMMENT1.INPUT=="STARTUP",GOTO = L1
        IF_GOTO/COMMENT1.INPUT>0,GOTO = L2
        L1 =LABEL/
        PRINT/REPORT,EXEC MODE=END,$
        TO_FILE=ON,OVERWRITE=VAL_FILE,AUTO OPEN=OFF,$
        TO_PRINTER=OFF,COPIES=1,$
        TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
        REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMEN SIONS=NO,$
        TO_EXCEL=OFF,$
        PREVIOUS_RUNS=DELETE_INSTANCES
        goto/endpgm
        L2 =LABEL/
        PRINT/REPORT,EXEC MODE=END,$
        TO_FILE=ON,OVERWRITE=VAL_FILE,AUTO OPEN=OFF,$
        TO_PRINTER=ON,COPIES=1,$
        TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
        REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMEN SIONS=NO,$
        TO_EXCEL=OFF,$
        PREVIOUS_RUNS=DELETE_INSTANCES
        endpgm=label/
        Question, what if someone typed in an invalid number, or "START UP" with a space? Or "PEISS OFF DEMON"? you should have a validation loop in the comment that FORCES operator to provide a correct input. I'm pretty sure this should work, but you get the point either way.
        Code:
        com1in=label/
        comment1: what's the routine you want?
        IF_GOTO/COMMENT1.INPUT=="STARTUP",GOTO = L1
        IF_GOTO/COMMENT1.INPUT>0,GOTO = L2
        ELSE/goto=com1in
        endelse/
        L1 =LABEL/
        PRINT/REPORT,EXEC MODE=END,$
        TO_FILE=ON,OVERWRITE=VAL_FILE,AUTO OPEN=OFF,$
        TO_PRINTER=OFF,COPIES=1,$
        TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
        REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMEN SIONS=NO,$
        TO_EXCEL=OFF,$
        PREVIOUS_RUNS=DELETE_INSTANCES
        goto/endpgm
        L2 =LABEL/
        PRINT/REPORT,EXEC MODE=END,$
        TO_FILE=ON,OVERWRITE=VAL_FILE,AUTO OPEN=OFF,$
        TO_PRINTER=ON,COPIES=1,$
        TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
        REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMEN SIONS=NO,$
        TO_EXCEL=OFF,$
        PREVIOUS_RUNS=DELETE_INSTANCES
        endpgm=label/
        Last edited by louisd; 07-31-2019, 06:07 PM.

        Comment

        Related Topics

        Collapse

        Working...
        X