Re: Declaration of variables in IDL [message #26883 is a reply to message #26881] |
Wed, 03 October 2001 09:10   |
R.G.S.
Messages: 46 Registered: September 2000
|
Member |
|
|
Hans de Boer <boer@kfih.azr.nl> wrote in message
news:3BBB0EC8.1CCB5E11@kfih.azr.nl...
> Hi there,
>
> I have been working with IDL for quite a while now, but never
> encountered a way of fixing variable types in IDL. Especially when
> adding new variables to old pieces of code, it can be very confusing if
> a variable of that name was already in use. IDL simply changes the
> variable type (including changes of array dimension) if required and
> possible. If not possible, you are the lucky one to get run-time errors,
> but if possible, the code seems to run quite nicely and the poor
> programmer is left with apparently correct results.
> I also have found that people new to IDL have generated extremely sneaky
> bugs this way.
> Does anybody know of making IDL performing an explicit variable check
> during compilation ?
>
> Thanks
>
> Hans deB
As answered, IDL allows type changing. Such is life.
This may be too simple to help you, but your function can
explicitly check variable type. For instance:
function foo_wrapper,dnumber,fnumber,stringvar
if size(dnumber,/type) ne 5 then message,'ERROR: DNUMBER type changed or
undefined.'
if size(fnumber,/type) ne 4 then message,'ERROR: FNUMBER type changed or
undefined.'
if size(stringvar ,/type) ne 7 then message,'ERROR: STRINGVAR type changed
or undefined.'
return,realfunction_foo(dnumber,fnumber,stringvar)
end
Cheers,
bob
|
|
|