File: perlcall.e

package info (click to toggle)
entity 1.0.1-8
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 5,604 kB
  • ctags: 5,394
  • sloc: ansic: 64,242; sh: 7,377; makefile: 776; perl: 319
file content (49 lines) | stat: -rw-r--r-- 1,319 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env entity

<object title="Clock">
  <window ondelete="entity:exit" title="Clock" >
    <valign>
      <!-- Insure node lookups are working right by supplying fake
           label in different object -->
      <label name="time" text="fake! boo!"/>
      <object name="clock" dragable="true" 
              __perl-namespace="different" expand="false">
	<label name="time" font="10x20" text = "00:00:00"></label>
        <perl>
	    sub update_clock
	      {
		print "arguments passed to update_clock:";
	        print "@_\n";
		my $timelabel = enode("label.time");
	        print ("timelabel is $timelabel\n");
		
		my ($sec, $min, $hour, $mday) = localtime (time);
	        my $str = sprintf ("%02d:%02d:%02d", $hour, $min, $sec);

		$timelabel->attrib ("text" => $str);
		return "Here is your retval d00d.";
	      }
	    
	    sub foo
	      {
	        print ("foo!\n");
	      }
	      
	</perl>
      </object>
    </valign>
    <timer name="clock" interval="1000" action="call_update_clock"/>
    <perl>
      sub call_update_clock
        {
	  my $node = enode ("object.clock");
	  $foo = "my string foo";
	  $retval = $node->call ("update_clock", "ns", $node, $foo);
	  $node->call ("foo");
	  $node = enode ("label.time");
	  print ("retval -- $retval\n");
	  
	}
    </perl>
  </window>
</object>