old subject, making a counter for part sequencing

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

  • old subject, making a counter for part sequencing

    Long ago there was a posting about making a counter using a simple code rather than having to manually enter the number each time for the part sequence. We don't use datapage which would count for us, so I am left with this option, anyone know this code? To be used in a comment and printing to the report.

  • #2
    Loopidy loop loop

    I'd use a loop. What do you want to do specifically? Perhaps a do while or do until, maybe one of those PCDMIS loops depends on your goal. How about details. We can handle it by the sounds of it.

    Craig
    <internet bumper sticker goes here>

    Comment


    • #3
      What you could do is open a file, write a number to the first line. Close and save the file.

      Next time you need to increment, open the file, read the first line into a variable and make it a number. Increment the number by 1 and overwrite the file. That way you always have a file where the first line is the latest increment number.

      I have done all pieces, but never all. Try to implement and if you have trouble, post the code where it fails. I may be able to help to debug.



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

      Comment


      • #4
        If you are saving or printing your reports, which I'm sure you are since you are not using Datapage, you could simply insert a Keyin dimension at the very beginning of program. Make sure that this dimension is highlighted and each time you run the program and it asks for the key dimenion, simply key in what part you are on. It will be noted in every report as to which part the report goes to. I hope this is what you are looking for, and it is very simple to do.

        Comment


        • #5
          I want a automatic counter that was at one time explained in the other board long ago. It was VB code and very easy to write, I just cannot find it anywhere. I know I can use keyin dims, I wanted it to be automatic with a simple line of code like a variable, then displayed in a comment.

          Comment


          • #6
            Originally posted by Robert Squire
            I want a automatic counter that was at one time explained in the other board long ago. It was VB code and very easy to write, I just cannot find it anywhere. I know I can use keyin dims, I wanted it to be automatic with a simple line of code like a variable, then displayed in a comment.
            I’m still not 100% sure what you want to do but here are some examples, perhaps one of these is what you need. If you need to increment a counter within a program to count multiple times per execution try this:

            Code:
                        ASSIGN/LOOPINDEX  = 1
                        WHILE/(condition here)
            .
            .  (program code here)
            .
                        ASSIGN/LOOPINDEX  = LOOPINDEX  + 1
                        END_WHILE/
            That code will reset each time you execute the program. It will increment a variable each time it loops through the WHILE block.

            The same thing can be used inside a PCDMIS loop like so:

            Code:
                         ASSIGN/LOOPINDEX  = 1
            THE_LOOP     =LOOP/START, ID = YES, NUMBER = 6, START = 1, SKIP = ,
                           OFFSET: XAXIS = 0, YAXIS = 0, ZAXIS = 0, ANGLE = 0
            .
            .(program code here)
            .
                          ASSIGN/LOOPINDEX  = LOOPINDEX  + 1
            If what you want to do is make a counter that will iterate each time the program is executed you might want to put the index in a text file like so (this is Jan’s suggestion):

            Code:
            V1 =FILE/EXISTS,C:\PCDMISW\LoopCounter.txt
                         IF/V1==0
                       ASSIGN/LOOPINDEX = 1
            FPTR       =FILE/OPEN, C:\PCDMISW\LoopCounter.txt,WRITE
            V1         =FILE/WRITELINE,FPTR, LOOPINDEX
                        FILE/CLOSE,FPTR
                        END_IF/
                        ELSE/
            FPTR       =FILE/OPEN, C:\PCDMISW\LoopCounter.txt,READ
            V1         =FILE/READLINE,FPTR,{LOOPINDEX}
                        FILE/CLOSE,FPTR
                        END_ELSE/
            .
            .(part program code here)
            .
                        ASSIGN/LOOPINDEX  = LOOPINDEX  + 1
            FPTR       =FILE/OPEN, C:\PCDMISW\LoopCounter.txt,WRITE
            V1         =FILE/WRITELINE,FPTR,LOOPINDEX
                        FILE/CLOSE,FPTR
            Like I said, not knowing exactly what you want to do you could see if one of these solves your problem. If you use the later solution you’ll need a text file for each part program or it will write to the same file for every part and screw your count up.

            Craig
            <internet bumper sticker goes here>

            Comment


            • #7
              Thanks Craiger Ny I'll give this a shot.

              Comment

              Related Topics

              Collapse

              Working...
              X