Current SPAD.neXt Release: 0.9.12.123

This forum has closed. Please join our Discord Community.

SPAD.neXt online services are no longer available for SPAD.neXt Versions < 0.9.11.5

Custom expression help !

General Discussions
jojo86
Passenger
Posts: 8
Joined: 12 Nov 2018, 19:51
Status: Offline

Custom expression help !

Post by jojo86 » 13 Jan 2019, 01:20

Hello,
I want to calculate a book status with a formulea.
I tried this one but It doesn’t works :
|| is for OR condition is it correct?

Code: Select all

If ([SIMCONNECT:INDICATED ALTITUDE] - 50 =  [SIMCONNECT:AUTOPILOT ALTITUDE LOCK VAR]
|| 
[SIMCONNECT:INDICATED ALTITUDE] + 50.00 =  [SIMCONNECT:AUTOPILOT ALTITUDE LOCK VAR] ,
1, 
0
)


I want to set the result of my expression to 1 if indicated altitude more or less than 50ft equals to autopilot altitude lock var.

After that, I want to use this expression like a variable.

But when I try, I can’t see any variable change... always equal to zero...

Maybe my expression is bad?

Thanx for your help,

User avatar
thedazman
Betatester
Posts: 1808
Joined: 28 Mar 2015, 10:47
Location: United Kingdom
Contact:
Status: Offline

Re: Custom expression help !

Post by thedazman » 13 Jan 2019, 10:42

Without looking at the expression syntax, I can see you are never getting a match with that.

You are looking to see if the altitudes are the same at + and - 50 and they might for a millisecond as they cross over

You need to use greater than and less than, not equals!

&gt;
&lt;

Daz
"theDAZman" aka "theGFXguy"
Image
https://fipgauges.com

User avatar
thedazman
Betatester
Posts: 1808
Joined: 28 Mar 2015, 10:47
Location: United Kingdom
Contact:
Status: Offline

Re: Custom expression help !

Post by thedazman » 13 Jan 2019, 10:51

Without considering syntax your statement should be more like...

if altitude greater than ap lock + 50 or altitude less then ap lock - 50

Your statement is only true if alt = 5050 and ap lock =5000 the moment you altitude goes to 5051 it’s no longer true.

Daz
"theDAZman" aka "theGFXguy"
Image
https://fipgauges.com

jojo86
Passenger
Posts: 8
Joined: 12 Nov 2018, 19:51
Status: Offline

Re: Custom expression help !

Post by jojo86 » 13 Jan 2019, 10:59

thedazman wrote:
13 Jan 2019, 10:51
Without considering syntax your statement should be more like...

if altitude greater than ap lock + 50 or altitude less then ap lock - 50

Your statement is only true if alt = 5050 and ap lock =5000 the moment you altitude goes to 5051 it’s no longer true.

Daz
Yes this is my objectif. This expression is like a trigger. I know that the expression can’t always be set to I. But I want to look on this status and if 0 become 1 I want to change led status.

User avatar
thedazman
Betatester
Posts: 1808
Joined: 28 Mar 2015, 10:47
Location: United Kingdom
Contact:
Status: Offline

Re: Custom expression help !

Post by thedazman » 13 Jan 2019, 11:11

That’s fine you can use the expression as a led trigger and it should work, but not while you are using = instead of less than/greater than.

Daz
"theDAZman" aka "theGFXguy"
Image
https://fipgauges.com

jojo86
Passenger
Posts: 8
Joined: 12 Nov 2018, 19:51
Status: Offline

Re: Custom expression help !

Post by jojo86 » 13 Jan 2019, 11:41

thedazman wrote:
13 Jan 2019, 11:11
That’s fine you can use the expression as a led trigger and it should work, but not while you are using = instead of less than/greater than.

Daz
Ok, can you help me to write this condition ?
I want to change the status when the real altitude is near my autopilot altitude lock +-50feet.

I can try again but if you could help me I could spend a nice sunday :

Code: Select all

If ( [SIMCONNECT:AUTOPILOT ALTITUDE LOCK VAR] - 50 = [SIMCONNECT:INDICATED ALTITUDE] 
|| 
 [SIMCONNECT:AUTOPILOT ALTITUDE LOCK VAR] + 50 = [SIMCONNECT:INDICATED ALTITUDE]  ,
1, 
0
)
I don't know how I can do that with < or >...

User avatar
thedazman
Betatester
Posts: 1808
Joined: 28 Mar 2015, 10:47
Location: United Kingdom
Contact:
Status: Offline

Re: Custom expression help !

Post by thedazman » 13 Jan 2019, 13:44

Unfortunately I don’t know the expression syntax off the top of my head but greater and less then are usually coded as &gt; &lt;

Admin would be better to advise regarding expression syntax I can only advise you are using the operators

Daz
"theDAZman" aka "theGFXguy"
Image
https://fipgauges.com

jojo86
Passenger
Posts: 8
Joined: 12 Nov 2018, 19:51
Status: Offline

Re: Custom expression help !

Post by jojo86 » 14 Jan 2019, 00:29

Hi, how can I use a AND operator ???
I tried this but I'm not sure that's works :

Code: Select all

If ( [SIMCONNECT:INDICATED ALTITUDE]  >=  [SIMCONNECT:AUTOPILOT ALTITUDE LOCK VAR] - 50 
  &&
 [SIMCONNECT:INDICATED ALTITUDE]<= [SIMCONNECT:AUTOPILOT ALTITUDE LOCK VAR] + 50
  , 1, 0)
 

User avatar
Oz Flyer
Betatester
Posts: 741
Joined: 23 Sep 2015, 10:10
Location: YMMB, Melbourne, Australia
Contact:
Status: Offline

Re: Custom expression help !

Post by Oz Flyer » 14 Jan 2019, 08:31

Try this, Just change the field names:

Code: Select all

If ( [LOCAL:OZ_TEST_1] > [LOCAL:OZ_TEST_2] - 51
    &&
   [LOCAL:OZ_TEST_1] < [LOCAL:OZ_TEST_2] + 51
, 1, 0)
If OZ_TEST_2 is set to 2550
Then output is "1" when OZ_TEST_1 is any where from 2500 to 2600.

I am no coder just dumb luck testing hope it work for you.
David
OZ Flyer
Near YMMB
40+ year of Flight Siming.
Sim: subLOGIC/Microsoft Flight Sim's/DTG FSX, Microsoft Flight, DTG Filght School/FSW/Train Sim/TSW, ETS2 & ATS.
Hardware: Logitech, Saitek, Arduino 2560's & Leo's, BBI-32, PAC LED.

User avatar
thedazman
Betatester
Posts: 1808
Joined: 28 Mar 2015, 10:47
Location: United Kingdom
Contact:
Status: Offline

Re: Custom expression help !

Post by thedazman » 14 Jan 2019, 11:55

You can’t use < and > in xml they are reserved for xml tags and as all the programming is stored in xml profiles I’m not sure you can use <> ?

I haven’t done much expression programming with is why I said I can’t advise about expression syntax but would be interested to know if <> works

Daz
"theDAZman" aka "theGFXguy"
Image
https://fipgauges.com

Locked