Afiles and Avars commands - 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: Afiles and Avars commands (/thread-4562.html) |
Afiles and Avars commands - Giancarlo - 08-23-2015 04:00 PM Hello, I took my prime on vacation since this year i was busy on other stuff (my job). I think that i loss a lot of things and now I am trying to catch up. The first issue is related to the very useful commands AFiles and AVars. I understood that these commands allow the storage in a folder and then usage of files and variables which are part of an app. Apart from the theory, i don't know where i can start from. What i would need is an example of code showing how these commands are used and works. I think these commands are very important for the development of apps with their own variables and files, icons and so on. Do you have an example of working code to share? I searched in the previous threads but i didn't find a lot of informations. Thanks Giancarlo RE: Afiles and Avars commands - Marcel - 08-23-2015 06:59 PM Hi! I used AVARS in AstroLab4.. Download and edit to see. Marcel RE: Afiles and Avars commands - Giancarlo - 08-23-2015 08:25 PM Hello Marcel, Thank you very much. Unfortunately i cannot open the files since i don't have the laptop with me. As soon as i am back i am going to dig into that code. As a general approach do i have to save an existing app with a different name? Does it suffice to create a new app with its own folder where i can store all the different files like AVars, AFiles and icon.png? Thank you very much Giancarlo RE: Afiles and Avars commands - Marcel - 08-23-2015 08:44 PM Hi! I don't know for AFILES but AVARS is simple to use. In AstroLab4, many DATA are associated with the program. If you open (double click) the Variables in AstroLab4 in the ConnKit, you will see all the variables that I use for the program. When the program is in use, this variables are disponible. Marcel. RE: Afiles and Avars commands - Tim Wessman - 08-23-2015 09:01 PM (08-23-2015 08:25 PM)Giancarlo Wrote: As a general approach do i have to save an existing app with a different name? Does it suffice to create a new app with its own folder where i can store all the different files like AVars, AFiles and icon.png? AFiles and AVars create or access things within the current application. It doesn't matter if that is a copy of the base application, or a base application. AFiles will store things to disk. You cannot directly use those items by name. Nor can they be directly accessed. They do not remain in RAM taking up space when not in use. They must be recalled into RAM before use. (similar to an item saved in a port on the 48/50 series calcs). Example: Code:
AVars on the other had, creates a variable by name that can hold any object in the current application. They always remain in RAM like any other variable. This is like a normal variable accessed by the menu key in the 48/50 series. Code:
Note that the normal name resolution rules still apply. Unless MyVar has already been created, the program parser won't know what to do with it should you send that piece of code to someone. Code:
Wheras: Code:
Recommended uses for AFiles: archiving things - especially if they are large! You don't want your app to take up 5mb of space when not in use do you? Recommended uses for AVars: variables in common use - especially those that will be smaller or used frequently. If your variable starts taking up lots of space, store it to a disk when not in use and clear that memory out to be courteous. A store into AFiles will happen immediately - e.g. on call it writes at that instant to disk. AVars will only be saved to disk when the application in memory is saved. Usually, this will be on the next off. RE: Afiles and Avars commands - Giancarlo - 08-23-2015 09:40 PM Hello Tim, Thank you very much for taking the time to read and write this answer. Now things seems more clear now. I am going to play with these commands and in case i am lost i am going to use (and abuse) the support of the forum. Thanks Giancarlo P.S. thanks Marcel for astro lab4. As soon as i am back i am going to see your code. RE: Afiles and Avars commands - cyrille de brébisson - 08-24-2015 05:19 AM Hello, Files can also be accessed in binary form (AFilesB) which makes them useable for data storage. you can also store pictures (png) in files which can be automaticaly assigned to/from graphics (G0-G9)... AVars was created as an alternative to user app program exported function for people who do not want to program, AND/OR for programmer who need variables that 'stay' between 2 recompilation compilations of a program. Cyrille RE: Afiles and Avars commands - bobkrohn - 08-29-2015 10:26 PM Oh My. I just saw this Thread. I don't see any entry in the Help or any reference in the Toolbox for these commands. When I do the following from Home AFiles("MyFile"):={1,2,3,4,5} //stores to a file named "MyFile" inside the current app folder It works and I can recall the Variable MyFile (apparently a List). But I don't see it in Mem/UserVariables. How can you clear it? And I still don't know where the "App Folders" that everyone is talking about exist at. All I see are Apps. RE: Afiles and Avars commands - Tim Wessman - 08-30-2015 01:43 AM (08-29-2015 10:26 PM)bobkrohn Wrote: But I don't see it in Mem/UserVariables. A file would not be a variable and wouldn't should up. Think of it more like an archival location. However, you are correct that at the moment neither files nor app vars appear in the mem browser. That is something we'd planned to get resolved later in a more cohesive way when the memory screen gets its planned overhaul. AFiles() with no input returns a list of all the files for the app. Quote:How can you clear it? DelAFiles() (or DelAVars() for variables) Quote:And I still don't know where the "App Folders" that everyone is talking about exist at. That is the "folder". Each application is represented internally by a folder that contains several files. If you'd like to see what they are exactly, you can open a folder in either your %APPDATA%/HPPrime directory (where the emulator stores stuff), or else in the MyDocuemnts/HP Connectivity Kit/Calcs/<calc_name> folder. However, you don't really need to understand the underlying structure or details in order to use things. Just know that you can have files associated with an application. Variables can also be associated with the application (but the contents of those variables remain in RAM even when not in active use at the instant). |