grads scripting question

Sytske Kimball SKimball at USOUTHAL.EDU
Tue Apr 7 12:47:07 EDT 2009


Hi Michael,
 
Thanks for the suggestion. I wrote my script exactly as you indicated below (including the quotes)
but it still doesn't quite work. So I performed some tests, first by adding a
 
  say result
 
statement and the right value appears in my command window. I also checked that there were no errors 
in my draw string command by taking it out of the if - then loop. And it works fine. Anything else I'm missing?
 
Thanks again in advance,
Sytske

>>> "Sestak, Michael L CIV 63134" <michael.l.sestak at NAVY.MIL> 4/6/2009 5:25 PM >>>
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/20090407/b171ef11/attachment.html 


More information about the gradsusr mailing list