Creating new txt. file each day???

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

  • Creating new txt. file each day???

    Hello Everyone,

    Below is a section of a program where we log all nonconforming critical dimensions to a text file. As is... the data is appended to the file every day until we manually delete what we dont need. I would like to have pcdmis create a new "log file" every day at 6:30 am and sequentially name the file by date. Any ideas?

    SAMPLE:

    IF_GOTO/RM_321_1.TP.OUTTOL<=.000,GOTO = L2
    IF_GOTO/RM_321_1.TP.OUTTOL>=.001,GOTO = L1
    L1 =LABEL/
    FPTR =FILE/OPEN,C:\CLOG\GMTMACH.TXT,APPEND
    ASSIGN/WRITETHIS1 = SYSTEMDATE("MM'/'dd'/'yy")
    ASSIGN/WRITETHIS2 = SYSTEMTIME("hh':'mm':'ss tt")
    ASSIGN/WRITETHIS3 = OPERATOR_.INPUT
    ASSIGN/WRITETHIS4 = RM_321_1.TP.OUTTOL
    FILE/WRITELINE,FPTR,*******************************
    FILE/WRITELINE,FPTR,ROADMAP 321.1 WAS OUT OF SPEC!
    FILE/WRITELINE,FPTR,WRITETHIS1
    FILE/WRITELINE,FPTR,WRITETHIS2
    FILE/WRITELINE,FPTR,WRITETHIS3
    FILE/WRITELINE,FPTR,WRITETHIS4
    FILE/CLOSE,FPTR
    L2 =LABEL/
    IF_GOTO/RM_322_1.TP.OUTTOL<=.000,GOTO = L4
    IF_GOTO/RM_322_1.TP.OUTTOL>=.001,GOTO = L3
    L3 =LABEL/
    FPTR =FILE/OPEN,C:\CLOG\GMTMACH.TXT,APPEND
    ASSIGN/WRITETHIS1 = SYSTEMDATE("MM'/'dd'/'yy")
    ASSIGN/WRITETHIS2 = SYSTEMTIME("hh':'mm':'ss tt")
    ASSIGN/WRITETHIS3 = OPERATOR_.INPUT
    ASSIGN/WRITETHIS4 = RM_322_1.TP.OUTTOL
    FILE/WRITELINE,FPTR,*******************************
    FILE/WRITELINE,FPTR,ROADMAP 322.1 WAS OUT OF SPEC!
    FILE/WRITELINE,FPTR,WRITETHIS1
    FILE/WRITELINE,FPTR,WRITETHIS2
    FILE/WRITELINE,FPTR,WRITETHIS3
    FILE/WRITELINE,FPTR,WRITETHIS4
    FILE/CLOSE,FPTR
    L4 =LABEL/
    IF_GOTO/RM_426_1.TP.OUTTOL<=.000,GOTO = L6
    IF_GOTO/RM_426_1.TP.OUTTOL>=.001,GOTO = L5
    L5 =LABEL/

    ON & ON.......YOU GET THE IDEA!!

  • #2
    This is what I have done for one of my programs.

    Code:
           ASSIGN/SERIALNUMBER = STR(GETTEXT(193,1,{FILEHEDR}))
                ASSIGN/FILENAMEZ = "C:\PCDMISW\RESULTS\4120HJK"+SERIALNUMBER+".TXT"
    FPTR       =FILE/OPEN,FILENAMEZ,WRITE
                FILE/WRITELINE,FPTR,SERIALNUMBER
                FILE/CLOSE,FPTR,KEEP
    The only thing you have to do now is make sure that you replace my SERIALNUMBER with a string that does NOT contain a / or any of these code characters that Windows does not like. So make sure you manipulate the date until it reads something like 091906 (and it has to be a string; very important). I can guarantee that 09/19/06 does NOT work.


    Jan.
    ***************************
    PC-DMIS/NC 2010MR3; 15 December 2010; running on 18 machine tools.
    Romer Infinite; PC-DMIS 2010 MR3; 15 December 2010.

    Comment


    • #3
      To Jan: Good to see my "FILEHEDR" makes your day ;>)

      To Spazus: replace the assignment in Jan's sample with the following
      line:
      ASSIGN/SERIALNUMBER = STR(SYSTEMDATE("yyyyMMdd"))
      the variable could also be named different (e.g. DATE_NUMBER)

      That will generate each day a new file or append, if the file already exists

      Bye
      Hans

      Comment


      • #4
        Originally posted by bitsandmore
        To Jan: Good to see my "FILEHEDR" makes your day ;>)
        It certainly did. Lots of good rep for you suggesting it!



        Jan.
        ***************************
        PC-DMIS/NC 2010MR3; 15 December 2010; running on 18 machine tools.
        Romer Infinite; PC-DMIS 2010 MR3; 15 December 2010.

        Comment


        • #5
          thanks but.........

          Thanks fellas but......

          I dont think i clearly explained myself.

          This is a production program that runs approx 100X in a 24 hr period. I want to "auto create" a new log file each morning at 6:30am >> append to it for the next three shifts>> recreate and retitle at 6:30am>>>append for three shifts>>>>recreate and retitle at 6:30am>>> and so on... This way i will have a log file that covers all three shifts and is split up into seperate txt files by date.

          peace with a side of chicken grease

          Comment


          • #6
            Will THIS program ALWAYS be running at 6:30a.m. each morning?

            Comment


            • #7
              Originally posted by spazus_maximus
              Thanks fellas but......

              I dont think i clearly explained myself.

              This is a production program that runs approx 100X in a 24 hr period. I want to "auto create" a new log file each morning at 6:30am >> append to it for the next three shifts>> recreate and retitle at 6:30am>>>append for three shifts>>>>recreate and retitle at 6:30am>>> and so on... This way i will have a log file that covers all three shifts and is split up into seperate txt files by date.

              peace with a side of chicken grease
              You'll need to create an argument that tests the current system date time with the existence of a coresponding file name. If the file does not exist you create one. If it does you append. Use flow control.

              Craig
              <internet bumper sticker goes here>

              Comment


              • #8
                Try the following code-snippet:

                ASSIGN/TODAYS_MINUTES = INT(SYSTEMTIME("HH"))*60 + INT(SYSTEMTIME("mm"))
                IF/TODAYS_MINUTES < 390
                ASSIGN/SERIALNUMBER = STR(SYSTEMDATE("yyyyMM"))+(SYSTEMDATE("dd")-1)
                END_IF/
                ELSE/
                ASSIGN/SERIALNUMBER = STR(SYSTEMDATE("yyyyMMdd"))
                END_ELSE/
                COMMENT/OPER,NO,"Filename: " + SERIALNUMBER

                The comment is only there to test the generated value!

                Cheers

                Comment


                • #9
                  thanks....

                  Now I am on the right track ..Thanks

                  Comment

                  Related Topics

                  Collapse

                  Working...
                  X