Leading zero issue/creating filename correctly

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

  • Leading zero issue/creating filename correctly

    Issue Solved

    Solution-->
    Code:
    GROUP_SERIALNUMBER=GROUP/SHOWALLPARAMS=YES
    SERIALNUMBERQUESTION =COMMENT/INPUT,NO,FULL SCREEN=NO,
    Serial Number:
    ASSIGN/VAR_SERIALNUMBER="Serial Number: "+SERIALNUMBERQUESTION.INPUT
    COMMENT/REPT,
    
    COMMENT/REPT,
    VAR_SERIALNUMBER
    COMMENT/REPT,
    
    RUNNUMBERQUESTION =COMMENT/INPUT,NO,FULL SCREEN=NO,
    Run Number:
    IF_GOTO/RUNNUMBERQUESTION.INPUT<1 OR RUNNUMBERQUESTION.INPUT>9999,GOTO = RUNNUMBERQUESTION
    ASSIGN/VAR_RUNNUMBER=FORMAT("%04d",INT(RUNNUMBERQUESTION. INPUT))
    ASSIGN/VAR_RUNNUMBER_STATEMENT="Run Number: "+VAR_RUNNUMBER
    COMMENT/REPT,
    VAR_RUNNUMBER_STATEMENT
    COMMENT/REPT,
    
    ASSIGN/PROG_NAME=GETPROGRAMINFO ("PARTNAME")
    ASSIGN/REPORT_NAME="O:\\CMM PROGRAMS\\CMM_PDF_PC DMIS\\DELETEME\\"+PROG_NAME+"__"+SERIALNUMBERQUEST ION.INPUT+"__"+VAR_RUNNUMBER+"-.PDF"
    PRINT/REPORT,EXEC MODE=END,$
    TO_FILE=ON,AUTO=1,AUTO OPEN=OFF,$
    TO_PRINTER=OFF,COPIES=1,$
    TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=REPO RT_NAME,$
    REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMEN SIONS=NO,$
    TO_EXCEL=OFF,$
    PREVIOUS_RUNS=KEEP_INSTANCES
    ENDGROUP/ID=GROUP_SERIALNUMBER
    __________________________________________________ __________________________________________________ ________________________________
    Original Post-->

    I have a SERIAL NUMBER and RUN NUMBER being collected with input comments. I need to display these values on my inspection report AS WELL AS use these values to create a file path for the PDF that this inspection report will make. The office REQUIRES that I have leading zeroes on all paperwork. If it says "Run Number 0010" on the Insp. Report then "0010" MUST be in the filepath.

    Using below, I have PC DMIS successfully & handling the leading zero thing on the Insp. Report side. However, when making the PDF, PC DMIS REMOVES the leading zeroes on the filepath that it creates. Bob the operator types in "10", PC DMIS corrects it like I want to put "0010" on the inspection report... but the PDF file gets named "AG01234_567__TCWKALXXXX__10-001". I want it to be "AG01234_567__TCWKAL1432__0010-001".

    I know I'm close but still no cigar, any ideas? Here is what i have so far.

    Code:
    SERIALNUMBERQUESTION =COMMENT/INPUT,NO,FULL SCREEN=NO,
    Serial Number:
    ASSIGN/VAR_SERNO=SERIALNUMBERQUESTION.INPUT
    ASSIGN/VAR_SERIALNUMBER_STATEMENT="Serial Number: "+SERIALNUMBERQUESTION.INPUT
    COMMENT/REPT,
    
    COMMENT/REPT,
    VAR_SERIALNUMBER_STATEMENT
    COMMENT/REPT,
    
    RUNNUMBERQUESTION =COMMENT/INPUT,NO,FULL SCREEN=NO,
    Run Number:
    ASSIGN/V1=ABS(RUNNUMBERQUESTION.INPUT)
    IF/V1<10
    ASSIGN/VAR_RUNNUM=STR(0)+STR(0)+STR(0)+V1
    END_IF/
    IF/V1>9 AND V1<100
    ASSIGN/VAR_RUNNUM=STR(0)+STR(0)+V1
    END_IF/
    IF/V1>99 AND V1<1000
    ASSIGN/VAR_RUNNUM=STR(0)+V1
    END_IF/
    IF/V1>999 AND V1<9999
    ASSIGN/VAR_RUNNUM=V1
    END_IF/
    IF/V1>9999
    ASSIGN/VAR_RUNNUM="Run numbers don't go that high! Try again."
    COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
    VAR_RUNNUM
    GOTO/RUNNUMBERQUESTION
    END_IF/
    COMMENT/REPT,
    "Run Number: "+VAR_RUNNUM
    COMMENT/REPT,
    
    ASSIGN/PROG_NAME=GETPROGRAMINFO ("PARTNAME")
    ASSIGN/REPORT_NAME="O:\\CMM PROGRAMS\\CMM_PDF_PC DMIS\\AG01234_567\\"+PROG_NAME+"__"+VAR_SERNO+"__" +VAR_RUNNUM+"-.PDF"
    Code:
    PRINT/REPORT,EXEC MODE=END,$
    TO_FILE=ON,AUTO=1,AUTO OPEN=OFF,$
    TO_PRINTER=OFF,COPIES=1,$
    TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=REPORT_NAME,$
    REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMENSIONS=NO,$
    TO_EXCEL=OFF,$
    PREVIOUS_RUNS=KEEP_INSTANCES
    Last edited by DAN_M; 05-27-2020, 04:13 PM.

  • #2
    DAN_M, if the serial number is always a a fixed number of leading zeros, you could always hard code the zeros in
    Code:
    ASSIGN/REPORT_NAME="O:\\CMM PROGRAMS\\CMM_PDF_PC DMIS\\AG01234_567\\"+PROG_NAME+"__00"+VAR_SERNO+"__" +VAR_RUNNUM+"-.PDF"

    Comment


    • #3
      You can use the FORMAT assign to pad the string

      Code:
      C1 =COMMENT/INPUT,NO,FULL SCREEN=NO,
      Enter total
      ASSIGN/V1=FORMAT("%04d", INT(C1.INPUT))
      COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
      "The value is " + V1
      this will ask for a value, force to a number (INT) and format a string of 4 characters with leading 0's

      Comment


      • #4
        I would try something like this (I wrote it before the excellent post of SABarber !)
        Code:
        ASSIGN/V1=ABS(RUNNUMBERQUESTION.INPUT)
        ASSIGN/V2=LEN(V1)
        ASSIGN/NZERO=""
        WHILE/V2<5
        ASSIGN/V1=STR(V1)
        ASSIGN/V1=NZERO+V1
        ASSIGN/V2=LEN(V1)
        ASSIGN/NZERO=""+STR(0)
        END WHILE

        Comment


        • #5
          Thanks all! Issue resolved. See original post.

          Comment

          Related Topics

          Collapse

          Working...
          X