Jump to content
Sign in to follow this  
spokes2112

Decimal multiplication in XML

Recommended Posts

Guest iagman

Rob,The code was written with the "and, l, t"; however, these were changed by this b/b to the "less than" symbol when I posted. I'm not sure why that happened because I have the Message format box checked.Glenn

Share this post


Link to post
Share on other sites

Hi,I had a look and may be there are some } too much and what does a seperate ; ?Also, using repeat="Yes" can give some problem when choosing between 1 and 10.After editing:(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{ (L:CourseSet, degrees) 1 + (>L:CourseSet, degrees) (L:CourseSet, degrees) 359 > if{ 0 (>L:CourseSet,degrees) } (L:CourseSet, degrees) 0.01745 * (>L:CourseRadian, radian) } els{ (L:CourseSet, degrees) 10 + (>L:CourseSet, degrees) (L:CourseSet, degrees) 359 > if{ 0 (>L:CourseSet,degrees) } (L:CourseSet, degrees) 0.01745 * (>L:CourseRadian, radian) } } (M:Event) 'LeftRelease' scmp ! if{ 0 (>G:Var1) } (L:CourseRadian, radians) (A:Plane heading degrees gyro,radians) - (>L:CourseCursor, radians) (L:CourseCursor, radians)Not tested!, Hope it helps,Jan"Beatus Ille Procul Negotiis"

Share this post


Link to post
Share on other sites
Guest iagman

This code now increases the cursor in steps of one degree per click. When the mouse is held down, it moves continously but only one-degree per step, not 10. That is what was happening originally.Maybe I need four buttons, two that increase/decrease in steps of 10; two that increase/decrease in steps of 1. Maybe simpler is better in this case. Simmers love buttons anyway. I think I can handle the four button code.Glenn

Share this post


Link to post
Share on other sites

Hi Glenn,I suggest you use this code. It works fine:(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{ (L:CourseSet, degrees) ++ dnor (>L:CourseSet, degrees) } els{ (L:CourseSet, degrees) 10 + dnor (>L:CourseSet, degrees) } } (M:Event) 'LeftRelease' scmp ! if{ 0 (>G:Var1) } Things to add:"++" is the same as "1 +" (and -- is otherwise)"dnor" makes the resulting number be converted to degrees directly.This saves the "(L:CourseSet, degrees) 359 > if{ 0 >L:CourseSet,degrees) }" sentence (which is incorrect when incrementing by 10) and makes the code more clear."(L:CourseSet, degrees) 0.01745 * (>L:CourseRadian, radian)"Is not needed at all. Let FS make the conversion for you, which btw will be more precise than the factor you are using. use always "amphersand l t ;" instead of (L:CourseSet, radians) (A:plane heading degrees gyro,radians) - Regards,TomPS: Do you have a mousewheel? If so, have you tried scrolling the wheel over the click zone? I use this method to make ample increments.

Share this post


Link to post
Share on other sites

Hi,This is the working code of a heading-bug in a ND.(Rotation around a compass rose)I used Rob's and Tom's click-code and added something and tested it and it works as expected:I don't use G:Var'sDecrease:(M:Event) 'LeftSingle' scmp ! if{ (L:heading,number) ++ (>L:heading,number) (L:heading,number) 1 == if{ (P:ABSOLUTE TIME,seconds) (>L:heading timer,number) } (P:ABSOLUTE TIME,seconds) (L:heading timer,number) - 1 < if{ (L:CourseSet,degrees) -- dnor (>L:CourseSet,degrees) (L:CourseSet,degrees) (>K:HEADING_BUG_SET) } els{ (L:CourseSet,degrees) 10 - dnor (>L:CourseSet,degrees) (L:CourseSet,degrees) (>K:HEADING_BUG_SET) } } (M:Event) 'LeftRelease' scmp ! if{ 0 (>L:heading,number) } Increase:(M:Event) 'LeftSingle' scmp ! if{ (L:heading,number) ++ (>L:heading,number) (L:heading,number) 1 == if{ (P:ABSOLUTE TIME,seconds) (>L:heading timer,number) } (P:ABSOLUTE TIME,seconds) (L:heading timer,number) - 1 < if{ (L:CourseSet,degrees) ++ dnor (>L:CourseSet,degrees) (L:CourseSet,degrees) (>K:HEADING_BUG_SET) } els{ (L:CourseSet,degrees) 10 + dnor (>L:CourseSet,degrees) (L:CourseSet,degrees) (>K:HEADING_BUG_SET) } } (M:Event) 'LeftRelease' scmp ! if{ 0 (>L:heading,number) } (A:Autopilot heading lock dir,radians) (A:Plane heading degrees gyro,radians) - You can use a bitmap instead of this vector of course.So one click gives one degree rotation and pressing longer gives 10.May be this is what you want.(Same should be possible for alt, vs(very small increments!), obs, speed etc.)Hope it helps,Jan"Beatus Ille Procul Negotiis"

Share this post


Link to post
Share on other sites
Guest airhead

>>PS: Do you have a mousewheel? If so, have you tried scrolling>the wheel over the click zone? I use this method to make ample>increments.>As Tom suggested, don't want to forget about the wheel. You can even take that a step farther by adding wheel up and down event handlers for your click area code. This would allow for more precise conrol of the results when the wheel is used. If you find you're reusing click code for multiple events, you could even stick Jan's goodies in some macros and just call them when you need 'em.Like Tom, I tend to use the mousewheel frequently as well. I guess it just "feels" more like turning a knob on the panel. Granted, there may be those who don't have or use scollers, the standard button click events (as in the examples above) will still be there for them.

Share this post


Link to post
Share on other sites
Guest iagman

Thanks, I'll dig through this code later. I want to use code that I understand and that usually takes a bit of study and head scratching on my part. I can see that vectors will become a priority soon. Is speed their advantage over using bitmaps?Thanks for your help,Glenn

Share this post


Link to post
Share on other sites
Guest iagman

Regarding the use of the ampersand: I do use that for all my code. However, when I copy my code to this b/b, all ampersands structures are changed to the

Share this post


Link to post
Share on other sites
Guest iagman

I just discovered the problem and it was me.Tom's code works as he said. The problem was in the way I was testing the gauge.I had been testing it while FS was in pause. The cursor would moved using the mouse so I assumed everything was normal. But the cursor would only move in the 1-degree steps as I had been posting.I unpause FS to see if gauge worked when aircraft was flying. That is when I discovered the cursor will rotate like it is supposed to, even in 10-degree increments.I don't know why this happens, but I guess calculation are different when paused and not.Thanks everyone for the assistance. Glenn

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...