IonicWind Software

IWBasic => Console Corner => Topic started by: GJ on February 11, 2007, 08:22:15 AM

Title: large strings
Post by: GJ on February 11, 2007, 08:22:15 AM
Hi,


Just some fooling around with big strings / reading big datablocks , i encountered that i can't go further than this stepsize (53215)
I have no problem with that, i can always use smaller amount of stepsize ;D

Regards,

Gertjan (GJ)



Quote
autodefine "off"

BFILE myfile
string filename$,a
memory memoryfile
istring l$[3000000]
int flen,count
int linelen

filename$="C:\\abc.txt"

/*
a="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"

IF OPENFILE(myfile, filename$, "W") = 0
   for count=1 to 20000
   WRITE myfile, a+USING("####",count)
   next count
   CLOSEFILE myfile
ENDIF
*/

IF OPENFILE(myfile,filename$, "r") = 0
  flen = LEN(myfile) 
closefile myfile
ENDIF

allocmem memoryfile,1,flen+1

'write to memory

IF OPENFILE(myfile,filename$,"r") =0
  __read(myfile,L$,flen)
__writemem memoryfile,1,l$,flen
ENDIF

'read from memory back

__readmem memoryfile,1,l$,flen

linelen=53215  : 'still works
' linelen=53216 : 'doesnt work

for count=1 to flen step linelen
print mid$(l$,count,linelen)
print count
next count

print
print " Any key to end"
do:until inkey$<>""
freemem memoryfile
end




Title: Re: large strings
Post by: Ionic Wind Support Team on February 11, 2007, 09:02:07 AM
Your exceeding the capabilities of the PRINT statement.  PRINT has an internal 32K buffer that it copies the converted paramters to before outputting them to the console or window.  I never thought anyone would be exceeding that buffer ;)

I will change it in the next update to properly truncate without overwriting the buffer.

Paul.
Title: Re: large strings
Post by: Parker on February 11, 2007, 12:27:17 PM
So that's what it is. I remember a program crashing when I printed a whole big string at once, but doing fine if I printed it in individual pieces. I think it was a tokenizer program.
Title: Re: large strings
Post by: Rod on February 12, 2007, 08:11:24 AM
QuoteI never thought anyone would be exceeding that buffer

Buffer size limits exist to be exceeded.

Set the limit to 1 Gb, and somebody somewhere will try to print 2 Gb!!!
Title: Re: large strings
Post by: GJ on February 12, 2007, 10:05:35 AM
Thanks Paul for the explanation, btw i don't need 1 Gb , i was just curious why it didnt work  ;)


Regards,


GJ