home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_show / cecil / example5 / example.e < prev    next >
Encoding:
Text File  |  1999-06-05  |  796 b   |  39 lines

  1. class EXAMPLE
  2.    --
  3.    -- The Eiffel program is running first, then call the C program
  4.    -- which is in charge to add two INTEGERs using the infix "+"
  5.    -- feature of class INTEGER.
  6.    --
  7.    -- To compile this example, use command :
  8.    --
  9.    --         compile -cecil cecil.se example c_prog.c
  10.    --
  11.  
  12. creation make
  13.  
  14. feature
  15.  
  16.    make is
  17.       local
  18.          i1, i2, sum: INTEGER;
  19.       do
  20.          i1 := 2;
  21.          i2 := 3;
  22.          io.put_integer(i1);
  23.          io.put_string(" + ");
  24.          io.put_integer(i2);
  25.          io.put_string(" = ");
  26.          sum := call_c_prog(i1,i2);
  27.          io.put_integer(sum);
  28.          io.put_string("%N");
  29.       end;
  30.  
  31. feature {NONE}
  32.  
  33.    call_c_prog(i1, i2: INTEGER): INTEGER is
  34.       external "C_WithoutCurrent"
  35.       alias "c_prog"
  36.       end;
  37.  
  38. end -- EXAMPLE
  39.