PureBasic 读取文件中一行的两个数据例子

If ReadFile(0, "Test1.txt")   ; if the file could be read, we continue...
  If CreateFile(1, "Test2.txt") 
  While Eof(0) = 0     ; loop as long the 'end of file' isn't reached
    Astring$=ReadString(0)
    A$=StringField(Astring$,1,",")
    B$=StringField(Astring$,2,",")
    WriteStringN(1, A$+","+B$)
    Wend
    CloseFile(0)               ; close the previously opened file
    CloseFile(1)
    EndIf
  Else
    MessageRequester("信息","文件无法打开!")
  EndIf

 

你可能感兴趣的:(读取文件)