[comp.sys.mac.hypercard] Read file 16K limit problem

mari@levels.sait.edu.au (Renato Iannella CC2-4 X3033) (10/07/88)

--

Does anyone have any idea on how to read a text document (that is greater
than 16K in size) into a HyperTalk container ?

The problem is if you execute the following statement...

      read from file FILENAME for NUMCHARS

where FILENAME is the name of the file and NUMCHARS contains the number of
characters in the file.

Lets say that NUMCHARS contained "20480" (ie. 20K), the read statement would
only read-in 16K of characters as it assumes (i think) NUMCHARS is an
integer (integers go up to 16K) !!

The same problem occurs if you use the "read until CHAR" statement; it will
only read in the first 16K characters !

Has anyone solved this problem?  With an XCMD perhaps ?

Thanks in advance.

          /////////////////////////////////////////////////////////////////////
         //  Renato Iannella  B.App.Sc. AACS                           ///////
        //  South Australian Institute of Technology                     ////
       //  Mathematics and Computer Science Department                   ///
      //  The Levels 5095 Australia                                      //
     //  Phone# +61 8 343 3033       ACSNET & EAN: mari@levels.sait.oz  //
    //  Fax# +61 8 349 6939      JANET: mari%levels.sait.oz@uk.ac.ukc  //
   ///                       ARPANET & CSNET: mari@levels.sait.oz.au  //
  ////                     BITNET: mari%levels.sait.oz@uunet.uu.net  //
 ///////                  UUCP:  uunet!munnari!levels.sait.oz!mari  //
/////////////////////////////////////////////////////////////////////

dan@Apple.COM (Dan Allen) (10/14/88)

>Does anyone have any idea on how to read a text document (that is greater
>than 16K in size) into a HyperTalk container ?

It is very simple.  A HyperTalk variable is only limited by RAM.  Try
this:

	put empty into theText -- clear a variable named theText
	repeat
	  read from file "foo" for 16384 -- maximum chars to read
	  if it is empty then exit repeat -- end of file
	  put it after theText -- otherwise append to variable
	end repeat
	if the length of theText > 30000 then 
	  answer "This will not fit into a single field" with "OK"
	end if
	put theText info field 1 -- or whatever you want to do

This particular script would check to see if it is larger than the limit
of characters for a single field.  You could process the text and
distribute it across several fields if you wanted.  The possibilities
are endless...

Dan Allen
Software Explorer
Apple Computer

Newsgroups: comp.sys.mac.hypercard,aus.mac
Subject: Re: Read file 16K limit problem
Summary: 
Expires: 
References: <455@levels.sait.edu.au>
Sender: 
Followup-To: 
Distribution: 
Organization: Apple Computer Inc, Cupertino, CA
Keywords: 

In article <455@levels.sait.edu.au> mari@levels.sait.edu.au (Renato Iannella CC2-4 X3033) writes:
>Does anyone have any idea on how to read a text document (that is greater
>than 16K in size) into a HyperTalk container ?

It is very simple.  A HyperTalk variable is only limited by RAM.  Try
this:

	put empty into theText -- clear a variable named theText
	repeat
	  read from file "foo" for 16384 -- maximum chars to read
	  if it is empty then exit repeat -- end of file
	  put it after theText -- otherwise append to variable
	end repeat
	if the length of theText > 30000 then 
	  answer "This will not fit into a single field" with "OK"
	end if
	put theText info field 1 -- or whatever you want to do

This particular script would check to see if it is larger than the limit
of characters for a single field.  You could process the text and
distribute it across several fields if you wanted.  The possibilities
are endless...

Dan Allen
Software Explorer
Apple Computer