Post Reply 
Afiles and Avars commands
08-23-2015, 04:00 PM
Post: #1
Afiles and Avars commands
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
Find all posts by this user
Quote this message in a reply
08-23-2015, 06:59 PM
Post: #2
RE: Afiles and Avars commands
Hi!
I used AVARS in AstroLab4.. Download and edit to see.
Marcel
Find all posts by this user
Quote this message in a reply
08-23-2015, 08:25 PM
Post: #3
RE: Afiles and Avars commands
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
Find all posts by this user
Quote this message in a reply
08-23-2015, 08:44 PM
Post: #4
RE: Afiles and Avars commands
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.
Find all posts by this user
Quote this message in a reply
08-23-2015, 09:01 PM (This post was last modified: 08-23-2015 09:06 PM by Tim Wessman.)
Post: #5
RE: Afiles and Avars commands
(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:

AFiles("MyFile"):={1,2,3,4,5}  //stores to a file named "MyFile" inside the current app folder
L1:="MyFile" //would store into L1 the string "MyName" - not recall your file
L1:=AFiles("MyFile") //recalls content of file, and then store it into L1

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:

AVars("MyVar"):={1,2,3,4,5}  //creates a variable named "MyFile" inside the current app
L1:=MyVar; //would store into L1

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:

MyVar; //I've declared this to be a variable

EXPORT Function()
BEGIN
  AVars("MyVar"):={1,2,3,4,5}  //creates a variable named "MyFile" inside the current app
  L1:=MyVar; //will always work
END;

Wheras:

Code:

EXPORT Function()
BEGIN
  AVars("MyVar"):={1,2,3,4,5}  //creates a variable named "MyFile" inside the current app
  L1:=MyVar; //will only work if you have *already* created this before, else on compile will error here
END;

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. Smile


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.

TW

Although I work for the HP calculator group, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
08-23-2015, 09:40 PM
Post: #6
RE: Afiles and Avars commands
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.
Find all posts by this user
Quote this message in a reply
08-24-2015, 05:19 AM
Post: #7
RE: Afiles and Avars commands
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
Find all posts by this user
Quote this message in a reply
08-29-2015, 10:26 PM
Post: #8
RE: Afiles and Avars commands
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.
Find all posts by this user
Quote this message in a reply
08-30-2015, 01:43 AM (This post was last modified: 08-30-2015 01:45 AM by Tim Wessman.)
Post: #9
RE: Afiles and Avars commands
(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.
All I see are Apps.

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).

TW

Although I work for the HP calculator group, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
Post Reply 




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