home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / ada / 2509 < prev    next >
Encoding:
Text File  |  1992-09-02  |  2.4 KB  |  66 lines

  1. Newsgroups: comp.lang.ada
  2. Path: sparky!uunet!cs.utexas.edu!sdd.hp.com!uakari.primate.wisc.edu!aplcen.apl.jhu.edu!ddsdx2.jhuapl.edu!dlc
  3. From: dlc@ddsdx2.jhuapl.edu (Dave Collard x7468)
  4. Subject: Re: pragma INTERFACE to MTH$RANDOM in DEC ADA?
  5. Message-ID: <1992Sep2.122928.22153@aplcen.apl.jhu.edu>
  6. Sender: news@aplcen.apl.jhu.edu (USENET News System)
  7. Organization: Johns Hopkins University
  8. References: <ELLIOTTM.92Sep2032817@beach.csulb.edu>
  9. Distribution: usa
  10. Date: Wed, 2 Sep 92 12:29:28 GMT
  11. Lines: 53
  12.  
  13. In <ELLIOTTM.92Sep2032817@beach.csulb.edu> elliottm@beach.csulb.edu (Mike Elliott) writes:
  14.  
  15. >I've gotten stuck trying to interface to the VMS math library routine
  16. >MTH$RANDOM, which takes the address of an integer seed as its argument, and
  17. >returns a FLOAT.  Ada rightly complains if I declare my routine as a function
  18. >taking an in out INTEGER parameter, but my other attempts to trick DEC ADA into
  19. >iterfacing to this routine have also failed.  They include
  20.  
  21. >   1) declaring the function to take a parameter of type access INTEGER, which
  22. >      points to an actual intger which can be changed (the INTEGER pointed to
  23. >      remains immutable),
  24.  
  25. >   2) declaring the function to take a parameter of type SYSTEM'ADDRESS, and
  26. >      passing it the address of some integer (the INTEGER at said address
  27. >      remains stubbornly unchanged).
  28.  
  29. >I'm sure there's some way to do this, but my only two DEC ADA manuals shed no
  30. >light on how.  They do illustrate how to interface to routines like MTH$SQRT,
  31. >which rightly take a parameter of type in FLOAT, and these attempts have been
  32. >successful. 
  33. >-- 
  34.  
  35. --    MTH$RANDOM
  36. --    
  37. --    Random-Number Generator, Uniformly Distributed
  38. --    
  39. --    The Random-Number Generator, Uniformly Distributed
  40. --    routine is a general random-number generator. 
  41. --    
  42.  
  43.     procedure RANDOM (
  44.     RESULT        : out FLOAT;                    -- return value
  45.     SEED        : in out UNSIGNED_LONGWORD);
  46.  
  47.     pragma INTERFACE (EXTERNAL, RANDOM);
  48.  
  49.     pragma IMPORT_VALUED_PROCEDURE (RANDOM, "mth$random",
  50.     (FLOAT, UNSIGNED_LONGWORD),
  51.     (VALUE, REFERENCE));
  52.  
  53. this is the interface supplied by DEC.  What version of Ada are you using?
  54. They supply an interface to everything in the math lib, just 
  55.  
  56. with MTH;
  57.  
  58. look in ADA$PREDEFINED:MTH_.ADC for the spec.  If you don't have this
  59. then you are working with a pretty old version of DEC Ada. If you can't 
  60. find this, then email me.
  61.  
  62.  
  63. --Thor
  64. collard@capsrv.jhuapl.edu
  65. dlc@ddsdx2.jhuapl.edu
  66.