procedure argument



a question regarding the usage of procedure arguments with different
argument lists.

the appended code compiles and writes out:

sub1: a= 1.0
sub2: a= 1.0 , b= 2.0

when i replace the two "EXTERNAL sub" statements by interface blocks

INTERFACE
SUBROUTINE sub (a,b)
REAL :: a,b
END SUBROUTINE sub
END INTERFACE

the compiler complains (as it should) about the different number of arguments of actual and dummy procedure.

why does it accept the EXTERNAL statements?

thanks,
roland


MODULE testmod
INTERFACE
SUBROUTINE sub1 (a)
REAL :: a
END SUBROUTINE sub1
END INTERFACE
INTERFACE
SUBROUTINE sub2 (a,b)
REAL :: a,b
END SUBROUTINE sub2
END INTERFACE
INTERFACE
SUBROUTINE process (sub)
EXTERNAL sub
REAL :: c=1.0,d=2.0
END SUBROUTINE process
END INTERFACE
END MODULE testmod

PROGRAM testprog
USE testmod, ONLY: sub1,sub2,process
CALL process (sub1)
CALL process (sub2)
END PROGRAM testprog

SUBROUTINE process (sub)
EXTERNAL sub
REAL :: c=1.0,d=2.0
CALL sub (c,d)
END SUBROUTINE process

SUBROUTINE sub1 (a)
REAL :: a
WRITE(*,*)'sub1: a= ',a
END SUBROUTINE sub1

SUBROUTINE sub2 (a,b)
REAL :: a,b
WRITE(*,*)'sub2: a= ',a,', b= ',b
END SUBROUTINE sub2
.



Relevant Pages

  • Re: Use of CallByName()
    ... Your call line is more universal than mine in that it will call a subroutine from any module in the workbook as long as the subroutine names on each module are unique. ... If you had, say, two subroutines named Sub1, one on Module1 and the other on Module2, your code line would error out unless the programmer specifically specified which Module's Sub1 he/she wanted. ... Sub testme() ... MsgBox "sub3" ...
    (microsoft.public.excel.programming)
  • Re: Use of CallByName()
    ... I don't disagree with you at all, that is for sure, but I do know there are programmers out there who will use the same subroutine name in different modules... ... For example, a programmer might create a module with routines for dealing with personal information and create a GetAddress subroutine there; then, 3 months later he/she might develop a module dealing with cell ranges and include a GetAddress subroutine there too. ... programmer specifically specified which Module's Sub1 he/she wanted. ... > End Sub ...
    (microsoft.public.excel.programming)
  • Re: Use of CallByName()
    ... Your call line is more universal than mine in that it will call a subroutine ... programmer specifically specified which Module's Sub1 he/she wanted. ... Sub testme() ... MsgBox "sub3" ...
    (microsoft.public.excel.programming)
  • Re: Memory problem with XML::DOM::Parser???
    ... >> # Die Anfrage ist Teil der neuen EPA ... # Modul für die XML-Funktionen des Clients ... # Subroutine, um die XML-Struktur aus dem XML-Rootfile und den ... sub construct_xml { ...
    (comp.lang.perl.misc)
  • Re: passing database data to a sub
    ... > I'm not sure of the difference, why isn't it a subroutine? ... > sure about this 'shift' thing anyway :-) ... > sub teardown ... > # Setup the template to use for the output. ...
    (perl.beginners)