Dividing two number when you might not yet have values for both of them requires taking precautions
to avoid dividing by zero, or presenting bad results.
By now, you should have created an output Label in the Designer, whose .Text value is the
eventual destination of your division calculation.
Your numerator and denominator are either in separate Label.Text values or maybe in global variables,
awaiting the moment when our app decides it's okay to do the division and display the result.
You have two possible triggers for the division calculation, either the Location Sensor or the Clock Timer,
depending on which one last received data. To avoid duplicating the same code, then, I recommend
creating a common procedure (call it Calculate_And_Display_LPM, for Liters_per_mile) to hold the dirty work,
and call that procedure from both events.
To signal incomplete data, I recommend you decide on an unlikely value to keep in your numerator and denominator
.Text fields or global variables, say '?'.
The procedure would go like this ...
procedure Calculate_And_Display_LPM
if and(numerator not equal to '?' , denominator not equal to '?') then
if denominator not equal to 0 then
set output-Label.Text to numerator / denominator
else
set output_Label.Text to '?'
else
set output_Label.Text to '?'
end procedure
Location information might not be immediately available when an app starts. You'll have to wait a short time for a location provider to be found and used, or wait for the OnLocationChanged event
so that's where you would put the other procedure call.)
ABG