From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00,INVALID_MSGID, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,a1a88c4d509f6381 X-Google-Attributes: gid103376,public From: Matthew Heaney Subject: Re: scope and/or parameters (beginner) Date: 1999/04/03 Message-ID: #1/1 X-Deja-AN: 462127112 References: <37064309.889106243@news.dsuper.net> NNTP-Posting-Date: Fri, 02 Apr 1999 16:58:34 PDT Newsgroups: comp.lang.ada Date: 1999-04-03T00:00:00+00:00 List-Id: fluffy_pink@dsuper.net writes: > Here is what I have that doesn't work: > ----------------------------------------------------------- > PROCEDURE One_Procedure > ( Second_Variable : IN The_Type; > Third_Variable : OUT The_Type ) IS > > -- types & sub-types: none =========================== > -- sub-programs ====================================== > > PROCEDURE Internal_Procedure > ( One_Variable : IN OUT The_Type ) IS > BEGIN > One_Variable := One_Variable + A_Constant; > -- What goes on here is not important. The point > -- Is that I am (want to) modify the value of > -- "One_Variable" and bring its new value to > -- "One_Procedure", as an IN OUT should be used. > END Internal_Procedure; > > -- variables: none =================================== > > BEGIN -- One_Procedure > > Internal_Procedure ( One_Variable => (QUESTION) ); > Third_Variable = Second_Variable + Another_Constant; > -- More stuff goes here using "Third_Variable". > > END One_Procedure; > ----------------------------------------------------------- > > In my main program I have declared the following variables: > > Var_2, Var_3 : The_Type; > > In my main program I am calling "One_Proc�dure" with: > > One_Procedure > (Second_Variable => Var_2, Third_Variable => Var_3); > > If for "(QUESTION)" I use "Second_Variable" the compiler tells me that > for an OUT or an IN OUT I must have an actual parameter that **is a > variable***. I don't understand why it tells me this. Obviously, if > I use "Var_2", then it says that it cannot see "Var_2"; that I think I > understand. The problem is that anywhere inside One_Procedure, the object Second_Variable is a constant, because it's an in-mode parameter. Yes, the object Var_2 is a variable, but One_Procedure doesn't know this. One_Procedure is looking at Var_2 via the formal parameter Second_Variable, which is in-mode, and therefore is constant. > How can I pass the value of Var_2 from my main program, into > One_Procedure, and then from One_Procedure into Internal_Procedure, > and then to make it come back out modified (IN OUT) so that it will > end up in One_Proc�dure ? Make the formal parameter Second_Variable mode in out, instead of mode in. Here's a little formula for formal parameter modes: in = object is treated as a constant in out = object is treated as a variable > I don't want to use the modified value of Var_2 (modified by > Internal_Procedure) at the main program level; I want to use it only > in One_Proc�dure. Then you have to make a local copy.