Reading from a file in a script

Stegert stegert at IFM.UNI-HAMBURG.DE
Thu Oct 16 14:01:26 EDT 2008


Dear Zilore Mumba,

As far as I know grads expects to put the information
from READ into a file, i.e.
var = read(date_file.txt)

should work followed by
say sublin(var,2)

The same is with the CLOSE function which should be
dum = close(date_file.txt)
(dum is not further needed but must be used to
avoid an error).

Best regards,
Christoph

zilore mumba schrieb:
> Help sought please,
> I have a file generate by a perl script, containing only the current
> date, written as, e.g.: 16/ 10/ 2008.
>
> I am trying to read from this file in my grads script. Here is the
> script I wrote:
> read(date_file.txt)
>
> say sublin(result,2)
>
> Day=sublin(result,2)
> Month=sublin(result,3)
> Year=sublin(result,4)
>
> 'draw title Valid on:  'Day' 'Month' 'Year
>
> According to the Grads documentation, the first record of this read
> statement is a return error, and I can recover the records from 2 and
> repeatedly reading for subsequent records.
>
> I do not get beyond the first line of my script, geeting error 1, which
> is an open error.
> I have not seem a single script which reads from a file.
> Does the read function actually work, or where is my error?
>
> Assistance appreciated
> Zilore Mumba
>
>

--
Christoph Stegert:  Ecological Modelling group
Institut für Meereskunde - Universität Hamburg, Germany
Zentrum f. Marine u. Atmosphärische Wissenschaften ZMAW
Bundesstr.53, 20146 Hamburg - Phone: +49-40/ 42838-7486



More information about the gradsusr mailing list