Restored from previous forum. Originally posted by Ralf.
ReadString() should be able to handle Strings larger than 64 k.
At least 300 k.
[Implemented] ReadString()
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by PB.
currently handle strings of 64k. But Fred said unlimited strings are coming
very soon, so relax.
(Here is what Fred said: "Yes, Strings are limited to 5000 bytes for now.
2.80 will extend this limit to 64k and v3.0 should provide unlimited length.").
PB - Registered PureBasic Coder
It's not ReadString() that's the problem; it's the fact that PureBasic can onlyReadString() should be able to handle Strings larger than 64 k.
currently handle strings of 64k. But Fred said unlimited strings are coming
very soon, so relax.
(Here is what Fred said: "Yes, Strings are limited to 5000 bytes for now.
2.80 will extend this limit to 64k and v3.0 should provide unlimited length.").
PB - Registered PureBasic Coder
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Rings.
Okay guys, here it it:
(i hope that the (+) PLUS-Sign is in the code, coz in the Preview ist missing )
; ReplaceString for large Files
;
; by Siegfried (Siggi) Rings
; Note, this is in PureBasic , not in Assembler
; but Assembler can speed up this routine.
; btw it is fast enough and beats every VB indeed.
; Length of Search and Replace must be the same !!!!
;
Procedure ReplaceFileString(File.s,Search.s,Replace.s)
If Len(Search)Len(Replace)
;Length of Search and Replace must be the same !!!!
ProcedureReturn -2
EndIf
;MessageRequester("Info",File+Chr(13)+Search+Chr(13)+Replace,0)
pResult.l=-1
If ReadFile(0, File)
FileLength = Lof()
If FileLength And AllocateMemory(0, FileLength , 0)
Mempointer=UseMemory(0)
ReadData(Mempointer, FileLength) ; Read the whole file in the memory buffer
;So now we have all Data from the file in memory
T=0
P=0
L=Len(Search)
; MessageRequester("Info",Str(FileLength)+":"+Str(L),0)
NochMal:
a=PeekB(UseMemory(0)+T);Read a byte
If a=Asc(Mid(Search,P+1,1)) ;Is byte same as in Search ?
If P=L-1
;Okay found, now replace it
For H=1 To L
PokeB(UseMemory(0)+T-L+H,Asc(Mid(Replace,H,1)) )
Next H
P=0;Reset Pointer in SearchString
pResult=pResult+1; increment our ResultCounter
MessageRequester("Info","Found at Position "+Str(T-L),0)
Else
P=P+1
T=T+1
Goto NochMal
EndIf
Else
P=0
EndIf
T=T+1
If T-1
MessageRequester("Info",Str(Result+1)+" has been replaced!",0)
Else
MessageRequester("Info",Str(Result+1)+" ERROR",0)
EndIf
Siggi
Okay guys, here it it:
(i hope that the (+) PLUS-Sign is in the code, coz in the Preview ist missing )
; ReplaceString for large Files
;
; by Siegfried (Siggi) Rings
; Note, this is in PureBasic , not in Assembler
; but Assembler can speed up this routine.
; btw it is fast enough and beats every VB indeed.
; Length of Search and Replace must be the same !!!!
;
Procedure ReplaceFileString(File.s,Search.s,Replace.s)
If Len(Search)Len(Replace)
;Length of Search and Replace must be the same !!!!
ProcedureReturn -2
EndIf
;MessageRequester("Info",File+Chr(13)+Search+Chr(13)+Replace,0)
pResult.l=-1
If ReadFile(0, File)
FileLength = Lof()
If FileLength And AllocateMemory(0, FileLength , 0)
Mempointer=UseMemory(0)
ReadData(Mempointer, FileLength) ; Read the whole file in the memory buffer
;So now we have all Data from the file in memory
T=0
P=0
L=Len(Search)
; MessageRequester("Info",Str(FileLength)+":"+Str(L),0)
NochMal:
a=PeekB(UseMemory(0)+T);Read a byte
If a=Asc(Mid(Search,P+1,1)) ;Is byte same as in Search ?
If P=L-1
;Okay found, now replace it
For H=1 To L
PokeB(UseMemory(0)+T-L+H,Asc(Mid(Replace,H,1)) )
Next H
P=0;Reset Pointer in SearchString
pResult=pResult+1; increment our ResultCounter
MessageRequester("Info","Found at Position "+Str(T-L),0)
Else
P=P+1
T=T+1
Goto NochMal
EndIf
Else
P=0
EndIf
T=T+1
If T-1
MessageRequester("Info",Str(Result+1)+" has been replaced!",0)
Else
MessageRequester("Info",Str(Result+1)+" ERROR",0)
EndIf
Siggi
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm