截取数据采集系统部分,看obs[]和range[]能采到数据吗

截取数据采集系统一部分,看obs[]和range[]能采到数据吗?
只是输出不了,不知道哪里出问题了。
采集部分                    tempstr := copy(readstrbuffer,rnum+14,length(readstrbuffer)-rnum-13); //RANGEA段开始 去#RANGEA,COM1,0,
//#RANGEA,COM1,0,63.5,FINESTEERING,1429,226979.000,00000000,5103,2748;
//26,
//6,0,23359924.081,0.078,-122757217.106875,0.015,-3538.602,43.3,19967.080,08109C04,
//.
//43,8,20375687.399,0.253,-108919708.904476,0.012,-2781.090,39.1,10629.934,18119E84
                                     tempnum := Posch(';',tempstr);
                                     tempstr := copy(tempstr,tempnum+1,length(tempstr)-tempnum);
                                     tempnum := Posch(',',tempstr);
                                     gps1[4,GPS1bagnum] := copy(tempstr,0,tempnum-1);
                                     j :=strtoint(gps1[4,GPS1bagnum]);
                                     tempstr := copy(tempstr,tempnum+1,length(tempstr)-tempnum);
                                     tempnum := Posch(',',tempstr);
                                     obs[j,GPS1bagnum] := copy(tempstr,0,tempnum-1);
                                     tempstr := copy(tempstr,tempnum+1,length(tempstr)-tempnum);
                                     tempnum := Posch(',',tempstr);
                                     tempstr := copy(tempstr,tempnum+1,length(tempstr)-tempnum);
                                     tempnum := Posch(',',tempstr);
                                     range[j,GPS1bagnum] := copy(tempstr,0,tempnum-1);
                                     tempstr := copy(tempstr,tempnum+1,length(tempstr)-tempnum);
                                     while (j>1) do
                                       begin
                                         dec(j);
                                         tempnum := Posch(',',tempstr);
                                         tempstr := copy(tempstr,tempnum+1,length(tempstr)-tempnum);
                                         tempnum := Posch(',',tempstr);
                                         tempstr := copy(tempstr,tempnum+1,length(tempstr)-tempnum);
                                         tempnum := Posch(',',tempstr);
                                         tempstr := copy(tempstr,tempnum+1,length(tempstr)-tempnum);
                                         tempnum := Posch(',',tempstr);
                                         tempstr := copy(tempstr,tempnum+1,length(tempstr)-tempnum);
                                         tempnum := Posch(',',tempstr);
                                         tempstr := copy(tempstr,tempnum+1,length(tempstr)-tempnum);
                                         tempnum := Posch(',',tempstr);
                                         tempstr := copy(tempstr,tempnum+1,length(tempstr)-tempnum);
                                         tempnum := Posch(',',tempstr);
                                         tempstr := copy(tempstr,tempnum+1,length(tempstr)-tempnum);
                                         tempnum := Posch(',',tempstr);
                                         obs[j,GPS1bagnum] := copy(tempstr,0,tempnum-1);
                                         tempstr := copy(tempstr,tempnum+1,length(tempstr)-tempnum);
                                         tempnum := Posch(',',tempstr);
                                         tempstr := copy(tempstr,tempnum+1,length(tempstr)-tempnum);
                                         tempnum := Posch(',',tempstr);
                                         range[j,GPS1bagnum] := copy(tempstr,0,tempnum-1);
                                         tempstr := copy(tempstr,tempnum+1,length(tempstr)-tempnum);
                                       end;
输出部分 assignfile(filevar,'E:\TestData\车载多传感器数据采集系统\Gps1\'+savename+'.txt');
                 rewrite(filevar);
                 for i:=1 to GPS1bagnum  do
                begin
                write(filevar,                                       
format('%5d%10s%15s%15s%10s%5s%15s%15s%15s%5s'[i,posa1[0,i],posa1[1,i],posa1[2,i],posa1[3,i],gps1[0,i],gps1[1,i],gps1[2,i],gps1[3,i],gps1[4,i]]));
            j :=strtoint(gps1[4,i]);
            while (j>1) do
              begin
              write(filevar,format('%5s%20s',[obs[j,i],range[j,i]]));
              dec(j);
              end;
            writeln(filevar,format('%5s%20s',[obs[1,i],range[1,i]]));
          end;
        closefile(filevar);
------解决思路----------------------
代码太密集了,单步跟踪一下,看看数据在哪一步开始没了

另外,如果是按逗号分隔的数据,最好写一个通用函数,或利用Tstringlist,以便 用简单代码即可得到需要的数据