NCalc expression wi...
 
Notifications
Clear all

NCalc expression with more than one line possible?

3 Posts
3 Users
0 Reactions
4,947 Views
(@rvirzi)
New Member
Joined: 3 years ago
Posts: 3
Topic starter  

I've written the following code:

if( [DeltaToSessionBest] > 0, 1, if( [DeltaToSessionBest] < 0, 2, 0 ) )

 

This code works, but I always have to go into the game to test that my code is doing it right.

To test the code without switching all the time to the game, I've tried the following code:

deltatemp = [DeltaToSessionBest]
if( [deltatemp] > 0, 1, if( [deltatemp] < 0, 2, 0 ) )

I get the error "Expression error:missing EOF at 'if' at line 2:0"

 

Why do I want to do this? I change the code to:

deltatemp = 10
if( [deltatemp] > 0, 1, if( [deltatemp] < 0, 2, 0 ) )

Now I can run the dashboard within Dash Studio and see the result if the value is 10. Or I can test negative values:

deltatemp = -10
if( [deltatemp] > 0, 1, if( [deltatemp] < 0, 2, 0 ) )

But I can't get rid of the error "missing EOF". What ist the delimiter in NCalc for the next line?

And how can I use variables inside my NCalc code? Is "deltatemp = 10" the correct way?

 

I've searched inside this forum and also the internet. But I haven't found any example for NCalc code with more than one line.

This topic was modified 3 years ago by rvirzi

   
Quote
(@romainrob)
Honorable Member
Joined: 5 years ago
Posts: 530
 

Hi,
You can't have multiple lines in an NCalc formula.

What you could do is use a custom property as variable for testing purpose:
https://github.com/SHWotever/SimHub/wiki/NCalc-scripting---Introduction

You can change its value on the fly as it will update when saving the ini file.

Also as mentioned in the link above, using data replays instead of live game data while working is very handy.


   
ReplyQuote
(@rex-julian)
New Member
Joined: 2 years ago
Posts: 2
 

"You can change its value on the fly as it will update when saving the ini file." 

This is exactly what I need! How can I change a property value on the fly? 

Thanks!!


   
ReplyQuote
Share: