1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>AARM95 - Interfacing with COBOL</TITLE>
<META NAME="Author" CONTENT="JTC1/SC22/WG9/ARG, by Randall Brukardt, ARG Editor">
<META NAME="GENERATOR" CONTENT="Arm_Form.Exe, Ada Reference Manual generator">
<STYLE type="text/css">
DIV.paranum {position: absolute; font-family: Arial, Helvetica, sans-serif; left: 0.5 em; top: auto}
TT {font-family: "Courier New", monospace}
DT {display: compact}
DIV.Normal {font-family: "Times New Roman", Times, serif; margin-bottom: 0.6em}
DIV.Wide {font-family: "Times New Roman", Times, serif; margin-top: 0.6em; margin-bottom: 0.6em}
DIV.Annotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
DIV.WideAnnotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0.6em; margin-bottom: 0.6em}
DIV.Index {font-family: "Times New Roman", Times, serif}
DIV.SyntaxSummary {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
DIV.Notes {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.6em}
DIV.NotesHeader {font-family: "Times New Roman", Times, serif; margin-left: 2.0em}
DIV.SyntaxIndented {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
DIV.Indented {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-bottom: 0.6em}
DIV.CodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
DIV.SmallIndented {font-family: "Times New Roman", Times, serif; margin-left: 10.0em; margin-bottom: 0.6em}
DIV.SmallCodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-bottom: 0.6em}
DIV.Examples {font-family: "Courier New", monospace; margin-left: 2.0em; margin-bottom: 0.6em}
DIV.SmallExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 7.5em; margin-bottom: 0.6em}
DIV.IndentedExamples {font-family: "Courier New", monospace; margin-left: 8.0em; margin-bottom: 0.6em}
DIV.SmallIndentedExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 15.0em; margin-bottom: 0.6em}
UL.Bulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SmallBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SmallNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.IndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.CodeIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.CodeIndentedNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SyntaxIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NotesBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NotesNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
DL.Hanging {font-family: "Times New Roman", Times, serif; margin-top: 0em; margin-bottom: 0.6em}
DD.Hanging {margin-left: 6.0em}
DL.IndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.IndentedHanging {margin-left: 2.0em}
DL.HangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.HangingInBulleted {margin-left: 4.0em}
DL.SmallHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.SmallHanging {margin-left: 7.5em}
DL.SmallIndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.SmallIndentedHanging {margin-left: 2.0em}
DL.SmallHangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.SmallHangingInBulleted {margin-left: 5.0em}
DL.Enumerated {font-family: "Times New Roman", Times, serif; margin-right: 0.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.Enumerated {margin-left: 2.0em}
DL.SmallEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.SmallEnumerated {margin-left: 2.5em}
DL.NestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
DL.SmallNestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
</STYLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFF0" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
<P><A HREF="AA-TOC.html">Contents</A> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-B-3-2.html">Previous</A> <A HREF="AA-B-5.html">Next</A></P>
<HR>
<H1> B.4 Interfacing with COBOL</H1>
<DIV Class="Paranum"><FONT SIZE=-2>1</FONT></DIV>
<DIV Class="Normal"> <A NAME="I6493"></A><A NAME="I6494"></A>The facilities
relevant to interfacing with the COBOL language are the package Interfaces.COBOL
and support for the Import, Export and Convention pragmas with <I>convention</I>_<FONT FACE="Arial, Helvetica">identifier</FONT>
COBOL.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>2</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> The COBOL interface
package supplies several sets of facilities: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>A set of types corresponding to the native COBOL types
of the supported COBOL implementation (so-called ``internal COBOL representations''),
allowing Ada data to be passed as parameters to COBOL programs</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>4</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>A set of types and constants reflecting external data representations
such as might be found in files or databases, allowing COBOL-generated
data to be read by an Ada program, and Ada-generated data to be read
by COBOL programs</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>5</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>A generic package for converting between an Ada decimal
type value and either an internal or external COBOL representation </LI></UL>
<H4 ALIGN=CENTER>Static Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> The library package
Interfaces.COBOL has the following declaration: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<DIV Class="Examples"><TT><B>package</B> Interfaces.COBOL <B>is</B><A NAME="I6495"></A><A NAME="I6496"></A><A NAME="I6497"></A><BR>
<B>pragma</B> Preelaborate(COBOL);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<DIV Class="Examples"><TT><I>-- Types and operations for internal data representations</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9</FONT></DIV>
<DIV Class="Examples"><TT> <B>type</B> <A NAME="I6498"></A><A NAME="I6499"></A>Floating <B>is</B> <B>digits</B> <I>implementation-defined</I>;<BR>
<B>type</B> <A NAME="I6500"></A><A NAME="I6501"></A>Long_Floating <B>is</B> <B>digits</B> <I>implementation-defined</I>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10</FONT></DIV>
<DIV Class="Examples"><TT> <B>type</B> <A NAME="I6502"></A><A NAME="I6503"></A>Binary <B>is</B> <B>range</B> <I>implementation-defined</I>;<BR>
<B>type</B> <A NAME="I6504"></A><A NAME="I6505"></A>Long_Binary <B>is</B> <B>range</B> <I>implementation-defined</I>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11</FONT></DIV>
<DIV Class="Examples"><TT> <A NAME="I6506"></A>Max_Digits_Binary : <B>constant</B> := <I>implementation-defined</I>;<BR>
<A NAME="I6507"></A>Max_Digits_Long_Binary : <B>constant</B> := <I>implementation-defined</I>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12</FONT></DIV>
<DIV Class="Examples"><TT> <B>type</B> <A NAME="I6508"></A><A NAME="I6509"></A>Decimal_Element <B>is</B> <B>mod</B> <I>implementation-defined</I>;<BR>
<B>type</B> <A NAME="I6510"></A><A NAME="I6511"></A>Packed_Decimal <B>is</B> <B>array</B> (Positive <B>range</B> <>) <B>of</B> Decimal_Element;<BR>
<B>pragma</B> Pack(Packed_Decimal);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>13</FONT></DIV>
<DIV Class="Examples"><TT> <B>type</B> <A NAME="I6512"></A><A NAME="I6513"></A>COBOL_Character <B>is</B> <I>implementation-defined character type</I>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>14</FONT></DIV>
<DIV Class="Examples"><TT> <A NAME="I6514"></A>Ada_To_COBOL : <B>array</B> (Character) <B>of</B> COBOL_Character := <I>implementation-defined</I>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>15</FONT></DIV>
<DIV Class="Examples"><TT> <A NAME="I6515"></A>COBOL_To_Ada : <B>array</B> (COBOL_Character) <B>of</B> Character := <I>implementation-defined</I>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>16</FONT></DIV>
<DIV Class="Examples"><TT> <B>type</B> <A NAME="I6516"></A><A NAME="I6517"></A>Alphanumeric <B>is</B> <B>array</B> (Positive range <>) <B>of</B> COBOL_Character;<BR>
<B>pragma</B> Pack(Alphanumeric);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>17</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I6518"></A><A NAME="I6519"></A>To_COBOL (Item : <B>in</B> String) <B>return</B> Alphanumeric;<BR>
<B>function</B> <A NAME="I6520"></A><A NAME="I6521"></A>To_Ada (Item : <B>in</B> Alphanumeric) <B>return</B> String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>18</FONT></DIV>
<DIV Class="Examples"><TT> <B>procedure</B> <A NAME="I6522"></A><A NAME="I6523"></A>To_COBOL (Item : <B>in</B> String;<BR>
Target : <B>out</B> Alphanumeric;<BR>
Last : <B>out</B> Natural);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>19</FONT></DIV>
<DIV Class="Examples"><TT> <B>procedure</B> <A NAME="I6524"></A><A NAME="I6525"></A>To_Ada (Item : <B>in</B> Alphanumeric;<BR>
Target : <B>out</B> String;<BR>
Last : <B>out</B> Natural);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>20</FONT></DIV>
<DIV Class="Examples"><TT> <B>type</B> <A NAME="I6526"></A><A NAME="I6527"></A>Numeric <B>is</B> <B>array</B> (Positive <B>range</B> <>) <B>of</B> COBOL_Character;<BR>
<B>pragma</B> Pack(Numeric);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>21</FONT></DIV>
<DIV Class="Examples"><TT><I>-- Formats for COBOL data representations</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>22</FONT></DIV>
<DIV Class="Examples"><TT> <B>type</B> <A NAME="I6528"></A><A NAME="I6529"></A>Display_Format <B>is</B> <B>private</B>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>23</FONT></DIV>
<DIV Class="Examples"><TT> <A NAME="I6530"></A>Unsigned : <B>constant</B> Display_Format;<BR>
<A NAME="I6531"></A>Leading_Separate : <B>constant</B> Display_Format;<BR>
<A NAME="I6532"></A>Trailing_Separate : <B>constant</B> Display_Format;<BR>
<A NAME="I6533"></A>Leading_Nonseparate : <B>constant</B> Display_Format;<BR>
<A NAME="I6534"></A>Trailing_Nonseparate : <B>constant</B> Display_Format;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>24</FONT></DIV>
<DIV Class="Examples"><TT> <B>type</B> <A NAME="I6535"></A><A NAME="I6536"></A>Binary_Format <B>is</B> <B>private</B>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>25</FONT></DIV>
<DIV Class="Examples"><TT> <A NAME="I6537"></A>High_Order_First : <B>constant</B> Binary_Format;<BR>
<A NAME="I6538"></A>Low_Order_First : <B>constant</B> Binary_Format;<BR>
<A NAME="I6539"></A>Native_Binary : <B>constant</B> Binary_Format;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>26</FONT></DIV>
<DIV Class="Examples"><TT> <B>type</B> <A NAME="I6540"></A><A NAME="I6541"></A>Packed_Format <B>is</B> <B>private</B>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>27</FONT></DIV>
<DIV Class="Examples"><TT> <A NAME="I6542"></A>Packed_Unsigned : <B>constant</B> Packed_Format;<BR>
<A NAME="I6543"></A>Packed_Signed : <B>constant</B> Packed_Format;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>28</FONT></DIV>
<DIV Class="Examples"><TT><I>-- Types for external representation of COBOL binary data</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>29</FONT></DIV>
<DIV Class="Examples"><TT> <B>type</B> <A NAME="I6544"></A><A NAME="I6545"></A>Byte <B>is</B> <B>mod</B> 2**COBOL_Character'Size;<BR>
<B>type</B> <A NAME="I6546"></A><A NAME="I6547"></A>Byte_Array <B>is</B> <B>array</B> (Positive <B>range</B> <>) <B>of</B> Byte;<BR>
<B>pragma</B> Pack (Byte_Array);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>30</FONT></DIV>
<DIV Class="Examples"><TT> <A NAME="I6548"></A>Conversion_Error : <B>exception</B>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>31</FONT></DIV>
<DIV Class="Examples"><TT> <B>generic</B><BR>
<B>type</B> Num <B>is</B> <B>delta</B> <> <B>digits</B> <>;<BR>
<B>package</B> Decimal_Conversions <B>is</B></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>32</FONT></DIV>
<DIV Class="Examples"><TT> <I>-- Display Formats: data values are represented as Numeric</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>33</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I6549"></A><A NAME="I6550"></A>Valid (Item : <B>in</B> Numeric;<BR>
Format : <B>in</B> Display_Format) <B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>34</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I6551"></A><A NAME="I6552"></A>Length (Format : <B>in</B> Display_Format) <B>return</B> Natural;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>35</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I6553"></A><A NAME="I6554"></A>To_Decimal (Item : <B>in</B> Numeric;<BR>
Format : <B>in</B> Display_Format) <B>return</B> Num;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>36</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I6555"></A><A NAME="I6556"></A>To_Display (Item : <B>in</B> Num;<BR>
Format : <B>in</B> Display_Format) <B>return</B> Numeric;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>37</FONT></DIV>
<DIV Class="Examples"><TT> <I>-- Packed Formats: data values are represented as Packed_Decimal</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>38</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I6557"></A><A NAME="I6558"></A>Valid (Item : <B>in</B> Packed_Decimal;<BR>
Format : <B>in</B> Packed_Format) <B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>39</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I6559"></A><A NAME="I6560"></A>Length (Format : <B>in</B> Packed_Format) <B>return</B> Natural;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>40</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I6561"></A><A NAME="I6562"></A>To_Decimal (Item : <B>in</B> Packed_Decimal;<BR>
Format : <B>in</B> Packed_Format) <B>return</B> Num;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>41</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I6563"></A><A NAME="I6564"></A>To_Packed (Item : <B>in</B> Num;<BR>
Format : <B>in</B> Packed_Format) <B>return</B> Packed_Decimal;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>42</FONT></DIV>
<DIV Class="Examples"><TT> <I>-- Binary Formats: external data values are represented as Byte_Array</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>43</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I6565"></A><A NAME="I6566"></A>Valid (Item : <B>in</B> Byte_Array;<BR>
Format : <B>in</B> Binary_Format) <B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>44</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I6567"></A><A NAME="I6568"></A>Length (Format : <B>in</B> Binary_Format) <B>return</B> Natural;<BR>
<B>function</B> <A NAME="I6569"></A><A NAME="I6570"></A>To_Decimal (Item : <B>in</B> Byte_Array;<BR>
Format : <B>in</B> Binary_Format) <B>return</B> Num;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>45</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I6571"></A><A NAME="I6572"></A>To_Binary (Item : <B>in</B> Num;<BR>
Format : <B>in</B> Binary_Format) <B>return</B> Byte_Array;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>46</FONT></DIV>
<DIV Class="Examples"><TT> <I>-- Internal Binary formats: data values are of type Binary or Long_Binary</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>47</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I6573"></A><A NAME="I6574"></A>To_Decimal (Item : <B>in</B> Binary) <B>return</B> Num;<BR>
<B>function</B> <A NAME="I6575"></A><A NAME="I6576"></A>To_Decimal (Item : <B>in</B> Long_Binary) <B>return</B> Num;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>48</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I6577"></A><A NAME="I6578"></A>To_Binary (Item : <B>in</B> Num) <B>return</B> Binary;<BR>
<B>function</B> <A NAME="I6579"></A><A NAME="I6580"></A>To_Long_Binary (Item : <B>in</B> Num) <B>return</B> Long_Binary;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>49</FONT></DIV>
<DIV Class="Examples"><TT> <B>end</B> Decimal_Conversions;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>50</FONT></DIV>
<DIV Class="Examples"><TT><B>private</B><BR>
... -- <I>not specified by the language</I><BR>
<B>end</B> Interfaces.COBOL;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>50.a/1</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Implementation defined: </B>The
types Floating, Long_Floating, Binary, Long_Binary, Decimal_Element,
and COBOL_Character; and the initializations of the variables Ada_To_COBOL
and COBOL_To_Ada, in Interfaces.COBOL<U>.</U></FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>51</FONT></DIV>
<DIV Class="Normal"> Each of the types in Interfaces.COBOL is COBOL-compatible.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>52</FONT></DIV>
<DIV Class="Normal"> The types Floating and Long_Floating correspond
to the native types in COBOL for data items with computational usage
implemented by floating point. The types Binary and Long_Binary correspond
to the native types in COBOL for data items with binary usage, or with
computational usage implemented by binary.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>53</FONT></DIV>
<DIV Class="Normal"> Max_Digits_Binary is the largest number of decimal
digits in a numeric value that is represented as Binary. Max_Digits_Long_Binary
is the largest number of decimal digits in a numeric value that is represented
as Long_Binary.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>54</FONT></DIV>
<DIV Class="Normal"> The type Packed_Decimal corresponds to COBOL's
packed-decimal usage.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>55</FONT></DIV>
<DIV Class="Normal"> The type COBOL_Character defines the run-time
character set used in the COBOL implementation. Ada_To_COBOL and COBOL_To_Ada
are the mappings between the Ada and COBOL run-time character sets. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>55.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>The character mappings
are visible variables, since the user needs the ability to modify them
at run time. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>56</FONT></DIV>
<DIV Class="Normal"> Type Alphanumeric corresponds to COBOL's alphanumeric
data category.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>57</FONT></DIV>
<DIV Class="Normal"> Each of the functions To_COBOL and To_Ada converts
its parameter based on the mappings Ada_To_COBOL and COBOL_To_Ada, respectively.
The length of the result for each is the length of the parameter, and
the lower bound of the result is 1. Each component of the result is obtained
by applying the relevant mapping to the corresponding component of the
parameter.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>58</FONT></DIV>
<DIV Class="Normal"> Each of the procedures To_COBOL and To_Ada copies
converted elements from Item to Target, using the appropriate mapping
(Ada_To_COBOL or COBOL_To_Ada, respectively). The index in Target of
the last element assigned is returned in Last (0 if Item is a null array).
<A NAME="I6581"></A>If Item'Length exceeds Target'Length, Constraint_Error
is propagated.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>59</FONT></DIV>
<DIV Class="Normal"> Type Numeric corresponds to COBOL's numeric data
category with display usage.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>60</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.9em"> The types Display_Format,
Binary_Format, and Packed_Format are used in conversions between Ada
decimal type values and COBOL internal or external data representations.
The value of the constant Native_Binary is either High_Order_First or
Low_Order_First, depending on the implementation. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>61</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> Valid (Item : <B>in</B> Numeric;<BR>
Format : <B>in</B> Display_Format) <B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>62</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.4em">The function
Valid checks that the Item parameter has a value consistent with the
value of Format. If the value of Format is other than Unsigned, Leading_Separate,
and Trailing_Separate, the effect is implementation defined. If Format
does have one of these values, the following rules apply: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>63/1</FONT></DIV>
<UL Class="CodeIndentedBulleted"><LI TYPE=DISC>{<I><A HREF="defect1.html#8652/0066">8652/0066</A></I>}
Format=Unsigned: if Item comprises <S>zero or more leading space characters
followed by </S>one or more decimal digit characters then Valid returns
True, else it returns False.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>64/1</FONT></DIV>
<UL Class="CodeIndentedBulleted"><LI TYPE=DISC>{<I><A HREF="defect1.html#8652/0066">8652/0066</A></I>}
Format=Leading_Separate: if Item comprises <S>zero or more leading space
characters, followed by </S>a single occurrence of the plus or minus
sign character, and then one or more decimal digit characters, then Valid
returns True, else it returns False.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>65/1</FONT></DIV>
<UL Class="CodeIndentedBulleted"><LI TYPE=DISC>{<I><A HREF="defect1.html#8652/0066">8652/0066</A></I>}
Format=Trailing_Separate: if Item comprises <S>zero or more leading space
characters, followed by </S>one or more decimal digit characters and
finally a plus or minus sign character, then Valid returns True, else
it returns False. </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>66</FONT></DIV>
<DIV Class="Examples" Style="margin-bottom: 0.9em"><TT><B>function</B> Length (Format : <B>in</B> Display_Format) <B>return</B> Natural;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>67</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">The Length function
returns the minimal length of a Numeric value sufficient to hold any
value of type Num when represented as Format.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>68</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> To_Decimal (Item : <B>in</B> Numeric;<BR>
Format : <B>in</B> Display_Format) <B>return</B> Num;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>69</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">Produces a value
of type Num corresponding to Item as represented by Format. The number
of digits after the assumed radix point in Item is Num'Scale. Conversion_Error
is propagated if the value represented by Item is outside the range of
Num. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>69.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>There is no
issue of truncation versus rounding, since the number of decimal places
is established by Num'Scale.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>70</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> To_Display (Item : <B>in</B> Num;<BR>
Format : <B>in</B> Display_Format) <B>return</B> Numeric;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>71/1</FONT></DIV>
<DIV Class="CodeIndented">{<I><A HREF="defect1.html#8652/0067">8652/0067</A></I>}
This function returns the Numeric value for Item, represented in accordance
with Format. <U>The length of the returned value is Length(Format), and
the lower bound is 1. </U>Conversion_Error is propagated if Num is negative
and Format is Unsigned.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>72</FONT></DIV>
<DIV Class="Examples" Style="margin-bottom: 0.9em"><TT><B>function</B> Valid (Item : <B>in</B> Packed_Decimal;<BR>
Format : <B>in</B> Packed_Format) <B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>73</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">This function
returns True if Item has a value consistent with Format, and False otherwise.
The rules for the formation of Packed_Decimal values are implementation
defined.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>74</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> Length (Format : <B>in</B> Packed_Format) <B>return</B> Natural;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>75</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">This function
returns the minimal length of a Packed_Decimal value sufficient to hold
any value of type Num when represented as Format.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>76</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> To_Decimal (Item : <B>in</B> Packed_Decimal;<BR>
Format : <B>in</B> Packed_Format) <B>return</B> Num;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>77</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">Produces a value
of type Num corresponding to Item as represented by Format. Num'Scale
is the number of digits after the assumed radix point in Item. Conversion_Error
is propagated if the value represented by Item is outside the range of
Num.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>78</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> To_Packed (Item : <B>in</B> Num;<BR>
Format : <B>in</B> Packed_Format) <B>return</B> Packed_Decimal;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>79/1</FONT></DIV>
<DIV Class="CodeIndented">{<I><A HREF="defect1.html#8652/0067">8652/0067</A></I>}
This function returns the Packed_Decimal value for Item, represented
in accordance with Format. <U>The length of the returned value is Length(Format),
and the lower bound is 1. </U>Conversion_Error is propagated if Num is
negative and Format is Packed_Unsigned.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>80</FONT></DIV>
<DIV Class="Examples" Style="margin-bottom: 0.9em"><TT><B>function</B> Valid (Item : <B>in</B> Byte_Array;<BR>
Format : <B>in</B> Binary_Format) <B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>81</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">This function
returns True if Item has a value consistent with Format, and False otherwise.
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>81.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>This function
returns False only when the represented value is outside the range of
Num.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>82</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> Length (Format : <B>in</B> Binary_Format) <B>return</B> Natural;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>83</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">This function
returns the minimal length of a Byte_Array value sufficient to hold any
value of type Num when represented as Format.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>84</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> To_Decimal (Item : <B>in</B> Byte_Array;<BR>
Format : <B>in</B> Binary_Format) <B>return</B> Num;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>85</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">Produces a value
of type Num corresponding to Item as represented by Format. Num'Scale
is the number of digits after the assumed radix point in Item. Conversion_Error
is propagated if the value represented by Item is outside the range of
Num.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>86</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> To_Binary (Item : <B>in</B> Num;<BR>
Format : <B>in</B> Binary_Format) <B>return</B> Byte_Array;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>87/1</FONT></DIV>
<DIV Class="CodeIndented">{<I><A HREF="defect1.html#8652/0067">8652/0067</A></I>}
This function returns the Byte_Array value for Item, represented in accordance
with Format. <U>The length of the returned value is Length(Format), and
the lower bound is 1.</U></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>88</FONT></DIV>
<DIV Class="Examples" Style="margin-bottom: 0.9em"><TT><B>function</B> To_Decimal (Item : <B>in</B> Binary) <B>return</B> Num;<BR>
<BR>
<B>function</B> To_Decimal (Item : <B>in</B> Long_Binary) <B>return</B> Num;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>89</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">These functions
convert from COBOL binary format to a corresponding value of the decimal
type Num. Conversion_Error is propagated if Item is too large for Num.
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>89.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>There is
no rescaling performed on the conversion. That is, the returned value
in each case is a ``bit copy'' if Num has a binary radix. The programmer
is responsible for maintaining the correct scale. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>90</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> To_Binary (Item : <B>in</B> Num) <B>return</B> Binary;<BR>
<BR>
<B>function</B> To_Long_Binary (Item : <B>in</B> Num) <B>return</B> Long_Binary;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>91</FONT></DIV>
<DIV Class="CodeIndented">These functions convert from Ada decimal to
COBOL binary format. Conversion_Error is propagated if the value of Item
is too large to be represented in the result type. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>91.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>One style of
interface supported for COBOL, similar to what is provided for C, is
the ability to call and pass parameters to an existing COBOL program.
Thus the interface package supplies types that can be used in an Ada
program as parameters to subprograms whose bodies will be in COBOL. These
types map to COBOL's alphanumeric and numeric data categories.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>91.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>Several types are provided for
support of alphanumeric data. Since COBOL's run-time character set is
not necessarily the same as Ada's, Interfaces.COBOL declares an implementation-defined
character type COBOL_Character, and mappings between Character and COBOL_Character.
These mappings are visible variables (rather than, say, functions or
constant arrays), since in the situation where COBOL_Character is EBCDIC,
the flexibility of dynamically modifying the mappings is needed. Corresponding
to COBOL's alphanumeric data is the string type Alphanumeric.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>91.c</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>Numeric data may have either a
``display'' or ``computational'' representation in COBOL. On the Ada
side, the data is of a decimal fixed point type. Passing an Ada decimal
data item to a COBOL program requires conversion from the Ada decimal
type to some type that reflects the representation expected on the COBOL
side. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>91.d</FONT></DIV>
<UL Class="SmallBulleted"><FONT SIZE=-1><LI TYPE=DISC>Computational Representation</LI></FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>91.e</FONT></DIV>
<UL Class="SmallBulleted"><FONT SIZE=-1>Floating point representation
is modeled by Ada floating point types, Floating and Long_Floating. Conversion
between these types and Ada decimal types is obtained directly, since
the type name serves as a conversion function.</FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>91.f</FONT></DIV>
<UL Class="SmallBulleted"><FONT SIZE=-1>Binary representation is modeled
by an Ada integer type, Binary, and possibly other types such as Long_Binary.
Conversion between, say, Binary and a decimal type is through functions
from an instantiation of the generic package Decimal_Conversions.</FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>91.g</FONT></DIV>
<UL Class="SmallBulleted"><FONT SIZE=-1>Packed decimal representation
is modeled by the Ada array type Packed_Decimal. Conversion between packed
decimal and a decimal type is through functions from an instantiation
of the generic package Decimal_Conversions.</FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>91.h</FONT></DIV>
<UL Class="SmallBulleted"><FONT SIZE=-1><LI TYPE=DISC>Display Representation</LI></FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>91.i</FONT></DIV>
<UL Class="SmallBulleted"><FONT SIZE=-1>Display representation for numeric
data is modeled by the array type Numeric. Conversion between display
representation and a decimal type is through functions from an instantiation
of the generic package Decimal_Conversions. A parameter to the conversion
function indicates the desired interpretation of the data (e.g., signed
leading separate, etc.) </FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>91.j</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>Pragma Convention(COBOL, T) may
be applied to a record type T to direct the compiler to choose a COBOL-compatible
representation for objects of the type.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>91.k</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>The package Interfaces.COBOL allows
the Ada programmer to deal with data from files (or databases) created
by a COBOL program. For data that is alphanumeric, or in display or packed
decimal format, the approach is the same as for passing parameters (instantiate
Decimal_Conversions to obtain the needed conversion functions). For binary
data, the external representation is treated as a Byte array, and an
instantiation of Decimal_IO produces a package that declares the needed
conversion functions. A parameter to the conversion function indicates
the desired interpretation of the data (e.g., high- versus low-order
byte first). </FONT></DIV>
<H4 ALIGN=CENTER>Implementation Requirements</H4>
<DIV Class="Paranum"><FONT SIZE=-2>92</FONT></DIV>
<DIV Class="Normal"> An implementation shall support pragma Convention
with a COBOL <I>convention</I>_<FONT FACE="Arial, Helvetica">identifier</FONT>
for a COBOL-eligible type (see <A HREF="AA-B-1.html">B.1</A>). </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>92.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>An implementation
supporting this package shall ensure that if the bounds of a Packed_Decimal,
Alphanumeric, or Numeric variable are static, then the representation
of the object comprises solely the array components (that is, there is
no implicit run-time ``descriptor'' that is part of the object). </FONT></DIV>
<H4 ALIGN=CENTER>Implementation Permissions</H4>
<DIV Class="Paranum"><FONT SIZE=-2>93</FONT></DIV>
<DIV Class="Normal"> An implementation may provide additional constants
of the private types Display_Format, Binary_Format, or Packed_Format.
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>93.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>This is to allow
exploitation of other external formats that may be available in the COBOL
implementation.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>94</FONT></DIV>
<DIV Class="Normal"> An implementation may provide further floating
point and integer types in Interfaces.COBOL to match additional native
COBOL types, and may also supply corresponding conversion functions in
the generic package Decimal_Conversions. </DIV>
<H4 ALIGN=CENTER>Implementation Advice</H4>
<DIV Class="Paranum"><FONT SIZE=-2>95</FONT></DIV>
<DIV Class="Normal"> An Ada implementation should support the following
interface correspondences between Ada and COBOL. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>96</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>An Ada <B>access</B> T parameter is passed as a ``BY REFERENCE''
data item of the COBOL type corresponding to T.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>97</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>An Ada <B>in</B> scalar parameter is passed as a ``BY CONTENT''
data item of the corresponding COBOL type.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>98</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>Any other Ada parameter is passed as a ``BY REFERENCE''
data item of the COBOL type corresponding to the Ada parameter type;
for scalars, a local copy is used if necessary to ensure by-copy semantics.
</LI></UL>
<DIV Class="NotesHeader"><FONT SIZE=-1>NOTES</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>99</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>15 An implementation is not
required to support pragma Convention for access types, nor is it required
to support pragma Import, Export or Convention for functions. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>99.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>COBOL does not
have a pointer facility, and a COBOL program does not return a value.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>100</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>16 If an Ada subprogram is
exported to COBOL, then a call from COBOL call may specify either ``BY
CONTENT'' or ``BY REFERENCE''. </FONT></DIV>
<H4 ALIGN=CENTER>Examples</H4>
<DIV Class="Paranum"><FONT SIZE=-2>101</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> <I>Examples of
Interfaces.COBOL:</I> </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>102</FONT></DIV>
<DIV Class="Examples"><TT><B>with</B> Interfaces.COBOL;<BR>
<B>procedure</B> Test_Call <B>is</B></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>103</FONT></DIV>
<DIV Class="Examples"><TT> <I>-- Calling a foreign COBOL program</I><BR>
<I>-- Assume that a COBOL program PROG has the following declaration</I><BR>
<I>-- in its LINKAGE section:</I><BR>
<I>-- 01 Parameter-Area</I><BR>
<I>-- 05 NAME PIC X(20).</I><BR>
<I>-- 05 SSN PIC X(9).</I><BR>
<I>-- 05 SALARY PIC 99999V99 USAGE COMP.</I><BR>
<I>-- The effect of PROG is to update SALARY based on some algorithm</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>104</FONT></DIV>
<DIV Class="Examples"><TT> <B>package</B> COBOL <B>renames</B> Interfaces.COBOL;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>105</FONT></DIV>
<DIV Class="Examples"><TT> <B>type</B> Salary_Type <B>is</B> <B>delta</B> 0.01 <B>digits</B> 7;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>106</FONT></DIV>
<DIV Class="Examples"><TT> <B>type</B> COBOL_Record <B>is</B><BR>
<B>record</B><BR>
Name : COBOL.Numeric(1..20);<BR>
SSN : COBOL.Numeric(1..9);<BR>
Salary : COBOL.Binary; <I>-- Assume Binary = 32 bits</I><BR>
<B>end</B> <B>record</B>;<BR>
<B>pragma</B> Convention (COBOL, COBOL_Record);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>107</FONT></DIV>
<DIV Class="Examples"><TT> <B>procedure</B> Prog (Item : <B>in</B> <B>out</B> COBOL_Record);<BR>
<B>pragma</B> Import (COBOL, Prog, "PROG");</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>108</FONT></DIV>
<DIV Class="Examples"><TT> <B>package</B> Salary_Conversions <B>is</B><BR>
<B>new</B> COBOL.Decimal_Conversions(Salary_Type);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>109</FONT></DIV>
<DIV Class="Examples"><TT> Some_Salary : Salary_Type := 12_345.67;<BR>
Some_Record : COBOL_Record :=<BR>
(Name => "Johnson, John ",<BR>
SSN => "111223333",<BR>
Salary => Salary_Conversions.To_Binary(Some_Salary));</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>110</FONT></DIV>
<DIV Class="Examples"><TT><B>begin</B><BR>
Prog (Some_Record);<BR>
...<BR>
<B>end</B> Test_Call;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>111</FONT></DIV>
<DIV Class="Examples"><TT><B>with</B> Interfaces.COBOL;<BR>
<B>with</B> COBOL_Sequential_IO; <I>-- Assumed to be supplied by implementation</I><BR>
<B>procedure</B> Test_External_Formats <B>is</B></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>112</FONT></DIV>
<DIV Class="Examples"><TT> <I>-- Using data created by a COBOL program</I><BR>
<I>-- Assume that a COBOL program has created a sequential file with</I><BR>
<I>-- the following record structure, and that we need to</I><BR>
<I>-- process the records in an Ada program</I><BR>
<I>-- 01 EMPLOYEE-RECORD</I><BR>
<I>-- 05 NAME PIC X(20).</I><BR>
<I>-- 05 SSN PIC X(9).</I><BR>
<I>-- 05 SALARY PIC 99999V99 USAGE COMP.</I><BR>
<I>-- 05 ADJUST PIC S999V999 SIGN LEADING SEPARATE.</I><BR>
<I>-- The COMP data is binary (32 bits), high-order byte first</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>113</FONT></DIV>
<DIV Class="Examples"><TT> <B>package</B> COBOL <B>renames</B> Interfaces.COBOL;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>114</FONT></DIV>
<DIV Class="Examples"><TT> <B>type</B> Salary_Type <B>is</B> <B>delta</B> 0.01 <B>digits</B> 7;<BR>
<B>type</B> Adjustments_Type <B>is</B> <B>delta</B> 0.001 <B>digits</B> 6;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>115</FONT></DIV>
<DIV Class="Examples"><TT> <B>type</B> COBOL_Employee_Record_Type <B>is</B> <I>-- External representation</I><BR>
<B>record</B><BR>
Name : COBOL.Alphanumeric(1..20);<BR>
SSN : COBOL.Alphanumeric(1..9);<BR>
Salary : COBOL.Byte_Array(1..4);<BR>
Adjust : COBOL.Numeric(1..7); <I>-- Sign and 6 digits</I><BR>
<B>end</B> <B>record</B>;<BR>
<B>pragma</B> Convention (COBOL, COBOL_Employee_Record_Type);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>116</FONT></DIV>
<DIV Class="Examples"><TT> <B>package</B> COBOL_Employee_IO <B>is</B><BR>
<B>new</B> COBOL_Sequential_IO(COBOL_Employee_Record_Type);<BR>
<B>use</B> COBOL_Employee_IO;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>117</FONT></DIV>
<DIV Class="Examples"><TT> COBOL_File : File_Type;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>118</FONT></DIV>
<DIV Class="Examples"><TT> <B>type</B> Ada_Employee_Record_Type <B>is</B> <I>-- Internal representation</I><BR>
<B>record</B><BR>
Name : String(1..20);<BR>
SSN : String(1..9);<BR>
Salary : Salary_Type;<BR>
Adjust : Adjustments_Type;<BR>
<B>end</B> <B>record</B>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>119</FONT></DIV>
<DIV Class="Examples"><TT> COBOL_Record : COBOL_Employee_Record_Type;<BR>
Ada_Record : Ada_Employee_Record_Type;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>120</FONT></DIV>
<DIV Class="Examples"><TT> <B>package</B> Salary_Conversions <B>is</B><BR>
<B>new</B> COBOL.Decimal_Conversions(Salary_Type);<BR>
<B>use</B> Salary_Conversions;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>121</FONT></DIV>
<DIV Class="Examples"><TT> <B>package</B> Adjustments_Conversions <B>is</B><BR>
<B>new</B> COBOL.Decimal_Conversions(Adjustments_Type);<BR>
<B>use</B> Adjustments_Conversions;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>122</FONT></DIV>
<DIV Class="Examples"><TT><B>begin</B><BR>
Open (COBOL_File, Name => "Some_File");</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>123</FONT></DIV>
<DIV Class="Examples"><TT> <B>loop</B><BR>
Read (COBOL_File, COBOL_Record);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>124</FONT></DIV>
<DIV Class="Examples"><TT> Ada_Record.Name := To_Ada(COBOL_Record.Name);<BR>
Ada_Record.SSN := To_Ada(COBOL_Record.SSN);<BR>
Ada_Record.Salary :=<BR>
To_Decimal(COBOL_Record.Salary, COBOL.High_Order_First);<BR>
Ada_Record.Adjust :=<BR>
To_Decimal(COBOL_Record.Adjust, COBOL.Leading_Separate);<BR>
... <I>-- Process Ada_Record</I><BR>
<B>end</B> <B>loop</B>;<BR>
<B>exception</B><BR>
<B>when</B> End_Error => ...<BR>
<B>end</B> Test_External_Formats;</TT></DIV>
<HR>
<P><A HREF="AA-TOC.html">Contents</A> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-B-3-2.html">Previous</A> <A HREF="AA-B-5.html">Next</A> <A HREF="AA-TTL.html">Legal</A></P>
</BODY>
</HTML>
|