grads scripting question

Sestak, Michael L CIV 63134 michael.l.sestak at NAVY.MIL
Mon Apr 6 18:25:11 EDT 2009


You cannot use the scripting language "if" with grads variables, only with script variables.

However, if you do all you the set x, y, z, t, then display your stationID variable 'd stationID' the value of the grads variable at that set of coordinates will be displayed as text in your command window.  In a script, it works a little differently.  Instead of being displayed in the command window, the variable value is saved in a script variable with the name result.  Since this is a script variable, you can use the if with the script if statement.  Thus

'set t 1'
'set x 1'
'set y 1'
'set z 1'
'd stationID'
if (result=101) 
'draw string 1 1 Pascagoula'
endif

if (result=201) 
'draw string 1 1 Agricola'
endif

By the way, not the quotes around the set commands.  Any grads command must have quotes around it in a script.

Michael Sestak
Fleet Numerical Meteorology and Oceanography Center
Monterey, CA



From: Sytske Kimball
Sent: Mon 4/6/2009 15:11
To: GRADSUSR at LIST.CINECA.IT
Subject: grads scripting question


Dear grads users,

I want to perform an action (write out a name) depending on the value of a grads data variable.
In other words, I have a grads data file that contains a code number for the name of a location.
In my control file I have the variable stationID and I want to do the following:

set t 1
set x 1
set y 1
set z 1

if (stationID=101) 
'draw string 1 1 Pascagoula'
endif

if (stationID=201) 
'draw string 1 1 Agricola'
endif

The above does not work, can anyone tell me how to do this?

Thanks in advance,
Sytske

Sytske Kimball
Associate Professor of Meteorology
Dept. of Earth Sciences
University of South Alabama
Mobile, AL
phone (251) 460-7031
fax        (251) 460-7886
email   skimball at usouthal.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20090406/175b7ffa/attachment.html 


More information about the gradsusr mailing list