HP Forums
is there any way to get list of files in application? - 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: is there any way to get list of files in application? (/thread-21362.html)



is there any way to get list of files in application? - dmh - 02-26-2024 01:20 PM

I have a Python program where I want the user to be able to pick a file from the Python application files but I can't see any way of getting the list of files either natively on the Prime or via Python.

Am I missing something or is this currently not possible?

I can open files that I've added to Python without a problem but I want a list of them so I can display and let the user choose one (no os.listdir() etc).

Thanks


RE: is there any way to get list of files in application? - komame - 02-26-2024 01:26 PM

(02-26-2024 01:20 PM)dmh Wrote:  I have a Python program where I want the user to be able to pick a file from the Python application files but I can't see any way of getting the list of files either natively on the Prime or via Python.

Am I missing something or is this currently not possible?

I can open files that I've added to Python without a problem but I want a list of them so I can display and let the user choose one (no os.listdir() etc).

Try this:
Code:
from hpprime import eval as ppleval
files = ppleval('AFiles')

The list with file names will be stored in the variable "files".


RE: is there any way to get list of files in application? - dmh - 02-27-2024 12:59 AM

Perfect - thank you!!!

I actually found some samples using AFiles but they were all reading and writing files and I didn't see this exact example.


(02-26-2024 01:26 PM)komame Wrote:  
(02-26-2024 01:20 PM)dmh Wrote:  I have a Python program where I want the user to be able to pick a file from the Python application files but I can't see any way of getting the list of files either natively on the Prime or via Python.

Am I missing something or is this currently not possible?

I can open files that I've added to Python without a problem but I want a list of them so I can display and let the user choose one (no os.listdir() etc).

Try this:
Code:
from hpprime import eval as ppleval
files = ppleval('AFiles')

The list with file names will be stored in the variable "files".