User:Www2/temp
Jump to navigation
Jump to search
# 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);
}
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:
# 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);
}
Another example:
var abc = 1;
var def = getprop("/abc/def/ghi");
# Note that there is a space around the '='!
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: