List Length Maximum - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: List Length Maximum (/thread-8862.html) |
List Length Maximum - Jacob Wall - 08-19-2017 11:16 PM 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"); 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.) RE: List Length Maximum - StephenG1CMZ - 08-20-2017 03:58 PM I don't know about AFilesB, but simple lists are limited to 10000 elements. RE: List Length Maximum - Jacob Wall - 08-20-2017 06:40 PM 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. RE: List Length Maximum - wangchong01 - 08-21-2017 12:19 AM 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 . 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 empty .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.". RE: List Length Maximum - pier4r - 08-21-2017 06:02 AM (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 . 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 empty .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! |