![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: Mar 2006
Posts: 120
Rep Power: 3
![]() |
problem with a function
Hi I need to wirt a function in frtran77 that does the following:
integer function delete(id, list, n) where • delete returns 0 if the deletion was successful, -1 if the list is empty, and -2 if the user is not currently in the list. • id is the integer identification number of the user. • list is the integer array from which the id is to be removed. • n is the current length of the list. I have wrote the code integer function delete(id,list,n)
integer id,indexe,n,list(n)
integer delete,nempty,idx,m
delete=-100
nempty=0
do 1000 idx=1,n
if (list(idx).EQ.101) then
nempty=nempty+1
end if
if (list(idx) .EQ. id) then
delete=0
indexe=idx
do 30 m= indexe,n - 1
list(m) = list(m+1)
30 continue
n = n-1
end if
1000 continue
if (delete .EQ. 0) then
return
end if
if (nempty .eq. n) then
delete=-1
return
end if
delete=-2
return
endThe way I call it in main is integer p
.......
else if(option.EQ.'DU') then
write(6,*)'delete user',A
p=delete(A,list,hh)
write(6,*)'value of delete*',p
.................When I compile I have the following message *** FUNCTION 'DELETE' returns a INTEGER(KIND=3) but has been called as if it returns a REAL(KIND=1) (from the main program) I dont know why. Please can someone help me please B. |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Please show your "main" function. If it's too large, zip and attach it.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#3 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,260
Rep Power: 5
![]() |
Add a line "integer delete" to the set of declarations at the top of your main function. Optionally you might also wish to add a line "external delete" before that line. Essentially these are about telling the compiler that delete is a function that returns an integer (it will assume the function returns a REAL otherwise), which is what the error message is suggesting. The potential need for these does not change by simply having the function delete in the same source file.
|
|
|
|
|
|
#4 |
|
Hobbyist Programmer
Join Date: Mar 2006
Posts: 120
Rep Power: 3
![]() |
yeah , the message is gone.
Thanks |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|