PageRenderTime 7ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/tutorial/signal/example1.e

http://github.com/tybor/Liberty
Specman e | 30 lines | 19 code | 5 blank | 6 comment | 0 complexity | 43bb730a3a7b08b203e5366578ed6ca5 MD5 | raw file
 1class EXAMPLE1
 2   -- Signal example1
 3   -- This example shows a signal which carries an integer value.
 4   -- You may imagine that A is a scrollbar and that you need to be
 5   -- informed each time the value (position) changes so that you can
 6   -- correctly redraw it at the new place.
 7
 8create {ANY}
 9   make
10
11feature {}
12   a: A
13
14   make
15      do
16         create a.make
17         a.value_changed.connect(agent foo(?))
18         -- a.value_changed.connect(agent foo); -- syntactically equivalent
19         a.set_val(3)
20         a.set_val(5)
21      end
22
23   foo (i: INTEGER)
24      do
25         io.put_string(once "New value is ")
26         io.put_integer(i)
27         io.put_new_line
28      end
29
30end -- class EXAMPLE1