Jump to content
Sign in to follow this  
spokes2112

Decimal multiplication in XML

Recommended Posts

Guest iagman

In the following code, each click on a gauge button increases the CourseSet variable by one. It will count up to 359, then reset to zero on the next click. These values are degrees on the compass. On the last line, I want to convert the degree value into radian for further calculations. When the degrees are multiplied by .01745, a zero value always results. If the code below is incorrect, how do you multiply decimal values in XML?(L:CourseSet, degrees) 1 + (>L:CourseSet, degrees) ;(L:CourseSet, degrees) 359 > if{ 0 (>L:CourseSet, degrees) } ;(L:CourseSet, degrees) .01745 * (>L:CourseRadian, radian)I've also substituted this code on the last line above to see if XML would do the conversion for me, but no luck.(L:CourseSet, degrees) (>L:CourseRadian, radian)Thanks,Glenn

Share this post


Link to post
Share on other sites

Hi Glenn,I've never been able to figure out which conversions work for L:Vars and which don't.So I'll always use "number" and "bool" for my variables.And this:(L:CourseSet,number) 0.01745 * (>L:CourseRadian,number)will definitely work.It could also be the missing 0 before the decimal point.Rob

Share this post


Link to post
Share on other sites

Hi,May be this works:(L:CourseSet,degrees) dgrd (>L:CourseRadian,radian)or use number:(L:CourseSet,number) dgrd (>L:CourseRadian,number)Hope it helps,Jan"Beatus Ille Procul Negotiis"

Share this post


Link to post
Share on other sites

Hi,>>>(L:CourseSet, degrees) (>L:CourseRadian, radian)This won't work.Rather is a direct conversion, just change the unit:(L:CourseSet, radians)Tom

Share this post


Link to post
Share on other sites

This works:180 (>L:CourseSet, degrees)(L:CourseSet, radians) will equal 3.14 'ish'pi (>L:CourseSet, radians)(L:CourseSet, degrees) dnor will equal 180This will also work,180 (>L:CourseSet, enum)(L:CourseSet, enum) dgrd = 3.14pi (>L:CourseSet, enum)(L:CourseSet, enum) rddg = 180--Jon

Share this post


Link to post
Share on other sites
Guest iagman

Thanks, good answers. I went with adding a zero in front of the decimal. Apparently, XML does not recognize decimals unless they are surrounded by digits. I

Share this post


Link to post
Share on other sites

Hi,Do you use or ?Jan"Beatus Ille Procul Negotiis"

Share this post


Link to post
Share on other sites

Hi Glen,You could use this construction: (M:Event) 'LeftSingle' scmp ! if{ (G:Var1) ++ (>G:Var1) (G:Var1) 1 == if{ (P:ABSOLUTE TIME,seconds) (>G:Var2) } (P:ABSOLUTE TIME,seconds) (G:Var2) - 1 < if{ "code that increments your var by 1" } els{ "code that increments your var by 10" } } (M:Event) 'LeftRelease' scmp ! if{ 0 (>G:Var1) }So:Normally Var1 is 0.When the mouse is depressed and held, the 'LeftSingle' section is continuously executed.The first "click" (Var1 = 1) sets Var2 to current time.Keeping it depressed will continuously increment Var1, so Var2 is set only once ("start-time").So the first second the "incr by 1" code is executed.When the "current-time - start-time > 1 sec", the "incr by 10" code is executed.Releasing the mouse sets Var1 back to zero, to initialise it for a next "click-and-hold" event.This construction is never affected by "acceleration" problem you see in many gauges, and makes it very easy to use another "hold-time" than 1 sec. Just replace the "1" by another period.Cheers, Rob Barendregt

Share this post


Link to post
Share on other sites
Guest iagman

That solution looks good. I'll give it a try tomorrow. Thanks,Glenn

Share this post


Link to post
Share on other sites
Guest iagman

I tried the code. It works in this fashion: When I single-click the mouse, the cursor rotates in 10-degrees increments. When I keep the mouse button down, the cursor then rotates continously in 1-degree increments. But, upon releasing the button, the cursor jumps 10-degrees one final time before stopping.I think I

Share this post


Link to post
Share on other sites

Hi Glenn,I'd appreciate if you could show me where my example is wrong :-)Because I can't explain the behaviour you describe ..Rob

Share this post


Link to post
Share on other sites

Hi Rob,I took a glance to your code, just by curiosity :-)At first thought it has something to do with (P:Absolute time) being negative, but then realized it's ok...so I second your post.Regards,Tom

Share this post


Link to post
Share on other sites
Guest iagman

If you guys see nothing wrong, then I may have followed your instructions incorrectly although it looks okay to me. I can

Share this post


Link to post
Share on other sites

Hi Glenn,Try to replace:(P:ABSOLUTE TIME,seconds) (G:Var2) - 1 " as ">") in an XML expression.Rob

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...