主题:怎样读log文件并保存为.txt文件(初识vb,请各位大侠帮忙)
我有一个HTBasic程序生成的数据log文件,没有后缀的,应该是binary文件。我想读取它并生成.txt形式的文件。请问用vb怎么实现? (附上log文件和用HTBasic读取的数据文件供参考)
我知道用HTBisic可以把它转成.txt,代码如下:
SUB Convert_burnlog
DIM Runnum$[10],Ws1$[80],Ws2$[80],Ws3$[80],Ws4$[80],Ws5$[80],Ws6$[80]! #'S IN SER$ AS [6*#-5,6*#]
INTEGER Actvtstr,Runseq,Lp1,Lp2,Lp3,Lp4,Maxtstr,Outdev,Tries,Trieslim,Win1,Win2,Win3,Win4,Win5,Win6,Win7,Win8,Winary(0:39)! Runseq IS FOR RUN NUMBER
INTEGER Timact,Sumrec,Eof_run,Numruns,Eof_brn
!CURRENT IN 0.1 mA, DEG. RATE IN 0.001 mA/hr, IVSTARY(n,40)= EL. TIME IN 0.1 hr
INTEGER Indx,Eof,Lastpt!--END OF FILE AND LAST DATA POINT FOUND
INTEGER Rs_fill!REV C.17
COM /Dfil/Sys$[4],@Burnlog,@Runsum,@Cnstilog
COM /Msus/Hard$[10],Flop$[8],Defaultdrive$[10],Subdir$[12],Netswpdir$[20]
!---------------------------------------------------
Hard$="D:\share\"
ON ERROR GOTO Purge_finished
PURGE Hard$&"BURNLOG.txt"
Purge_finished:!
OFF ERROR
ON ERROR GOTO Finish_line
CREATE Hard$&"BURNLOG.txt",0
ASSIGN @Out TO Hard$&"BURNLOG.txt";FORMAT ON
ASSIGN @In TO Hard$&"BURNLOG"
STATUS @In,7;Eof_brn
FOR Lp1=1 TO Eof_brn-1
Lp2=0! PLACE IN NEW RUN NUMBER ARRAY
ENTER @In,Lp1;Runnum$,Win1,Winary(*),Rs_fill,Rs_fill
OUTPUT @Out;Lp1,Runnum$,Win1,Winary(*),Rs_fill,Rs_fill
NEXT Lp1
OUTPUT CRT
OUTPUT CRT
OUTPUT CRT;"BURNLOG.txt Updated Succesfully."
GOTO End_line
Finish_line:!
OFF ERROR
OUTPUT CRT;"BURNLOG.txt Updated Error."
End_line:!
ASSIGN @In TO *
ASSIGN @Out TO *
SUBEND
我知道用HTBisic可以把它转成.txt,代码如下:
SUB Convert_burnlog
DIM Runnum$[10],Ws1$[80],Ws2$[80],Ws3$[80],Ws4$[80],Ws5$[80],Ws6$[80]! #'S IN SER$ AS [6*#-5,6*#]
INTEGER Actvtstr,Runseq,Lp1,Lp2,Lp3,Lp4,Maxtstr,Outdev,Tries,Trieslim,Win1,Win2,Win3,Win4,Win5,Win6,Win7,Win8,Winary(0:39)! Runseq IS FOR RUN NUMBER
INTEGER Timact,Sumrec,Eof_run,Numruns,Eof_brn
!CURRENT IN 0.1 mA, DEG. RATE IN 0.001 mA/hr, IVSTARY(n,40)= EL. TIME IN 0.1 hr
INTEGER Indx,Eof,Lastpt!--END OF FILE AND LAST DATA POINT FOUND
INTEGER Rs_fill!REV C.17
COM /Dfil/Sys$[4],@Burnlog,@Runsum,@Cnstilog
COM /Msus/Hard$[10],Flop$[8],Defaultdrive$[10],Subdir$[12],Netswpdir$[20]
!---------------------------------------------------
Hard$="D:\share\"
ON ERROR GOTO Purge_finished
PURGE Hard$&"BURNLOG.txt"
Purge_finished:!
OFF ERROR
ON ERROR GOTO Finish_line
CREATE Hard$&"BURNLOG.txt",0
ASSIGN @Out TO Hard$&"BURNLOG.txt";FORMAT ON
ASSIGN @In TO Hard$&"BURNLOG"
STATUS @In,7;Eof_brn
FOR Lp1=1 TO Eof_brn-1
Lp2=0! PLACE IN NEW RUN NUMBER ARRAY
ENTER @In,Lp1;Runnum$,Win1,Winary(*),Rs_fill,Rs_fill
OUTPUT @Out;Lp1,Runnum$,Win1,Winary(*),Rs_fill,Rs_fill
NEXT Lp1
OUTPUT CRT
OUTPUT CRT
OUTPUT CRT;"BURNLOG.txt Updated Succesfully."
GOTO End_line
Finish_line:!
OFF ERROR
OUTPUT CRT;"BURNLOG.txt Updated Error."
End_line:!
ASSIGN @In TO *
ASSIGN @Out TO *
SUBEND