Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In 5250 programs (LANSA/RPG) or in a Windows programs (Visual LANSA/Visual Basic) the logic would be:

Define #NUMBER with a default value of zero
Change #NUMBER to #NUMBER + 1
Display the incremented #NUMBER value

In stateless programs #NUMBER (and in fact your whole program and all its state) ceases to exist between interactions with the user. Therefore the variable cannot be used to remember it's previous value between interactions with the user.

The change to your programming approach is easy enough. You simply need to do this: 

Define #NUMBER
Restore the current value (i.e. state) of #NUMBER
Change #NUMBER to #NUMBER + 1
Save the new value (i.e. state) of #NUMBER
Display the new #NUMBER value (at which point your program ceases to exist)

LANSA for the Web and the Framework both provide facilities to save and restore state for you (more on that later). Maintaining state is easy, but you need to understand that it is happening and how it impacts your applications.