Post Reply 
Check if an app is active, use AVar()
07-18-2015, 01:06 PM (This post was last modified: 07-18-2015 04:04 PM by salvomic.)
Post: #1
Check if an app is active, use AVar()
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");
// ...

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
07-18-2015, 04:23 PM
Post: #2
RE: Check if an app is active, use AVar()
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
Find all posts by this user
Quote this message in a reply
07-18-2015, 04:34 PM
Post: #3
RE: Check if an app is active, use AVar()
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
Find all posts by this user
Quote this message in a reply
07-18-2015, 04:44 PM (This post was last modified: 07-18-2015 04:44 PM by salvomic.)
Post: #4
RE: Check if an app is active, use AVar()
(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)...

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
07-18-2015, 04:55 PM
Post: #5
RE: Check if an app is active, use AVar()
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
Find all posts by this user
Quote this message in a reply
07-18-2015, 05:52 PM
Post: #6
RE: Check if an app is active, use AVar()
[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...

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
07-18-2015, 08:59 PM (This post was last modified: 07-18-2015 10:58 PM by StephenG1CMZ.)
Post: #7
RE: Check if an app is active, use AVar()
Could you use IFERR?
Something like:

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

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
07-18-2015, 10:09 PM
Post: #8
RE: Check if an app is active, use AVar()
(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

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
07-19-2015, 06:58 AM
Post: #9
RE: Check if an app is active, use AVar()
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.
Find all posts by this user
Quote this message in a reply
07-19-2015, 03:28 PM
Post: #10
RE: Check if an app is active, use AVar()
(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

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
07-19-2015, 04:56 PM
Post: #11
RE: Check if an app is active, use AVar()
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

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




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