Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!uunet!comp.vuw.ac.nz!canterbury!otago.ac.nz!erin From: erin@otago.ac.nz (John Gee) Newsgroups: comp.lang.pascal Subject: Re: procedures as parameters to procedures Message-ID: <1991Feb4.114449.74@otago.ac.nz> Date: 3 Feb 91 23:08:55 GMT References: <25782@adm.brl.mil> Organization: University of Otago, Dunedin, New Zealand Lines: 56 In article <25782@adm.brl.mil>, VMAN%PACEVM.BITNET@uga.cc.uga.edu ( cliff) writes: > hi, > we run vs pascal 2.1 on vm/sp 6. is it possible to pass as a procedure > parameter a procedure name with a parameter list? for example, > IMHO No. Need to pass the parameters separately. Reasoning for why it won't work follows. > program main (input,output); > > var word: packed array(1..5) of char; > > procedure abc(procedure xyx(var string: packed array(1..5) of char);i:integer); > . Telling pascal that you will give it a procedure. So that it can type check, you specify the parameter types that the procedure takes. (In this case a string) > . > procedure blah(var string: packed array(1..5) of char); > . > . > begin (* main program *) > . > . > abc(blah(word),3) > end. > IMHO this tries to pass the result returned by a procedure, as a procedure parameter - ie it doesn't make sense. Think of putting a function there instead of a procedure, since you have the parameters, it seems likely it will evaluate if before passing it? You need to do something like procedure abc ( procedure xyx (var string: packed array(1..5) of char); var word: packed array (1..5) of char); i: integer); ... abc (blah, word, 3); instead. - The views expressed here are my own, and not necessarily those of my employer. John Gee Systems Programmer E-mail: ERIN@otago.ac.nz (internet) Computing Services Centre Phone: +64 3 4798596 University of Otago Fax: +64 3 4798577 PO Box 56 Dunedin "Program until NEW ZEALAND you drop!"