Re: HELP ME - HOW THIS ERROR?
- From: Richard E Maine <nospam@xxxxxxxxxxxxx>
- Date: Thu, 30 Jun 2005 09:08:01 -0700
In article <XsUwe.30358$yM4.457964@xxxxxxxxxxxxxxxxxx>,
"WindCina" <windcina@xxxxxxxxx> wrote:
> error 250 - You cannot assign an expression of type REAL(KIND=1) to a
> variable of type TYPE(LISTA)
>
> h = RicercaParola(vett(k),parola); <-error is here
You haven't shown enough context to know with absolute certainty... but
there is enough for me to make a pretty good guess.
It probably isn't known *IN THE SCOPE OF THE ABOVE STATEMENT* that
function RicercaParola returns something of type Lista. If the function
is an external function, that information isn't "magically" known to
anything that references the function. There are lots of ways to make
this known. I generally recommend making all procedures module
procedures, in which case the USE statement for the module brings this
information in.
You also have other problems here. I didn't take the time to study this
carefully, but 2 things jump right out at me.
1. The function requires an explicit interface (because it returns a
pointer, which is one of the many things that can trigger such a
requirement). Just declaring the return type won't be enough. This is
yet further argument for making it a module function.
But, *MOST IMPORTANTLY*
I strongly recommend against using functions that return pointers. Use
subroutines instead. I've had to repeat this advice several times
recently. I don't think you were one of the people I formerly gave it to.
Functions that return pointers are *VERY* error prone. Even experts are
likely to get them wrong. Your code has one of the more common major
errors. I'm not even going to bother to point it out because I feel that
this would be counter-productive - it would just encourage you to try to
fix the one case... and you'd make another error elsewhere. This is not
intended as a personal aspersion - as I said, experts make these errors.
The best solution is to use subroutines, which aren't as prone to the
same errors. (Of course, one can make errors with about anything, but
functions that return pointers are especially prone to it).
--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain | experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
.
- References:
- HELP ME - HOW THIS ERROR?
- From: WindCina
- HELP ME - HOW THIS ERROR?
- Prev by Date: Re: I have no ideas what can it be!
- Next by Date: Re: backslash-issues
- Previous by thread: HELP ME - HOW THIS ERROR?
- Index(es):
Relevant Pages
|