hexagon logo

Using Variables in READLINE

This is probably a simple syntax problem, but searching has not given me any clues.

Goal: automate report display of heat lot code unique to workpiece serial #.

Done: Operator inputs serial # which is assigned to variable V1.

Done: CSV file created with master list of serial #s in first column with heat lot codes in next column.

Not working: getting file pointer to look for a variable (V1 the serial #) to return text after.

The READLINE example from the Help is designed to look for a standard block of text (Part ID, Location, etc) to return text after.

In my code so far, file pointer looks for text "V1" but returns nothing as it's not looking for the value of variable V1.

Code:

C1         =COMMENT/INPUT,YES,'Serial Number:'
            ASSIGN/V1=C1.INPUT
FPTR       =FILE/OPEN,C:\BLADERUNNER\BLADES\ROW_2\ROW2_HEAT_LOT_CODES.CSV,READ
VREAD      =FILE/READLINE,FPTR, "V1" +{VCODE}
            COMMENT/REPT,VCODE
            FILE/CLOSE,FPTR,KEEP
.
.
.


Thanks in advance!
Parents
  • Hmmmm...

    Update:
    Added the explicit declaration of VCODE and filled it with a dummy value.
    Changed the syntax per recomendation.
    Note that "198" is the actual sample workpiece serial #.

                ASSIGN/VCODE=42
    C1         =COMMENT/INPUT,YES,'Serial Number:'
                ASSIGN/V1=C1.INPUT
    FPTR       =FILE/OPEN,C:\BLADERUNNER\BLADES\ROW_2\ROW2_HEAT_LOT_CODES.CSV,READ
    VREAD      =FILE/READLINE,FPTR, V1 + {VCODE}
                COMMENT/REPT,VCODE
                FILE/CLOSE,FPTR,KEEP


    Same results - the report displays:
    'Serial Number:' 198
    0


    So the dummy value of 42 is being replaced with 0.


    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


    Next attempt:
    Converted the CSV file to a text file and replaced all comma seperators with spaces.
    Also, I added a comment line to display the success or failure of the read, which is stored in the VREAD variable of the READLINE command.

                ASSIGN/VCODE=42
    C1         =COMMENT/INPUT,YES,'Serial Number:'
                ASSIGN/V1=C1.INPUT
    FPTR       =FILE/OPEN,C:\BLADERUNNER\BLADES\ROW_2\ROW2_HEAT_LOT_CODESTXT.TXT,READ
    VREAD      =FILE/READLINE,FPTR, V1 + {VCODE}
                COMMENT/REPT,VCODE
                FILE/CLOSE,FPTR,KEEP


    Report displays:
    'Serial Number:' 198
    42
    ERROR


    This tells me that the READLINE is not wiping out the dummy value of 42 that I used while assigning VCODE.

    This is clearly a step in the wrong direction.


    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Round 3:
    OK, change back to CSV but keep the other changes:
                ASSIGN/VCODE=42
    C1         =COMMENT/INPUT,YES,'Serial Number:'
                ASSIGN/V1=C1.INPUT
    FPTR       =FILE/OPEN,C:\BLADERUNNER\BLADES\ROW_2\ROW2_HEAT_LOT_CODES.CSV,READ
    VREAD      =FILE/READLINE,FPTR, V1 + {VCODE}
                COMMENT/REPT,VCODE
                COMMENT/REPT,VREAD
                FILE/CLOSE,FPTR,KEEP


    Report displays:
    'Serial Number:' 198
    0
    ERROR


    Same failure-to-read error but for some reason the CSV file method replaces the dummy 42 with 0.

    OK, the little window of experimentation time has closed. Back to production.

    vpt.se, thank you for trying to help me. I suspect I may have to dwelve into scripting to accomplish this automation.

    - Josh
Reply
  • Hmmmm...

    Update:
    Added the explicit declaration of VCODE and filled it with a dummy value.
    Changed the syntax per recomendation.
    Note that "198" is the actual sample workpiece serial #.

                ASSIGN/VCODE=42
    C1         =COMMENT/INPUT,YES,'Serial Number:'
                ASSIGN/V1=C1.INPUT
    FPTR       =FILE/OPEN,C:\BLADERUNNER\BLADES\ROW_2\ROW2_HEAT_LOT_CODES.CSV,READ
    VREAD      =FILE/READLINE,FPTR, V1 + {VCODE}
                COMMENT/REPT,VCODE
                FILE/CLOSE,FPTR,KEEP


    Same results - the report displays:
    'Serial Number:' 198
    0


    So the dummy value of 42 is being replaced with 0.


    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


    Next attempt:
    Converted the CSV file to a text file and replaced all comma seperators with spaces.
    Also, I added a comment line to display the success or failure of the read, which is stored in the VREAD variable of the READLINE command.

                ASSIGN/VCODE=42
    C1         =COMMENT/INPUT,YES,'Serial Number:'
                ASSIGN/V1=C1.INPUT
    FPTR       =FILE/OPEN,C:\BLADERUNNER\BLADES\ROW_2\ROW2_HEAT_LOT_CODESTXT.TXT,READ
    VREAD      =FILE/READLINE,FPTR, V1 + {VCODE}
                COMMENT/REPT,VCODE
                FILE/CLOSE,FPTR,KEEP


    Report displays:
    'Serial Number:' 198
    42
    ERROR


    This tells me that the READLINE is not wiping out the dummy value of 42 that I used while assigning VCODE.

    This is clearly a step in the wrong direction.


    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Round 3:
    OK, change back to CSV but keep the other changes:
                ASSIGN/VCODE=42
    C1         =COMMENT/INPUT,YES,'Serial Number:'
                ASSIGN/V1=C1.INPUT
    FPTR       =FILE/OPEN,C:\BLADERUNNER\BLADES\ROW_2\ROW2_HEAT_LOT_CODES.CSV,READ
    VREAD      =FILE/READLINE,FPTR, V1 + {VCODE}
                COMMENT/REPT,VCODE
                COMMENT/REPT,VREAD
                FILE/CLOSE,FPTR,KEEP


    Report displays:
    'Serial Number:' 198
    0
    ERROR


    Same failure-to-read error but for some reason the CSV file method replaces the dummy 42 with 0.

    OK, the little window of experimentation time has closed. Back to production.

    vpt.se, thank you for trying to help me. I suspect I may have to dwelve into scripting to accomplish this automation.

    - Josh
Children
No Data