HP Forums
Check if an app is active, use AVar() - 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: Check if an app is active, use AVar() (/thread-4379.html)



Check if an app is active, use AVar() - salvomic - 07-18-2015 01:06 PM

hi,
in Effemeridi (my program for Astronomy) I would get some controls about Astro Lab 4 (the app for Astronomy by Marcel) and use some of its variables (with the kind permission of Marcel).

Is it possible to get some of these things?

1. check if Astro Lab 4 is installed and it's the active app
2. call some functions by it (something like Astro_Lab_4.ListNow ...)
3. use its Avars *also* if it's not active app

The purpose is to share Avars with the app without duplicate them, also if Astro Lab is not the active app.

Thank you for advice and hints.

Salvo

for example:
Code:

IF // Astro Lab 4 is installed;
THEN
l:= Astro_Lab_4.PlanetCoordinates({"VEN", lista});
ELSE
  l:= atan2(y,x);
END;

or

Code:

// check for Astro Lab 4 and Avar("earb0")
bvar:= AVar("earb0");
// ...



RE: Check if an app is active, use AVar() - Marcel - 07-18-2015 04:23 PM

Hi Salvomic!

I know that ti-Nspire can do this because we can declare a library to be public or not and use it where and when we want from any document!
This is what I do with Astro Lab 2.
On Prime you can do
Astro_Lab_4.AVars("name"):=varName
and it will work. This is a sort of "public Library"...
Marcel


RE: Check if an app is active, use AVar() - Marcel - 07-18-2015 04:34 PM

Oups...
In fact this is OK with DATA but with function I have to try it, because one fonction call other and so on...
Marcel


RE: Check if an app is active, use AVar() - salvomic - 07-18-2015 04:44 PM

(07-18-2015 04:23 PM)Marcel Wrote:  Hi Salvomic!
I know that ti-Nspire can do this because we can declare a library to be public or not and use it where and when we want from any document!
This is what I do with Astro Lab 2.
On Prime you can do
Astro_Lab_4.AVars("name"):=varName
and it will work. This is a sort of "public Library"...
Marcel

(07-18-2015 04:34 PM)Marcel Wrote:  Oups...
In fact this is OK with DATA but with function I have to try it, because one fonction call other and so on...
Marcel

hi Marcel, thank you, however is a good input...
I tried this, just now:
Code:

  // Use Astro Lab 4 if installed
  IF (nameplanet<>"Pluto") THEN
    temp:= breviplanet(nameplanet);
    temp2:= EVAL(Astro_Lab_4.PlanetCoordinates({EVAL(temp),lista}));
    lapp:= temp2(1);
    b:= temp2(2);
    R:= temp2(3);
  END;
  // end use Astro Lab 4
breviplanet(); just abbreviate the name of planet like "VEN", "JUP" and so on...
It works if Astro Lab 4 is active, and in Effemeridi give for planets (not Pluto for now) the same results as Astro Lab (taken by there!)
But if Astro Lab 4 is not active I get error: "unmatch control word".

So I need:
1. control if Astro Lab 4 is active
or
2. correct syntax to work even if it isn't active.

Then I'll study how use Avars from your app (it could be nice to extract some part to elaborate other calculations not already included in the app)...


RE: Check if an app is active, use AVar() - Marcel - 07-18-2015 04:55 PM

Hi!
The DATA is the easy part but how to know if a apps is active or not?
I don't know.
I will try...
Marcel


RE: Check if an app is active, use AVar() - salvomic - 07-18-2015 05:52 PM

[quote='salvomic' pid='39335' dateline='1437237850']
...and use this line
Code:

    temp2:= EVAL(Astro_Lab_4.PlanetCoordinates({EVAL(temp),lista}));

is insecure!
if the program doesn't exist the program won't compile and gives a syntax error
i.e.
Code:

    temp2:= EVAL(Astro_Lab_4xxxxx.PlanetCoordinates({EVAL(temp),lista}));
as Astro_Lab_4xxxxx doesn't exist...


RE: Check if an app is active, use AVar() - StephenG1CMZ - 07-18-2015 08:59 PM

Could you use IFERR?
Something like:

Iferr astro... then
// not there or other err
Else
Astro... // all ok
Endif


RE: Check if an app is active, use AVar() - salvomic - 07-18-2015 10:09 PM

(07-18-2015 08:59 PM)StephenG1CMZ Wrote:  Could you use IFERR?

yes Stephen,
using IFERR, this seems to work (but...)
Code:

    IFERR EXPR("Astro_Lab_4()") THEN temp:=0; // change nothing 
    ELSE
        temp:= breviplanet(nameplanet);
        temp2:= EVAL(Astro_Lab_4.PlanetCoordinates({EVAL(temp),lista}));
        lapp:= temp2(1);
        b:= temp2(2);
        R:= temp2(3);
    END;

It executes the 5 lines if Atro Lab is active, and changing the IFERR line like
IFERR EXPR("Astro_Lab_4xxxxxx()") THEN temp:=0; // change nothing
it executes ...nothing, as expected.

But if Astro Lab 4 is not active I got always the "unmatch control word" error: I don't understand from where it comes...

However now with IFERR we can control if the syntax is ok, but not still *if* the app there is or it's active.

Salvo


RE: Check if an app is active, use AVar() - Tyann - 07-19-2015 06:58 AM

hello
Each application has its Avars list.
Add an Active Variable : = "name" or number.
In Astro: Avars "Active" : = " Astrolab "
in Function
Avars "Active" : = "Function"
Etc ...

If Avars "Active" not exist, write

Code:

Local vctrl
IFERR vctrl:=Avars("Active") THEN
 vctrl:=""
END;
Sorry for my English.


RE: Check if an app is active, use AVar() - salvomic - 07-19-2015 03:28 PM

(07-19-2015 06:58 AM)Tyann Wrote:  hello
Each application has its Avars list.
Add an Active Variable : = "name" or number.
In Astro: Avars "Active" : = " Astrolab "
in Function
Avars "Active" : = "Function"
Etc ...

If Avars "Active" not exist, write

Code:

Local vctrl
IFERR vctrl:=Avars("Active") THEN
 vctrl:=""
END;
Sorry for my English.


I'm trying, thank you.
The problem seems still the "unmatch control word" error when Astro Lab is not active, executing its function in the program: also the ELSE path of IFERR gives error and I don't know how to avoid it...

Salvo


RE: Check if an app is active, use AVar() - salvomic - 07-19-2015 04:56 PM

found!
thank also to Tyan input.

The "unmatch control word" was generated by an error of mine: it was recalled a function of Astro Lab 4 with a similar name, not mine! corrected a "J" in "j" it works also when Astro Lab is not installed with a code like this one:

Code:

  // Use Astro Lab 4 if installed (greatest precision)
    IFERR control:= AVars("lieu") THEN
        temp:=0; // do nothing
    ELSE 
        temp:= breviplanet(nameplanet);
        temp2:= EVAL(Astro_Lab_4.PlanetCoordinates({EVAL(temp),lista}));
        lapp:= temp2(1);
        b:= temp2(2);
        R:= temp2(3);
    END;
  // end use Astro Lab 4

AVars "lieu" is in Astro Lab 4, we control if it exists, and if not nothing will be changed, otherwise it's used the function PlanetCoordinates() in Astro Lab 4 and the result will be treated into Effemeridi, in some parts: very interesting!


I advice to install and use Astro Lab 4, to have a better experience with Effemeridi also.

Salvo