Post Reply 
List Length Maximum
08-19-2017, 11:16 PM
Post: #1
List Length Maximum
I was working on a tool to read text files when I encountered an issue with files larger than 10000 Bytes. Basically I was doing this:

Code:
fsize:=AFilesB("name.txt");
fcontent:=AFilesB("name.txt",0,fsize); // fails if fsize>10000
fcontent:=CHAR(fcontent);

This was the only way I found so far to read text files in, and it worked well until I tested a file larger than 10000 Bytes. After some more investigation and troubleshooting it appears to be caused by a limitation of how long list objects can be. Can someone confirm that?

I have a workaround, reading the file in 9999 Byte chunks and assembling the components of the string afterwards, but was surprised to find this limitation. (AFilesB returns a list of character codes for the string.)
Visit this user's website Find all posts by this user
Quote this message in a reply
08-20-2017, 03:58 PM (This post was last modified: 08-20-2017 03:59 PM by StephenG1CMZ.)
Post: #2
RE: List Length Maximum
I don't know about AFilesB, but simple lists are limited to 10000 elements.

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
08-20-2017, 06:40 PM
Post: #3
RE: List Length Maximum
The result from AFilesB is a "simple" list, and yes it is easy to see this limitation if you try to build a list longer than 10000. I suppose the limit was implemented because lists can hold many object types and memory concerns could be introduced. For reading and writing text, these lists are just reals and the net effect is that by default with AFilesB it is not possible to read file blocks longer than 10000 Bytes. The workaround previously mentioned works fine, but because this wasn't working as expected I was wondering if I was maybe not using the correct method.

AFiles returns something unexpected when calling a text file, I suppose it is because the file is not a "HP Prime object", or whatever the correct term is.

It's fast enough to iterate over a file, reading 10000 Bytes at a time, and likewise also to build a file 10000 Bytes at a time, so really no major issue just a learning experience.
Visit this user's website Find all posts by this user
Quote this message in a reply
08-21-2017, 12:19 AM
Post: #4
RE: List Length Maximum
I uploaded some files larger than 500Kb (in fact they are novels) to my reader app, and the calculator started up with a white screen and automatically cleared my memory Sad. However, when I stored my files to the program, the calculator will get stuck in the memory manager for a few seconds. If I restart the calculator with On+Symb, one of my files will be emptySad .I hope the calculator will have a better support of the large files. Though the storage of the calculator is about 190MB, a files can not be larger than 4MB or the calculator will be quite slow. Moreover, a string larger than 64KB can not be created in Home view except the Notes, Programs and AFiles function, I must use a:=CAS(a+a) a few times to create a large string, or I will get "Error: Insufficient Memory.".
Find all posts by this user
Quote this message in a reply
08-21-2017, 06:02 AM
Post: #5
RE: List Length Maximum
(08-21-2017 12:19 AM)wangchong01 Wrote:  I uploaded some files larger than 500Kb (in fact they are novels) to my reader app, and the calculator started up with a white screen and automatically cleared my memory Sad. However, when I stored my files to the program, the calculator will get stuck in the memory manager for a few seconds. If I restart the calculator with On+Symb, one of my files will be emptySad .I hope the calculator will have a better support of the large files. Though the storage of the calculator is about 190MB, a files can not be larger than 4MB or the calculator will be quite slow. Moreover, a string larger than 64KB can not be created in Home view except the Notes, Programs and AFiles function, I must use a:=CAS(a+a) a few times to create a large string, or I will get "Error: Insufficient Memory.".

This is good to know, thanks for sharing!

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)