next up previous contents index
Next: Context Levels Up: MIDAS Command Language Previous: Interrupting Procedures

  
Entry points

It is sometimes desirable to group several related procedures into a single file. In MIDAS, the ENTRY command defines entry points for different procedures in the same file. These individual procedures are executed by specifying also their entry point besides the file name in the `@@' command.

!+
! Example 18, MIDAS procedure exa18.prg
!+
DEFINE/PARAM P1 11 NUMBER "Enter input number: "
DEFINE/MAXPAR 1
! only one parameter expected
WRITE/OUT "Parameter 1 =
$\{$P1$\}$"
!
ENTRY 2
DEFINE/PARAM P1 new C "Enter input: "
DEFINE/MAXPAR 1
! only one parameter expected
WRITE/OUT "Parameter 1 =
$\{$P1$\}$"
!
ENTRY third
DEFINE/PARAM P1 spiral IMA "Enter input image: "
DEFINE/MAXPAR 1
! only one parameter expected
WRITE/OUT "Parameter 1 =
$\{$P1$\}$"
  
The string following the ENTRY command (max. 8 characters) is used in the `@@' command to select the code segment in the file exa18.prg. Thus, @@ exa18,2 old will result in the display of the line: `Parameter 1 = old'; the following ENTRY statements indicates the end of this code segment and acts like a RETURN statement. Entering @@ exa18,third produces the output: `Parameter 1 = spiral'; and @@ exa18 -12 will execute the lines with no preceding ENTRY statement, i.e. write: `Parameter 1 = -12'. This example also shows that parameter P1 is not global, that means it has to be defined in each ENTRY segment of the procedure file.   
Entries may also be used to structure the contents of a MIDAS procedure. In the following example, the procedure exa18.prg executes different code segments according to its first parameter.

!+
! Example 19, MIDAS procedure exa19.prg
!+
DEFINE/PARAM P1 000 C "Enter control flags for entries: "
DEFINE/PARAM P2 sombrero IMA "Enter image to work with: "
DEFINE/MAXPAR 2
! max 2 parameters expected
!
DEFINE/LOCAL LOOP/I/1/1 0
DEFINE/LOCAL CCC/C/1/3
$\{$P1(1:3)$\}$
SET/FORMAT I1
DO LOOP = 1 3
IF CCC(
$\{$LOOP$\}$:$\{$LOOP$\}$) .EQ. "1" @@ exa19,000$\{$LOOP$\}$$\{$P2$\}$
ENDDO
!
! here the different sub-procedures
!
ENTRY 0001
!
CREATE/IMAGE
$\{$P1$\}$ 2,256,256 ? gauss 128.5,128,128.5,128
!
ENTRY 0002
!
READ/DESCR
$\{$P1$\}$
!
ENTRY 0003
!
STATIST/IMAGE
$\{$P1$\}$
  
Then, to read the standard descriptors of image frame luna.bdf we would enter the command @@ exa19 010 luna; to create the frame sol.bdf we enter @@ exa19 100 sol. Finally, in order to create a gaussian image estrella.spc, and read its standard descriptors and do the statistics on the newly created image, we type the command
@@ exa19 111 estrella.spc.
next up previous contents index
Next: Context Levels Up: MIDAS Command Language Previous: Interrupting Procedures
Petra Nass
1999-06-09