Jump to content

FS9 XML Gauge L:Vars Scope


flyer8

Recommended Posts

I was looking through the documentation for L:Vars and their scope appears to be shared. But so far, I cannot find a clear example of where and when to instantiate an L:Var. What I'm seeing is in the following code snippet, although, the string statement only produces a "0" when I was thinking it should produce a "101".

 

Please advise and thanks for any help you can offer!

 





(101 (>L:Test_01,decimal)) // Is this correct?






%((L:Test_01,decimal))%!d!%





Link to comment
Share on other sites

I think when you assign a value to an L:var it should occur within an element.

 

I use L:vars for two reasons. One is to give them names that explain their functions (such as L:mode, enum instead of G:var1); the other is to allow a value to be used in more than one gauge (such as allowing an initialized variable to work in an autopilot and a nav/com).

 

Search this forum for "Nick Pike" and you'll find some great tutorials.

Link to comment
Share on other sites

This is the line that you are using ,

(L:Test_01,decimal))%!d!%

Where ,

- Test_01 = just a name , it could easily be Fred , Donut or whatever .

- decimal = units , it could be number , feet , degrees , etc

- !d! = will give a readout but not necessarily in decimals ,

to get a readout in decimals the correct format would be as in this example ,

!6.3f! , the .3 means that the readout will be to 3 decimal places .

 

With the L:Variable name , L:Test_01 the computer will look for Test_01 and find nothing unless Test_01 has previously been defined .

To get a better idea give the L: Variable the name Butterfly , L:Butterfly , the Butterfly name will be meaningless to the computer .

 

Below is an example where I have defined Butterfly ,









%((A:RADIO HEIGHT,feet) (>L:Butterfly,feet))%
                                  %((L:Butterfly,feet))%!8.2f!%




-here ,

%((A:RADIO HEIGHT,feet) (>L:Butterfly,feet))%

Butterfly has been defined , it will be the Radio Height .

-here ,

%((L:Butterfly,feet))%!8.2f!%

the readout of Butterfly will now be the Radio Height in feet to two decimal feet .

 

I hope the above is of some value .

 

EDIT ;

for your case try this and see if it works ,





%(101 (>L:Test_01,decimal))%
                                    %((L:Test_01,decimal))%!d!%


 

Cheers

Karol

Link to comment
Share on other sites

COBS, okbob, and Karol, all of the examples are very helpful, so thank you for that.

 

I think I need to refine and refocus this request a bit, and here's my attempt at a better request explanation for the same concept. Most developers have run into VBA from time to time and I'd like to use it as an example because it's fairly easy to read.

 

What I'm looking for is so simple (typically) its kind of dumb, but very a relevant primer. Variable assignments and macros in the namespace.

 

Private Sub AssignValues()

Dim Num01 As Variant
Num01 = 33

       Debug.Print("Num01: " & CStr(Num01))

End Sub

 

In most computer languages, a variable can first be defined so the compiler knows both its type and memory requirements.

 

With our fun RPN and XML DOM, it works a bit differently. The goal (at least for this request) is to discover how to store a value in an L:Var. It would be preferable to see an isolated embedded within the structure, in other words the gauge namespace if you would.

 






(L:Var,units) = 101










		(L:Var,units)








 

An Aside...

Its funny, I've actually programmed an HP-41CX triangle solution which I extracted from my HP-11C back in the early 80's. For the fun of it, I grabbed my old 11C manual and took a photo of it. It was printed in 1981 as that's when I bought it.

 

My HP-11C Solutions Handbook

HP-11C Solutions Handbook.jpg

Link to comment
Share on other sites

flyer 8

 

Not sure that I understand your latest post .

I'm not a computer programmer , I only use xml , I have created complex and advanced instruments for my F-111 panel , so can only advise on some aspects relating to xml use .

 

- VBA is totally meaningless to me , suspect it is not applicable to the Sim .

- suspect that this is not valid for Sim use .

 

1. An L:Variable can be used multiple times within an instrument , that variable will be visible and can be used in other instruments in the panel .

2. A Macro is only visible in the instrument that it is contained in , that Macro cannot be called in other instruments.

If you must use a Macro in several instruments , then a full copy of that Macro must be placed in each instrument that requires it's call .

 

In the previous example that I provided the L:Variable was defined within the string .

 

Below is an example where the L:Variable is defined separately in a "Select" ,




 101 (>L:Test_01,decimal)





 %((L:Test_01,decimal))%!d!%


 

Cheers

Karol

EDIT

as mentioned earlier by okbob the tutorials at the following link are very good to get to grips with xml ,

https://www.google.com.au/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=0ahUKEwjt0pP0n8DNAhVLoJQKHbTSCSgQFggiMAE&url=http%3A%2F%2Fwww.fs2x.com%2FTutorials.htm&usg=AFQjCNEtSpqALKKAFSxXcP-VZUtu58yZlw&sig2=z8gTU4xm35ceaJv8vuHAEQ

 

see specifically thes 4 chapters ,

Tutorial 1:

 

Making FS9/FSX gauges using XML code

 

Section 1: Basic Strategy

 

Chapter 1. Main Body Sections. PDF

 

Chapter 2. Interaction Sections. PDF

 

Chapter 3. Variables. PDF

 

Chapter 4. Radios. PDF

Link to comment
Share on other sites

COBS...That's what I was looking for.

 

I've read through all of the tutorials at fs2x and they were very informative. I do appreciate people who help so very much. The issue is that I have been writing object models for so long, that I have a bunch of useless criteria when it comes to gauge programming. The fs2x tutorials are limited to a non-developer audience and left me with many questions, so I went seeking advice here.

 

In a new programming language, one of the first things that I look for is logical operators, then the ability to write sub-routines, and finally what I was looking for here, which is variable assignments. Specifically, the syntax to assign a value to a variable and the scope (lifetime) of that variable.

 

In traditional programming languages, variables have a scope. That scope might be limited to the container where the variable was named. A variable could also be global (shared) between many containers. Sometimes it doesn't matter where a variable is named as it could be earmarked as a global variable by default. That sounds like the behavior of an L:Var.

 

Since I read that L:Vars are a shared resource through out the simulation, and that their names need to be unique, I was curious as to where they were named and instantiated for the first time, and how to stuff a value into one of them.

 

The reason that I used VBA as an example is that variables (in the sim realm) appear to behave the same as a VBA Variant variable. A VBA Variant data type can hold any number of value types such as a string, a decimal, or even an object reference (pointer).

 

Not trying to show off my programming knowledge here, just trying to find a common ground so I can fudge my way into a relevant gauge terminology, and then be able to speak a bit clearer. That should be quite soon (I hope).

 

So if I haven't said thank you for the help, it really is thank you for the help because without someone to mentor me a little, I'll have to hack my way into a couple of key concepts which is incredibly time consuming and very boring. But be that as it may, I have had some successes and am trying to advance a bit. Been reading through the gps_500.xml and still need to know just a bit more.

 

My current test gauge is the following image, a simple and brief timer and text test. It is comprised of the following information:

 

The first three rows are hours, minutes, and seconds.

%((P:LOCAL TIME,hours))%!02d!%

%((P:LOCAL TIME,seconds) 60 / int 60 % )%!02d!%

%((P:LOCAL TIME,seconds) 60 % )%!02d!%

 

The next two rows use...

%('Amsterdam' 2 4 ssub)%!s!%

%('Amsterdam' 1 symb)%!s!%

 

Timer.png

Link to comment
Share on other sites

COBS...very cool, thank you!

 

Please note the slight differences in this version. Also, the reference to "decimal", I can't seem to find it in the Panel SDK files so I used "number" instead. Where does it exist, and knowing there are so many different references that reveal one tiny little, albeit, really important piece of information.

 

Anyway, this works and I'm certain that I've tried one very close connotation of the following code before, but it didn't work that time as I may have had too many "%" (evaluation) symbols. If this is in error do let me know.

 

Anyway, COBS brings the sunny day with him!

 







 101 (>L:Test_01,number) 






%((L:Test_01,number))%!03d!




 

The next test will be checking if I can reuse the L:Var in another gauge, and then with/in a Macro.

 

Gauge Notes:

 

The first three rows are hours, minutes, and seconds.

%((P:LOCAL TIME,hours))%!02d!

%((P:LOCAL TIME,seconds) 60 / int 60 % )%!02d!

%((P:LOCAL TIME,seconds) 60 % )%!02d!

 

The next two rows use...

%('Amsterdam' 2 4 ssub)%!s!

%('Amsterdam' 1 symb)%!s!

 

The Final Row is simply a number, saved in a L:Var, and then recalled

%((L:Test_01,number))%!03d!

 

Timer.png

Link to comment
Share on other sites

flyer 8

 

Regards the decimals as a unit , you do not need it , number will do ,

By way of explanation I will use Radio Height and feet as it can be used in any aircraft ,

 

This is the variable from the SDK,

(A:RADIO HEIGHT,feet)

For this example the aircraft might be at 15,782.27'

 

If you want the readout in whole numbers ( 15782 ) , the string would be ,

%((A:RADIO HEIGHT,feet))%!5d!%

 

If you want the readout in feet and decimals to 2 decimal places ( 15782.27 ) , the string would be ,

%((A:RADIO HEIGHT,feet))%!8.2f!%

 

notice " !5d! " and " !8.2f! " ( d vs f ) , the " .2 " sets the 2 decimal places ,

if you wanted it to 4 decimal places use " !10.4f! " .

 

Regards a unique L:Variable , it's existance begins when you first use it , usually that would be when you first define it.

 

An example that I use in one of my instruments is :-

I want to capture and store the aircraft's current location , then use that in various ways ,

1.

(A:PLANE LATITUDE, degrees) (>L:MarkPositionLatitude,degrees)
(A:PLANE LONGITUDE, degrees) (>L:MarkPositionLongitude,degrees)

This captures the aircraft's current instantaneous Lat/Long and stores it in unique L:Vars (Mark Position) ,

That particular unique L:Var forms the basis of a display.

2. Then I want to Store that unique L:Var to Memory #1 ,

(L:MarkPositionLatitude,degrees) (>L:MemOneLatitude,degrees)
(L:MarkPositionLongitude,degrees) (>L:MemOneLongitude,degrees)

A Right click has stored the display to memory #1 .

3. Then I capture a different location it becomes the subject of the display ,

I then store the new location to memory #2 ,

(L:MarkPositionLatitude,degrees) (>L:MemTwoLatitude,degrees)
(L:MarkPositionLongitude,degrees) (>L:MemTwoLongitude,degrees)

A Right click has stored the later display to memory #2 .

4. I now have two different locations stored to 2 memories .

5. By a Left click on either of the memory buttons I can recall a location to the display .

6. Memory #1 ,

(L:MemOneLatitude,degrees) (>L:MarkPositionLatitude,degrees) 
(L:MemOneLongitude,degrees) (>L:MarkPositionLongitude,degrees)

7. Memory #2 ,

(L:MemTwoLatitude,degrees) (>L:MarkPositionLatitude,degrees) 
(L:MemTwoLongitude,degrees) (>L:MarkPositionLongitude,degrees)

8. So you can see in this example that I have taken an L:Var that is in the SDK's and

shuffled that into unique L:Vars to generate a display and 2 memories that can at any time be recalled to represent the basis of the display .

 

These unique L:Vars that you create and name and define have an endless variety of uses .

 

Cheers

Karol

 

EDIT

Shot shows Flow of above L:Vars ,

 

MP9.jpg

Shot shows Display , it is Page 4 at right of shot ,

fsx 2015-05-31 00-41-41-85.jpg

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...