Re: question on character-like variable defination



<meek@xxxxxxxxxxxxxxx> wrote:

In a previous article, "sunnylele" <sjsongjing@xxxxxxxxx> wrote:

in Fortran77, normally a variable to store a string can be defined as:
character file

Other have given the answer to your question, but I haven't noticed
anyone explicitly correcting the above misstatement. The correction is
implicit in the answers, but I'll make it explicit.

No, the above is not a way to declare a variable to store a string,
unless your definition of "string" is restricted to strings of length
exactly 1. The above is equivalent to

character*1 file

or

character file*1

whichever format you prefer. (To others: Yes, I know that the
character*1 form is obsolescent in f95/f2003, but that happens to be the
only obsolescent feature that I personally continue to use anyway.)

what does it mean by "character*30" and "character flags*5"
It's the new way - flags*5 means flags is character*5

I think you missed half of the question. The OP asked about both of
those forms - not just one of them. So explaining that one of the forms
that he doesn't understand is just like the other form that he doesn't
understand isn't likely to help him much.

But other folk gave the answer (that the numbers declare the length). I
suspect that the OP also doesn't appreciate that all f77 strings have
fixed length (except for assumed-length dummies), along with all the
implications of that. His incorrect presumption that "character file" is
how to declare a string suggests to me that he is thinking of
arbitrary-length strings. But that's getting off into questions not
asked, even if I suspect that they might be questions likely to come up
later.

--
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
.



Relevant Pages

  • Re: Public Variables
    ... I store the company name that is displayed on all my forms in a table. ... Is it not better to retrieve the company name at startup ... I declare the variable in a module but can not get a value ... Public Const CompanyName As String = "My Company Name" ...
    (microsoft.public.access.gettingstarted)
  • Difference between const and readonly
    ... I have a class where I store a lot of setting names. ... public const CurDoc as string = "CURRENT_DOCUMENT" ... wouldn't it be better to declare it as: ... public shared readonly CurDoc as string = "CURRENT_DOCUMENT" ...
    (microsoft.public.dotnet.languages.vb)
  • question on character-like variable defination
    ... normally a variable to store a string can be defined as: ... But how to interpret the following defination: ...
    (comp.lang.fortran)
  • Re: UnRAROCX.ocx and unrar.dll
    ... FileName As String * 260 ... Private Type RAROpenArchiveData ... Private Declare Function RARCloseArchive Lib "unrar.dll" (ByVal hArcData As ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Problem with passing parameter
    ... > 1) Your declare for WriteFile is incorrect. ... Since you're using strings you'd alias this API with an "A". ... > 2) You can *not* pass a variant, even if it's type is string, to an API ...
    (microsoft.public.vb.general.discussion)