Loopng with a Subroutine

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

  • Loopng with a Subroutine

    Version 2013

    I am using a Flow Control Loop to run a single program on multiple parts spaced evenly in the X and Y. It's been working fine.

    Today I wanted to get back to the SUBROUTINE thoughts I've been working on so I pulled the measurement portion of the program out and created a SUBROUTINE of it.

    That parts also works fine when I measure a single part.

    When I add the LOOP back in, the measurement program returns to the first part every time it indexes through the loops. I correctly moves to the next part for an initial measurement when in the main program.

    I've used some variable, reports and operator comments to prove to myself that the program is actually entering the SUBROUTINE correctly and indexing my variable correctly.

    Anyone know what I've missed?

    I even tried to change the SUBROUTINE alignment using X and Y offsets with variables to no avail.

    Thanks.

  • #2
    Turn on DEBUG = 1 to generate a file and when done delete or just switch DEBUG = 0


    An example of a "Poorman's debuger":
    Code:
    ASSIGN/DEBUG=0
    IF/DEBUG
    ASSIGN/LOG_FILE="C:\users\public\documents\wai\pc-dmis\2015.1\DEBUG_LOG.TXT"
    $$ NO,
    clears old contents
    FPTR =FILE/OPEN,LOG_FILE,WRITE
    FILE/WRITELINE,FPTR,"Started: " + SYSTEMTIME("hh:mm:ss tt") + ", " + SYSTEMDATE("MM'/'dd'/'yyyy")
    FILE/CLOSE,FPTR,KEEP
    END_IF/
    $$ NO,
    
    
    code goes here
    
    
    
    IF/DEBUG
    FPTR =FILE/OPEN,LOG_FILE,APPEND
    WHILE/COUNTER < LEN(THICKNESS)
        ASSIGN/COUNTER=COUNTER+1
        FILE/WRITELINE,FPTR,"Loop: " + COUNTER + ", value: " + THICKNESS[COUNTER]
    END_WHILE/
    FILE/WRITELINE,FPTR,"__________________________________ ___________"
    END_IF/
    $$ NO,
    
    
    code goes here
    
    
    
    IF/DEBUG
    FPTR =FILE/OPEN,LOG_FILE,APPEND
    FILE/WRITELINE,FPTR,"********************************** ***********"
    FILE/WRITELINE,FPTR,"Information about point SB1:"
    FILE/WRITELINE,FPTR,"XYZ: " + SB1.XYZ
    FILE/WRITELINE,FPTR,"IJK: " + SB1.IJK
    FILE/WRITELINE,FPTR,"__________________________________ ___________"
    FILE/CLOSE,FPTR,KEEP
    END_IF/
    $$ NO,
    
    
    code goes here
    
    
    
    IF/DEBUG
    FPTR =FILE/OPEN,LOG_FILE,APPEND
    FILE/WRITELINE,FPTR,"********************************** ***********"
    FILE/WRITELINE,FPTR,"information for point: SB4"
    FILE/WRITELINE,FPTR,"Point targs X: " + TARGPNTX
    FILE/WRITELINE,FPTR,"Point targs Y: " + TARGPNTY
    FILE/WRITELINE,FPTR,"Point rotated X: " + ROTATEDX
    FILE/WRITELINE,FPTR,"Point rotated Y: " + ROTATEDY
    FILE/WRITELINE,FPTR,"opp vec I: " + OPPI
    FILE/WRITELINE,FPTR,"opp vec J: " + OPPJ
    FILE/WRITELINE,FPTR,"__________________________________ ___________"
    FILE/CLOSE,FPTR,KEEP
    END_IF/
    Outputs something similar to this:
    Code:
    Started: 12:44:44 PM, 01/17/2020
    *********************************************
    Loop: 1, value: 0.1008
    Loop: 2, value: 0.1007
    Loop: 3, value: 0.1007
    Loop: 4, value: 0.101
    Loop: 5, value: 0.1003
    Loop: 6, value: 0.1003
    Loop: 7, value: 0.1003
    Loop: 8, value: 0.1009
    Loop: 9, value: 0.1009
    Loop: 10, value: 0.1009
    Loop: 11, value: 0.102
    Loop: 12, value: 0.1017
    part: U*******-1 and sn: ONLINE-1
    _____________________________________________

    This should assist better when writing subroutines.

    To better help YOU please post some code. Loops should be easy but Pc-Dmis...
    Last edited by Kp61dude!; 01-17-2020, 04:36 PM.
    PcDmis 2015.1 SP10 CAD++
    Global 7-10-7 DC800S

    Comment


    • #3
      Press F5 and ensure that "Reset global settings when branching" is un-checked.

      Comment

      Related Topics

      Collapse

      Working...
      X