User:Www2/temp: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
No edit summary
(Replaced content with "{{deleteme}}")
 
Line 1: Line 1:
<syntaxhighlight lang="nasal">
{{deleteme}}
# Checks whether we should create ice
# Icing conditions: freezing fog or low temp and below dp or in advanced wx cloud
 
var spread = temperature - dewpoint;
if ((spread < maxSpread and temperature < 0) or (temperature < 0 and visibility < 1000) or (visibLclWx < 5000 and temperature < 0)) {  
# we use two visibility properties: one is for basic wx and the other is for advanced wx
  setprop("/systems/icing/icingcond", 1);
} else {
  setprop("/systems/icing/icingcond", 0);
}
</syntaxhighlight>
 
== Spaces vs Tabs ==
 
This has divided many developers! I feel the best method is to use tabs at the start of a line and to use spaces within a line. For example:
<syntaxhighlight lang="nasal">
# we use spaces within the line to make it easier to read
if ((spread < maxSpread and temperature < 0) or (temperature < 0 and visibility < 1000) or (visibLclWx < 5000 and temperature < 0)) {  
# we tabs to move the "true" and "false" statement to the second column
  setprop("/systems/icing/icingcond", 1);
} else {
  setprop("/systems/icing/icingcond", 0);
}
</syntaxhighlight>
 
Another example:
 
<syntaxhighlight lang="nasal">
var abc = 1;
var def = getprop("/abc/def/ghi");
# Note that there is a space around the '='!
</syntaxhighlight>
 
Whichever method you choose, '''be consistent throughout your coding'''!
 
== Lining up code ==
This applies to both Nasal and XML. I will use XML in this example.
Use spaces to line up code within a code block; that is:

Latest revision as of 10:18, 6 July 2017