home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / c / xw2.000 / xw2 / xw / samples / arithmetic / calculate.xwx
Encoding:
Text File  |  1994-12-07  |  1.3 KB  |  33 lines

  1. %  This sample shows how to
  2. %  - create two Integer-Objects
  3. %  - calculate their values into a third object
  4. %  - show the result of the addition "on the fly"
  5. %  All calculations are done in floating point and written to the
  6. %  VAR-Elements in their respective VAR-Format
  7.  
  8. Malloc(90);                              %Get memory
  9. @xbwstart(("simple-project") ("bw"));    %Setup xbw system in "bw"/"color"
  10. wdw(TEST 3 4 20 11 StandardWDW);
  11.                                                            % VAR-PARAMETERS:
  12. o(TEST1 I I 2 3 15 1 Standard);  bg(TEST1 . 100 ); eg();   % 100
  13. o(TEST2 I I 2 4 15 1 Standard);  bg(TEST2 .  55 ); eg();   %  55
  14. o(TEST3 D D 2 7 15 1 Standard);
  15.   bg(TEST3 .   0.00001 ); ff( ("%12.7f") ("") 1.0 ); eg(); %   0.00001
  16.  
  17. % CALCULATE; this calculation runs only once (because it's in this macro file!)
  18. % Just move it into an object action, and it runs every time the object acts!
  19.  
  20. ?("First VAR-PARAMETER: ");                   ?(int)OBJ:TEST1.V;
  21. ?("Second VAR-PARAMETER:");                   ?(int)OBJ:TEST2.V;
  22. ?("Division Result:");
  23.   #a:=(int)OBJ:TEST1.V / (int)OBJ:TEST2.V;    ?(#a); % creating a temp.variable
  24. ?("Now putting the result in object TEST3");  (dbl)OBJ:TEST3.V := (#a);
  25.  
  26. o(TEST4 S . 2 9 15 1 Secure);
  27. bg(TEST4 . (" Exit"));
  28.   cn(raK("@stop();"));
  29.   eg();
  30. Message(("Project Complete."));     %That's it!
  31. End();
  32.  
  33.