Use a static variable and change it when frame() returns true.
https://zorro-project.com/manual/en/frame.htm