Posted: Mon Apr 22, 2002 8:47 pm
Restored from previous forum. Originally posted by TronDoc.
if you remove the ;s before the Return and fakesub: below the Writeasc:
you will see what the program is supposed to write to the new file.
with the ;s left in, the first line of the new program is written
correctly, but after that something goes wrong.
I think it has to do with not being able to specify a file number
in the lof() and ReadString() functions?
If there is a way to make this work, I'd really be happy to hear from you.
The WSKED.fil can be any ASCII text file:
------WSKED.fil------snip here-----
The Quick Brown Fox Jumped
Over the Lazy Dog.
------end of WSKED.fil------------
the output should be:
[The][Quick][Brown][Fox][Jumped]
[Over][the][Lazy][Dog.]
but ends up being:
[The][Quick][Brown][Fox][Jumped]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]etc.etc.etc......the program has to be aborted at this point of course!
Joe B.
elecTRONics DOCtor
{registeredPB}P150 32Mb w98/DOS/Linux NO DirX NO IE
if you remove the ;s before the Return and fakesub: below the Writeasc:
you will see what the program is supposed to write to the new file.
with the ;s left in, the first line of the new program is written
correctly, but after that something goes wrong.
I think it has to do with not being able to specify a file number
in the lof() and ReadString() functions?
If there is a way to make this work, I'd really be happy to hear from you.
The WSKED.fil can be any ASCII text file:
------WSKED.fil------snip here-----
The Quick Brown Fox Jumped
Over the Lazy Dog.
------end of WSKED.fil------------
the output should be:
[The][Quick][Brown][Fox][Jumped]
[Over][the][Lazy][Dog.]
but ends up being:
[The][Quick][Brown][Fox][Jumped]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]etc.etc.etc......the program has to be aborted at this point of course!
Joe B.
Code: Select all
; ------------------------------------------------------------
text$ = "by the elecTRONics DOCtor" ; just a small text$ string
dlay1 = 000 ; delay will set to 400
dlay2 = 4000 ; delay will set to 4000
x = 0
y = 0
OpenConsole() ; First we must open a console
ConsoleTitle ("PureBasic - xx:") ; Now we can give the opened console a Titlename :wink:
If ReadFile(0, "WSKED.FIL")
While Eof(0)=0
FIL$ = StripTrail(StripLead(ReadString()))
PrintN (FIL$) ; Print our text
Gosub FIL2asc
PrintN (NewString$)
Delay(dlay1) ; Waits for moment
Wend
CloseFile(0)
Else
MessageRequester("PureBasic", "Error: Can't read file", 0)
EndIf
Delay(dlay2) ; Waits for moment
;-------- Cls --------
ClearConsole() ; This will clean the ConsoleScreen
CloseConsole()
End
FIL2asc:
NewString$="["
FILlen = Len(FIL$)
PrintN(Str(FILlen))
commaCount = 0
For StartPosition = 1 To FILlen
FILchar$ = Mid(FIL$, StartPosition, 1)
If FILchar$ = " " And StartPosition 1 And StartPosition FILlen
NewString$ = NewString$ + "]["
Else
NewString$ = NewString$ + FILchar$
EndIf
Next StartPosition
NewString$=NewString$+"]"
Gosub Writeasc
Return
Writeasc:
;Return
;fakesub:
If OpenFile(1, "OutPut.asc")
Length = Lof()
FileSeek(Length)
WriteStringN(NewString$)
CloseFile(1)
EndIf
Return
elecTRONics DOCtor
{registeredPB}P150 32Mb w98/DOS/Linux NO DirX NO IE