I tried that, but if you just call the function with: -
weather(weatherstate)
It does not update the value of weatherstate from the main loop i.e. the
NEW value is only held during the execution of the function and not returned to the main routine.
The way to get the return value passed back from the weather function is to set a value equal to it, like: -
weatherstate=weather(weatherstate)
I think you are mixing up parameters and return values. The Parameter part weather(
weatherstate) is used to pass data to the function only. This is so that you can pass variables of your main program into a function that may affect the processing within it.
In this case you do not even need the parameter of
weatherstate because you reset it every time at the start of the function. You would only need it if you set the value in your main program and need to pass it to the
weather function.
The return_value is data you may wish to return to the main body of the program, this is correct as you wish to return the new value of weatherstate, however you still need to set a variable to the value so you know what was returned from the function.
Does this make sense?
Trev C