The statics bug has been resolved.
There a still problems with FILES though. (See this file)
This commit is contained in:
@@ -18,13 +18,11 @@ function Main( cFrom, cTo )
|
||||
local oTo
|
||||
local cOut
|
||||
|
||||
static oTrick1, oTrick2 // Dirty trick
|
||||
|
||||
cFrom := Default( cFrom, "strip.prg" )
|
||||
cTo := Default( cTo, "strip.out" )
|
||||
|
||||
oFrom := TDosFile(oTrick1):Stew( cFrom, "R" )
|
||||
oTo := TDosFile(oTrick2):Stew( cTo , "W" )
|
||||
oFrom := TTextFile():New( cFrom, "R" )
|
||||
oTo := TTextFile():New( cTo , "W" )
|
||||
|
||||
do while !oFrom:lEoF
|
||||
cOut := oFrom:Run()
|
||||
@@ -41,13 +39,11 @@ return nil
|
||||
//
|
||||
// Generic DOS file handler
|
||||
//
|
||||
function TDosFile( oGoneFile ) // Parameter = dirty
|
||||
function TTextFile() // Parameter = dirty
|
||||
|
||||
static oFile
|
||||
local oRet
|
||||
|
||||
if oFile == NIL // Second instance not correct
|
||||
QOut("Here")
|
||||
if oFile == NIL
|
||||
oFile := TClass():New( "TDosFile" ) // Create a new class def
|
||||
|
||||
oFile:AddData( "cFileName" ) // Filename spec. by user
|
||||
@@ -60,7 +56,7 @@ function TDosFile( oGoneFile ) // Parameter = dirty
|
||||
oFile:AddData( "cMode" ) // Mode of file use
|
||||
// R = read, W = write
|
||||
|
||||
oFile:AddMethod( "Stew" , @Stew() ) // Constructor
|
||||
oFile:AddMethod( "New" , @New() ) // Constructor
|
||||
oFile:AddMethod( "Run" , @Run() ) // Get/set data
|
||||
oFile:AddMethod( "Dispose", @Dispose() ) // Clean up code
|
||||
oFile:AddMethod( "Read" , @Read() ) // Read line
|
||||
@@ -71,19 +67,17 @@ function TDosFile( oGoneFile ) // Parameter = dirty
|
||||
|
||||
oFile:Create()
|
||||
endif
|
||||
oRet := oFile:Instance()
|
||||
|
||||
return oRet
|
||||
return oFile:Instance()
|
||||
|
||||
|
||||
//
|
||||
// Method DosFile:Stew -> Create a new dosfile
|
||||
// Method TextFile:New -> Create a new text file
|
||||
//
|
||||
// <cFile> file name. No wild characters
|
||||
// <cMode> mode for opening. Default "R"
|
||||
// <nBlockSize> Optional maximum blocksize
|
||||
//
|
||||
function Stew( cFileName, cMode, nBlock )
|
||||
function New( cFileName, cMode, nBlock )
|
||||
|
||||
local self := QSelf() // Get self
|
||||
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
There are four strip files here :
|
||||
Strip
|
||||
|
||||
#1 : strip.prg This one is broken
|
||||
#2 : strip2.prg This one works
|
||||
#3 : strip3.prg Broken as well
|
||||
#4 : strip4.prg Works. Includes TClass()
|
||||
Strip is a program which copies the infile to the outfile.
|
||||
|
||||
You'll need to the latest FILES.C for this + my harbour.y patch.
|
||||
The reason why this program is still broken is because there is still a
|
||||
discussion about the file format
|
||||
|
||||
The first one uses the TClass().
|
||||
Newline = chr(10) or chr(13)+chr(10)
|
||||
End of file = chr(0) or chr(26)
|
||||
|
||||
The second one uses the Class functions.
|
||||
Another reason is that the fRead does not work properly yet.
|
||||
|
||||
The third one uses the TClass() but store ClassH in the static.
|
||||
|
||||
The fourth one has TClass() in the .PRG.
|
||||
|
||||
The STATIC which is used, is removed (set to NIL) once you are done.
|
||||
The program now uses fReadStr, which reads a single character at a time
|
||||
|
||||
The TextFile class has been designed to allow to read (large) blocks.
|
||||
|
||||
Good luck
|
||||
|
||||
|
||||
Reference in New Issue
Block a user