Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling functions

Status
Not open for further replies.

Samohtvii

Programmer
Aug 2, 2012
21
AU
I thought calling a function seemed easy enough until i tried to write one.
I though it was as easy as:

program test
testFunction()
end program test

FUNCTION testFunction()
print *, "Hello World"
END

EDIT:
ok so why does below work. I just want a function that makes my code cleaning. No passing variables, no return type or anything

program test
REAL s
s = testFunction()
end program test

FUNCTION testFunction()
print *, "Hello World"
END

THanks
 
A function returns a value, a subroutine doesn't. The first example is incorrect as it should be a subroutine. In the second, the function is not returning a value.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top