Setting a local var value - vis and invis (xml)

#1
Good evening gentlemen!

I have offered myself to finish one certain xml gauge, should have been an easy altimeter. But thing has got a little much cofusing to me as I expected it to be.

Therefore I ask you, if you know the way how to change L or G variable, either visible(via click) or invisible(namely automaticaly upon change of another fsim variable - I want to change indicated altitude into hundreds of feet as nearest integer

so for example, 2956 feet should be value of 30 (29.56 nrst is 30) displayed further on gauge as 3000 feet, while 731 would return 7 shown as 700.

Hope you could help a noob! :rolleyes:
 

taguilo

Resource contributor
#2
Hi,

This conversion should work:

((L)(A)Var,feet) 100 / near ie 2956 -> 29.56 -> 30

Is this what you were looking for?

Tom
 
#3
Well, I actally know the code of conversion itself, but the thig is, i dont know HOW to use it. Should I use tag Script? Tag Macro? Where do I define in which variable would that coverted value stored? In parameter? What is its syntax?


Well, for exaple of what am I looking for would be:

For invisible put this right after gauge definition

Code:
<macro var="L:your name here">(A:INDICATED ALTITUDE,feet) 100 / near</macro>
See what I mean?

Thanks for your effort anyway.
 

taguilo

Resource contributor
#4
You can put it directly in a <string> tag, or use a macro if the expression is needed more than once in the code

For example (FS9 schema)

<Text .....>
<String>%((A:INDICATED ALTITUDE,feet) 100 / near)%!d!</String>
</Text>

or

<Macro Name="MyMacro">(A:INDICATED ALTITUDE,feet) 100 / near</Macro>

<Text .....>
<String>%(@MyMacro)%!d!</String>
</Text>

etc.

Tom
 
#6
Back I am again :(

Gauge resists to load, it just doesnt shoe up in FS. Added well to panel.cfg for sure.

Could it be cause by using reference to macro as vaule not string (direct use in calculating value for "case" - I wanted to isolate certain number (ones, tens, hudreds) and write them thorugh case like case of 1 show 1.bmp and so)?

If yes, how could I avoid it other than using syntax for calculating every single time? I dont want the code to be very complicated if I wanted to revise it later.

Thanks
 

taguilo

Resource contributor
#7
It would be of great help if you post an example of the code you are working on, with an explanation in plain english of what you really want to do.

Tom
 
#8
Good idea indeed! I hope I wont let anything important out!

Code:
<Macro Name="Hfeet">(A:INDICATED ALTITUDE,feet) 100 / near</Macro>
This would return the value I need

Code:
<Element>
		<Visible>(A:Circuit general panel on, bool)</Visible>
		<Position X="106" Y="48"/>
		<Select>


		<Value>(@Hfeet) 10 / (@Hfeet) 100 / flr 10 *  - flr ;</Value>
		<Case Value="0"><Image Name="0.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="1"><Image Name="1.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="2"><Image Name="2.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="3"><Image Name="3.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="4"><Image Name="4.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="5"><Image Name="5.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="6"><Image Name="6.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="7"><Image Name="7.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="8"><Image Name="8.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="9"><Image Name="9.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		</Select>
	</Element>
This should check second number in Hfeet value - tens in nubers, thousands of feet, and set BMP of digit according to it.

Picture of real gauge so you have an idea of what I am trying to write

 
Last edited:

taguilo

Resource contributor
#9
You must use @Hfeet instead of (@Hfeet)
And remove the ; so the code would be:

<Value>@Hfeet 10 / @Hfeet 100 / flr 10 * - flr</Value>

Tom
 
#10
It still wont show up. I am lost now :( :( :( :( :(

Code:
<Gauge Name="Mi-24_feetmeter" Version="1.6" Copyright="2006 Peter PRISKIN and 2007 Peter FABIAN">
<Image Name="bg.bmp" ImageSizes="320,186" Luminous="1"/>


<!-- calculations -->

<Macro Name="Hfeet">(A:INDICATED ALTITUDE,feet) 100 / near</Macro>

<!-- Hfeet -->

<!-- Feetometer -->

	<Element>

		<Visible>(A:Circuit general panel on, bool)</Visible>
		<Position X="68" Y="48"/>
		<Select>
                
		<Value>@Hfeet 100 / flr </Value>
		<Case Value="0"><Image Name="0.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="1"><Image Name="1.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="2"><Image Name="2.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="3"><Image Name="3.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="4"><Image Name="4.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="5"><Image Name="5.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="6"><Image Name="6.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="7"><Image Name="7.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="8"><Image Name="8.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="9"><Image Name="9.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		</Select>
	</Element>
	
	
	<Element>
		<Visible>(A:Circuit general panel on, bool)</Visible>
		<Position X="106" Y="48"/>
		<Select>


		<Value>@Hfeet 10 / @Hfeet 100 / flr 10 *  - flr </Value>
		<Case Value="0"><Image Name="0.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="1"><Image Name="1.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="2"><Image Name="2.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="3"><Image Name="3.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="4"><Image Name="4.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="5"><Image Name="5.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="6"><Image Name="6.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="7"><Image Name="7.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="8"><Image Name="8.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="9"><Image Name="9.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		</Select>
	</Element>

	<Element>
		<Visible>(A:Circuit general panel on, bool)</Visible>
		<Position X="144" Y="48"/>
		<Select>


		<Value>@Hfeet @Hfeet 10 / flr 10 *  - flr</Value>
		<Case Value="0"><Image Name="0.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="1"><Image Name="1.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="2"><Image Name="2.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="3"><Image Name="3.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="4"><Image Name="4.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="5"><Image Name="5.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="6"><Image Name="6.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="7"><Image Name="7.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="8"><Image Name="8.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		<Case Value="9"><Image Name="9.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
		</Select>
	</Element>
	
	
	<Element>
		<Visible>(A:Circuit general panel on, bool)</Visible>
		<Position X="182" Y="48"/>
		<Image Name="0.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/></Case>
	</Element>
	
	
	<Element>
		<Visible>(A:Circuit general panel on, bool)</Visible>
		<Position X="220" Y="48"/>
	  <Image Name="0.bmp" Luminous="Yes" Bright="Yes" ImageSizes="36,49"/>
	</Element>
	
	
   <Mouse>
      <Tooltip>%ALTITUDE (feet)</Tooltip>
   </Mouse>



</Gauge>
 

taguilo

Resource contributor
#11
If what you mean is the gauge isn't showing, then there must be a syntax error. To check this, load the xml file into Internet Explorer, and the error(s) will show up there.

Tom
 
Top