Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!mips!decwrl!deccrl!news.crl.dec.com!nntpd.lkg.dec.com!ryn.mro4.dec.com!shrnew.enet.dec.com!doody From: doody@shrnew.enet.dec.com Newsgroups: comp.lang.pascal Subject: Re: VAX Pascal Question. Somebody... Message-ID: <4821@ryn.mro4.dec.com> Date: 14 May 91 20:16:20 GMT References: <1991May9.141955.3561@desire.wright.edu> Sender: guest@ryn.mro4.dec.com Reply-To: doody@shrnew.enet.dec.com () Organization: Digital Equipment Corporation Lines: 72 In article <1991May9.141955.3561@desire.wright.edu>, bbehrmann@desire.wright.edu writes: |> |> I've never used VAX Pascal before, stick with TP, but I am trying |>to program something on a VMS system and am in need of a RANDOM number |>function, and a function that allows you to execute VAX commands. (Some |>type of SHELL) If anyone happens to know the answer, I'd greatly appriciate |>it if you would let me know!! |>Thanks!! |>Talk to you later!! |> |> -Barry- |> |> Well, I have used VAX Pascal and TP. Both are great at what they do. For VAX Pascal, You want to use the VMS RTL (run-time libraries). See $HELP RTL LIB$ and $ HELP RTL MTH$ (or much better, the hardcopy if you got em). For a 'shell' (really a command line interpreter in VMS lingo) You'll want to use LIB$SPAWN. There are lots of options for LIB$SPAWN. You'll have to read the docs for them all. The following fragment shows an example I've used to mail a message (before the days of callable mail). Any DCL command could be used. Also you can specify a command file ( script ) to run instead of just a single command. [ INHERIT('sys$library:starlet', 'sys$library:pascal$lib_routines' )] { need to INHERIT the routine declaration } [...] VAR spawn_command : varying [255] of char; spawn_status : [volatile] unsigned; { [volatile] because LIB$SPAWN is going to modify it behind Pascal's back...} [...] spawn_status := 0; WRITEV( spawn_command, '$ mail/noself ', my_filename, mail_address ); lib$spawn ( command_string := spawn_command, completion_status_address := address(spawn_status) ); if not odd( spawn_status ) then begin { error during the DCL command } end; Here's a little example for random number generation. You'll have to come up with an initial seed. Maybe generated from the current time or something. [ INHERIT('sys$library:pascal$mth_routines' )] PROGRAM random ( OUTPUT ); VAR random_number : REAL; seed : UNSIGNED; loop : INTEGER; BEGIN {seed := routine_to_get_seed;} seed := 826495832; { for example to run } FOR loop := 1 TO 10 DO BEGIN random_number := MTH$RANDOM ( seed ); WRITELN( 'Seed is ', Seed:11,' random is ', random_number:0:11 ); END; END.