[Fudgets Home Page]

An Up Counter


This program illustrates a more general way to combine application specific code with GUI elements from the Fudget library. It illustrates that state information can be encapsulated.

[Your browser doesn't support fupplets. Here is a window dump instead:]

[Window dump of the Up Counter]

This program has a button and a numeric display. Pressing the button increments the number in the display.

The application specific code in this example sits between the button and the display. It internally maintains a counter which is incremented and output to the display whenever a click is received from the button.

Here is the source code:

import Fudgets

main = fudlogue (shellF "Up Counter" counterF)

counterF = intDispF >==< mapstateF count 0 >==< buttonF "Up"

count n Click = (n+1,[n+1])

Things to note


  • Next Example
  • Previous Example
  • Back to the Example list