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 think I snagged this from the PCDBASIC help file, not sure. This should be run as a script though.

    Sub Main()
    Dim FileArray() As String
    Dim FileName As String
    
    ' Setup Folder And filecounter
    ' Example lists all bitmaps In C:\Windows
    Folder = Dir("C:\Windows\*.bmp")
    count = 0
    
    ' Parse the folder Until filename returns empty (no more files)
    ' And count the files ending With .bmp
    While Folder <> ""
        count = count + 1
        Folder = Dir
    Wend
    
    ' The MsgBox is For debug/example purposes And displays the
    ' number of bitmaps found
    MsgBox "Filecount: " & count
    
    ' Initialize the FileArray (create the array) With the size of
    ' count (number of files found)
    ReDim FileArray(count)
    
    ' Fill the filearray With the bitmap filenames
    FileArray(0) = Dir("C:\Windows\*.bmp")
    
    ' For debug/example purposes, displays the bitmap filenames
    For i = 1 To count
        FileArray(i) = Dir
        FileName = FileName + Chr(13) + FileArray(i)
    Next i
    MsgBox FileName
    
    End Sub
  • It seems so, yes. Depending on what you need the data in array for, you might be able to do that in the script without the need to do the manipulation of the array in PC-DMIS?
Reply Children
No Data