This is a multi-part message in MIME format.
Op 18-9-2021 om 7:54 schreef ldries46:
Op 13-9-2021 om 19:08 schreef ldries46:
I have a set of constants that need a different name each for
readability. It may not be an array.
For instance:
C1 : constant record_item := .....
C2 : constant record_item := .....
C3 : constant record_item := .....
C4 : constant record_item := .....
C5 : constant record_item := .....
Now in a procedure or a function I have to use one of these constants
for instance:
function X(C : record_item) return record_Item is
RI : record_item;
begin
..
..
RI := C -- This C may only be one of the five constants and not
another record_item
..
..
return RI;
end X;
In what way do I test if C is a constant and not another record Item
In the meantime I have added a boolean to the record "record_item"in
which true means this is a constant and false this not a constant then
in the function X I raise an exception if that boolean if false
The solution that finally worked is:
Create a new record
/type C_record_item is record //
// Item : record_Item;//
// const : boolean := true;//
//end;//
/then
/C1 : constant C_record_item := ..... //
//C2 : constant C_record_item := ..... //
//C3 : constant C_record_item := ..... //
//C4 : constant C_record_item := ..... //
//C5 : constant C_record_item := ..... //
//
//function X(C : C_record_item) return record_Item is //
// RI : record_item; //
//begin //
// .. //
// .. //
// RI := C.item; -- This C may only be one of the five constants and
not another record_item //
// .. //
// .. //
// return RI; //
//end X; //
///Now You have the possibility to use a function or a procedure in
which you are forced to use the constant or else you get an error
message . For instance if the function X is a "function New_Item".
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-cite-prefix">Op 18-9-2021 om 7:54 schreef ldries46:<br>
</div>
<blockquote type="cite"
cite="mid:nnd$32625521$73c3d8da@cb0786dc2fdce31d">Op 13-9-2021 om
19:08 schreef ldries46:
<br>
<blockquote type="cite">I have a set of constants that need a
different name each for readability. It may not be an array.
<br>
For instance:
<br>
C1 : constant record_item := .....
<br>
C2 : constant record_item := .....
<br>
C3 : constant record_item := .....
<br>
C4 : constant record_item := .....
<br>
C5 : constant record_item := .....
<br>
<br>
Now in a procedure or a function I have to use one of these
constants
<br>
for instance:
<br>
<br>
function X(C : record_item) return record_Item is
<br>
RI : record_item;
<br>
begin
<br>
..
<br>
..
<br>
RI := C -- This C may only be one of the five constants and
not another record_item
<br>
..
<br>
..
<br>
return RI;
<br>
end X;
<br>
<br>
In what way do I test if C is a constant and not another record
Item
<br>
</blockquote>
In the meantime I have added a boolean to the record
"record_item"in which true means this is a constant and false
this not a constant then in the function X I raise an exception
if that boolean if false
<br>
</blockquote>
The solution that finally worked is:<br>
Create a new record<br>
<i>type C_record_item is record </i><i><br>
</i><i> Item : record_Item;</i><i><br>
</i><i> const : boolean := true;</i><i><br>
</i><i>end;</i><i><br>
</i>then<br>
<i>C1 : constant C_record_item := .....
</i><i><br>
</i><i>C2 : constant C_record_item := .....
</i><i><br>
</i><i>C3 : constant C_record_item := .....
</i><i><br>
</i><i>C4 : constant C_record_item := .....
</i><i><br>
</i><i>C5 : constant C_record_item := .....
</i><i><br>
</i><i><br>
</i><i>function X(C : C_record_item) return record_Item is
</i><i><br>
</i><i> RI : record_item;
</i><i><br>
</i><i>begin
</i><i><br>
</i><i> ..
</i><i><br>
</i><i> ..
</i><i><br>
</i><i> RI := C.item; -- This C may only be one of the five
constants and not another record_item
</i><i><br>
</i><i> ..
</i><i><br>
</i><i> ..
</i><i><br>
</i><i> return RI;
</i><i><br>
</i><i>end X;
</i><i><br>
</i><i>
</i>Now You have the possibility to use a function or a procedure in
which you are forced to use the constant or else you get an error
message . For instance if the function X is a "function New_Item".<br>
</body>
</html>
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)