Query data -> loop over the array, conditionals to calculate some results and return to the screen

Maybe you can move the first Set Value hours = 0 outside of the Condition to make sure such variable is always present

Do you need help with anything else? I haven't read the whole topic

Array manipulation (editing) is something not quite implemented, so people have used workarounds, you can find more information in this topic: