From: CSBVAX::MRGATE!@KL.SRI.Com,@wiscvm.wisc.edu:CARTER@MITBATES.BITNET@SMTP 11-NOV-1987 01:33 To: EVERHART Subj: Re: Pascal and external routines Received: from wiscvm.wisc.edu by KL.SRI.COM with TCP; Tue 10 Nov 87 19:02:12-PST Received: from MITBATES.BITNET by wiscvm.wisc.edu ; Tue, 10 Nov 87 21:01:30 CDT Date: Tue, 10 Nov 87 17:43 EDT From: (Tony Carter - MIT Bates Linac) Subject: Re: Pascal and external routines To: info-vax@kl.sri.com X-Original-To: info-vax@kl.sri.com, CARTER >Regarding use of assorted system-defined status codes in Vax Pascal, >doesn't the statement > >[INHERIT ('SYS$LIBRARY:STARLET')] > >at the top of the program, automatically include for you most, if not >all, the system-defined status-code values, labels, etc. ? I found this >in the Pascal Reference Manual and/or User's Guide (can never quite keep >the two straight), and it seems to work fine for most everything, EXCEPT: Yes, it does. But you can also define you OWN error messages for use within a program. These are obviously not going to be in any of the VMS-supplied environment files. >Part of the problem would be solved if someone can tell me how to declare >a PROCEDURE or FUNCTION so as to allow "optional" parameters - i.e., so >that you can omit a parameter when actually calling the routine. I know >it's possible because the system-service routines defined in STARLET.PEN >allow you to omit parameters, but I haven't been able to get this to >work in my own declarations, particularly for LIB$ routines. Any informa- >tion would be greatly appreciated; I feel like it shouldn't take much to >clarify this for me - I feel that I'm just misunderstanding the effects >of an "attribute" or two somewhere. It's difficult to give a "course" in this over the net, but maybe an example would be helpful. This program uses LIB$GETJPI and defines it so that optional parameters are really optional: ---------------------------------cut here--------------------------------------- [inherit('sys$library:starlet')] program getuser(output); type $word = [word] -32768..32767; var stat : unsigned; username : varying[80] of char; [asynchronous,external] function lib$getjpi (%ref itemcode : integer; var processid : unsigned := %immed 0; %descr processname : varying[$u0] of char := %immed 0; var outvalue : [unsafe] integer := %immed 0; %descr outstring : varying[$u1] of char := %immed 0; var outlen : $word := %immed 0):unsigned;extern; begin { No parameter between commas means use the default. } stat := lib$getjpi(jpi$_username,,,,username); writeln(username); { Or use formal parameter name to indicate use. } stat := lib$getjpi(itemcode:=jpi$_username,outstring:=username); writeln(username); end.(*getuser*) ---------------------------------cut here--------------------------------------- The ":= %IMMED 0"'s tell Pascal what the default value for each parameter is and how to pass it. This is how the system services and library routines expect to be passed a "null" parameter ( a zero on the stack). The best place to learn about these things is in the "Procedures and Functions" section of the reference manual. Tony Carter CARTER@MITBATES (Bitnet) MIT Bates Linac CARTER@MITLNS.MIT.EDU (Arpanet) Middleton, MA