Paulo,
thanks so much for your help. I've tried both your examples and I see the approach but am having pesky syntax problems:
!I make viewport names
define symbol v1 "ul"
define symbol v2 "ur"
define symbol v3 "ll"
define symbol v4 "lr"
! a simple trial
repeat/range=1:4/name=m ( \
set viewport v`m` ; \
plot obgc01[l=`m`:200]; \
)
___!-> REPEAT: M:1
!-> set viewport v1
**ERROR: invalid command: Unknown argument:v1
set viewport v1
Command file, command group, or REPEAT execution aborted
Is it $v`m` or $(v`m`) or ($v`m`)....? I can't get any variation to work (except, of course, to hard-code 'set viewport "ul"' in the loop).
I also tried the first example:
let vplist = {"ul", "ur", "ll", "lr"}
repeat/range=1:4/name=m ( \
set viewport `vplist[i=m]`; \
plot obgc01[l=`m`:200]; \
)
!-> REPEAT: M:1
**ERROR: command syntax: M
set viewport `vplist[i=m]`
Command file, command group, or REPEAT execution aborted
I tried all the variations of $ and `` I can think of with this one, too, and none work. Do you see what I'm doing wrong? I'm using version6.72.
thanks so much for helping a poor lost ferreter!
jenny
_____________________________________
From: Paulo Santiago [paulohsm@xxxxxxxxx]
Sent: Monday, September 17, 2012 5:54 PM
To: Whelan, Jennifer (CMAR, Aspendale)
Cc: ferret_users@xxxxxxxx
Subject: Re: [ferret_users] looping through viewports
Dear Jennifer,
Lets adopt a simpler example to illustrate. Suppose we have a variable with four timesteps (l=4), and we want to plot each timestep in a viewport. We do
vplist = {"ul", "ur", "ll", "lr"}
repeat/range=1:4/name=m ( \
set viewport `vplist[i=m]`; \
fill variable[l=`m`]; \
)
If you have more than four viewports, you'll have to define those viewports before use it. In this case, you can use numbered-sequenced viewport names, such as vp1, vp2, vp3, ..., vpN. This makes your life easier if you have to use these viewports inside a repeat loop, and you should simply use something like the example below.
repeat/range=1:N/name=m ( \
set viewport vp`m`; \
<plot commands>; \
)
Hope it helps.
Cheers,
Paulo Santiago
2012/9/17 <Jennifer.Abernethy@xxxxxxxx<mailto:Jennifer.Abernethy@xxxxxxxx>>
Hi,
i'm trying to write a ferret script that can plot varying-length timeseries in sections, i.e., for 40 years of monthly data make 4 plots, for 100 years of monthly data make 10 plots, etc. I can do most of this in a repeat/range loop, but the one part I can't figure out is how to loop through viewports. I just want to loop through an array, arr[1], arr[2], arr[3] arr[4], arr[1], arr[2], etc etc - at least, that's how I'd do it in other languages. I was wanting 4 plots/page, ul (upper left) ur, ll, lr.
something like this:
let f = {"ul","ur","ll","lr"} !how do I address the elements of this list?
let c =1 !montlhly data counter
repeat/range=`startyear`:`endyear-10`:10:name=m (let g = `c+120`; !120 months = 10yrs ; set viewport ???? ; plot data[`c`:`g`] ; label/nouser 0,4,-1,0,.15 Title Year `m` to `m+10`; let c=`g`)
frame/file=plots.gif
I was also wondering if after 4+ iterations of this loop that the resulting gif file will have multiple pages, or will the last 4 plots overwrite any previous ones?
thanks for any help you can give,
jenny
--
Paulo Santiago
Doutorado em Meteorologia
Programa de Pós-Graduação em Meteorologia
Instituto Nacional de Pesquisas Espaciais
Tel.: (12) 3186 8637