hexagon logo

Reading from File into an Array

Hello,
I'm currently running a measurement routine that calls this subroutine to read nominal positions of x and y into two arrays:
STARTUP =ALIGNMENT/START,RECALL:USE_PART_SETUP,LIST=YES
ALIGNMENT/END
MODE/MANUAL
MOVESPEED/ 50
TOUCHSPEED/ 3
FORMAT/TEXT,OPTIONS, ,HEADINGS,SYMBOLS, ;NOM,MEAS,TOL,DEV,OUTTOL, ,
SUBROUTINE/MATRIX,
V_MATRIX = V_MATRIX : V_MATRIX,
=
LOADPROBE/5X-
TIP/TIP1, SHANKIJK=0, 0, 1, ANGLE=0
IF_GOTO/V_MATRIX=="NO",GOTO = ENDEMATRIX
ASSIGN/AVXPOS=ARRAY(0)
ASSIGN/AVYPOS=ARRAY(0)
ASSIGN/AVX=0
ASSIGN/AVY=0
ASSIGN/TZ=","
FPTR =FILE/OPEN,D:\V_2019R1\NOMINALS.txt,READ
ASSIGN/INC=1
DO/
V1 =FILE/READLINE,FPTR,{AVX}+TZ+{AVY}
ASSIGN/AVXPOS[INC]=AVX
ASSIGN/AVYPOS[INC]=AVY
ASSIGN/AVXPOS[LENG(AVXPOS)+1]=0
ASSIGN/AVYPOS[LENG(AVYPOS)+1]=0
ASSIGN/INC=INC+1
UNTIL/V1=="EOF"
FILE/CLOSE,FPTR,KEEP
ASSIGN/V_AVX=AVXPOS
ASSIGN/V_AVY=AVYPOS
ENDEMATRIX =LABEL/
ENDSUB/

I use the subroutine it like this:
CS8 =CALLSUB/MATRIX,D:\V_2019R1\SUB_MATRIX.PRG:,,
ASSIGN/XMITT=V_AVX
ASSIGN/YMITT=V_AVY

This is all running very slow. For 1100 lines in the NOMINALS.txt it takes about 60 sec to read. I heard that using a basic script could speed this up. But how do I read into an array?
Parents
  • I don't know if this will do it for you, but in code it would be something like:

    (In declarations):

    Public Xval(5000) as Double, Yval(5000) as double


    In the sub:
    Open {path/filename} For Input as #1
    Do While Not EOF(1)
    input #1, Xval(MyCount),Yval(MyCount)
    Mycount=MyCount+1
    Loop
    Close #1
    


    May work for you....
Reply
  • I don't know if this will do it for you, but in code it would be something like:

    (In declarations):

    Public Xval(5000) as Double, Yval(5000) as double


    In the sub:
    Open {path/filename} For Input as #1
    Do While Not EOF(1)
    input #1, Xval(MyCount),Yval(MyCount)
    Mycount=MyCount+1
    Loop
    Close #1
    


    May work for you....
Children