October 11, 200520 yr 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
October 11, 200520 yr 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
October 11, 200520 yr 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" Jan "Beatus ille qui procul negotiis..."
October 11, 200520 yr Hi,>>>(L:CourseSet, degrees) (>L:CourseRadian, radian)This won't work.Rather is a direct conversion, just change the unit:(L:CourseSet, radians)Tom
October 12, 200520 yr Commercial Member 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 Jon Blum Vertical Reality Simulations
October 12, 200520 yr 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
October 12, 200520 yr Hi,Do you use or ?Jan"Beatus Ille Procul Negotiis" Jan "Beatus ille qui procul negotiis..."
October 12, 200520 yr 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
October 14, 200520 yr 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
October 15, 200520 yr 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
October 15, 200520 yr 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
October 15, 200520 yr If you guys see nothing wrong, then I may have followed your instructions incorrectly although it looks okay to me. I can
October 15, 200520 yr Hi Glenn,Try to replace:(P:ABSOLUTE TIME,seconds) (G:Var2) - 1 " as ">") in an XML expression.Rob
Create an account or sign in to comment