SELECT FD && hoist out of the loop there is no need to keep selecting the work area && for every line of the file DO WHILE ! FEOF( nCDataHandle ) && can get rid of the seperate IF by testing this here DataString = FGETS(nCDataHandle,5000) m.Start = 1 SCAN m.FieldNum = FD.Field_Name FieldData = SUBSTR(DataString,m.Start,FD.Field_Len) store IIF(FD.Field_Type = 'N',VAL(m.FieldData),m.FieldData) to (FieldNum) m.Start = m.Start + FD.Field_Len ENDSCAN INSERT INTO (OutputName) FROM MEMVAR enddoThe STORE command can use a name expression as it's destination and you avoid the cost of macro expansion.
dimension laData( reccount( "fd" ) ) scan FieldData = SUBSTR(DataString,m.Start,FD.Field_Len) laData[recno( "fd" )] = iif(FD.Field_Type = 'N',VAL(m.FieldData),m.FieldData) m.Start = m.Start + FD.Field_Len endscan insert into (OutputName) from array laDataI don't really see what in there is dealing with more than 256 columns. Since this appears to be an SDF so something like this might work well for you:
fhOut1 = fopen( "temp1.txt", 1 ) fhout2 = fopen( "temp2.txt", 1 ) do while ! feof( fhIn ) lcAllData = fgets( fhIn, 5000 ) fputs( fhOut1, substr( lcAllData, 1, lnSlplitPoint ) ) fputs( fhOut2, substr( lcAllData, lnSplitPoint + 1 ) ) enddo fclose && each handle select Table1 append from temp1.txt type sdf select Table2 append from temp2.txt type sdfActually you don't have to split off the first set of bytes from each row because the first append from could use the original input file and it'll ignore the part of the line that doesn't fit in Table1.