Re: initializing an array of user-defined data types
- From: glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx>
- Date: Wed, 28 Nov 2007 12:55:31 -0800
Richard Maine wrote:
(snip)
if (board(i,j) == NULL) then
... do something ...
end if
What is this NULL thing you seem to expect? There is no such thing. The
only thing named NULL in Fortran is an intrinsic function that returns a
pointer or allocatable. Perhaps you are thinking that applies here
because your array is allocatable. That isn't so. The array is
allocatable, but the individual elements are not. You also don't have
the right syntax for NULL, as it is a function, but fixing the syntax
won't fit because the function isn't applicable here.
In C, some might use an array or pointers, assigning NULL to the
pointers for unused squares, and a pointer to the appropriate
structure for used squares. Someone used to doing that probably
wouldn't ask a question like the OP did, though.
The OP question reminds me more of they way interpreted
languages such as R or Mathematica are used. There are many
tricks that can be used that are not available in compiled languages.
Assigning zero to an appropriate structure element seems
like the right answer to me.
-- glen
.
- References:
- initializing an array of user-defined data types
- From: Bart Vandewoestyne
- Re: initializing an array of user-defined data types
- From: Richard Maine
- initializing an array of user-defined data types
- Prev by Date: Re: initializing an array of user-defined data types
- Next by Date: Re: initializing an array of user-defined data types
- Previous by thread: Re: initializing an array of user-defined data types
- Next by thread: Re: initializing an array of user-defined data types
- Index(es):
Relevant Pages
|
|