September 26, 2022, 07:48:57 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Workaround for printing large strings (> 32768) to console window.

Started by LarryMc, June 26, 2007, 12:33:01 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

LarryMc

Until Paul fixes the problem with the buffer limit of EBasic's PRINT statement you can use the following function.

'============================================================================================
'  printLM
'  Subroutine to print strings longer than 32768 chars
'============================================================================================
sub printLM(istr as string)
   int start_pos, total_len
   total_len = len(istr)
   start_pos=1
   while total_len > 32000
      print mid$(istr,start_pos,32000),
      start_pos += 32000
      total_len -= 32000
   endwhile
   if start_pos <= len(istr)
      print mid$(istr,start_pos)
   else
      print
   endif
   return
endsub
and use it this way:   istring sAccum[200001]     :' <-- size of users choice

   openconsole
   sAccum="blah....blah....blah"
   sAccum = "more blah ....up to a total of 1 less character than # above" 

   printLM(sAccum)

   PRINT "PRESS <ANY> KEY TO END!"
   DO:UNTIL INKEY$<>""
   closeconsole
   END


REV: changed 53000 to 32000 because it would still not print properly under some conditions.  with 32000 it will always work.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library