PROGRAM keypad; // These are the local variables of the program block VAR k : INT; //Key pressed on the front-panel keypad x : INT; //Some number END_VAR; // The next code will only be executed once after the program starts x := 0; displayClear(); BEGIN // Code from this point until END will be executed repeatedly k := displayGetKey(timeout:=1); if k = 120 then x := x+1; elsif k = 121 then x := x-1; elsif k = 125 then x := 0; end_if; displayXY(x:=1, y:=1); displayNumber(number := x); END; END_PROGRAM;
The variable is displayed on the front-panel LCD using displayNumber() function, that is much easier to use when displaying only numbers, compared to displayString(message:=intToStr()) function combination. On the other hand when using the displayNumber one can not easily format the output with some markings, so I suggest sticking to the casting method (eg. casting the integer to string and adding some text markings). The output is similar, the displayNumber() example code takes 2658 bytes and displayString(message:=intToStr()) takes 2712 bytes. Additional 54 bytes are occupied by the casting I guess, but this shouldn't be a big problem, when one realizes that the total memory for the configuration is up to 640 KB.
The next big thing - filesystem on the internal memory and on SD-card.