Hi,
I believe the `zf=2` in Paulo's answer refers to the "width"
specifier. This a "zero-filled width" in embedded expressions.
http://ferret.pmel.noaa.gov/Ferret/documentation/users-guide/variables-xpressions/EMBEDDED-XPRESSIONS#_VPINDEXENTRY_572
The syntax is `zw=2`, though oddly, zf seems to work:
yes? let a = 5.3
yes? let var = "my variable`a`"
!-> DEFINE VARIABLE var = "my variable5.3"
yes? let var = "my variable`a,w=5`"
!-> DEFINE VARIABLE var = "my variable 5.3"
yes? let var = "my variable`a,zw=5`"
!-> DEFINE VARIABLE var = "my variable005.3"
Often for the most detailed control, these kinds of loops are the
way to go, but don't forget the native Ferret-like ways to define
variables. Expressions on the whole list is often best, while
writing loops should be the exception.
Variations on the theme:
yes? let First = xsequence({ "one", "two", "three"
})
yes? let Second= xsequence({ 1, 2, 3 })
yes? let zeros = xsequence({ "0","0","0"})
yes? let ssecond = floatstr( xsequence({ 1, 2, 3
}),"(f2.0)")
yes? let part1 = strcat(first,zeros)
yes? let third = strcat(part1, ssecond)
yes? list third
VARIABLE : STRCAT(PART1, SSECOND)
SUBSET : 3 points (X)
1 / 1:"one01."
2 / 2:"two02."
3 / 3:"three03."
where the formatting issue of the earlier thread comes back to get
us.
On 9/22/2015 7:38 AM, Paulo B. Oliveira
wrote:
Hi Marco,
One (quite dirty) way to use the very nice "ZF" option is to
create a variable definition using recursion, that is, to force
ferret to do something that's against its nature... (you must be
very careful with the use of single and double quotes)
let First = xsequence({ "one", "two", "three" })
let Second= xsequence({ 1, 2, 3 })
let third_def = "xsequence({"
repeat/i=1:`First,ret=iend` ( let third_def = "`third_def`
'`First`_`Second,zf=2`', " )
let third_def = "`third_def` 'last_not_used_item'})"
let third = `third_def`
list third
..... of course you can make it even dustier and use conditions to
exclude or remove the last closing element.
Regards,
Paulo
On Tue, 2015-09-22 at 15:34 +0200, Marco van Hulten wrote:
Hi Ferret users,
I wanted to apply Paulo's xsequence/repeat solution on string-integer
concatenation (to another problem that I will report on in a different
post), but I found a problem.
Le 2015-09-18 Paulo a écrit:
> let First = xsequence({ "one", "two", "three" })
> let Second= xsequence({ 1, 2, 3 })
>
> repeat/i=1:`First,ret=iend` ( let Third = "`First`_`Second,zf=2`" )
We want Third to be an array, but it will be a scalar here, having the
value of the last iteration. How can one force Third to be an array,
and the assignment to be one to the i'th array element?
Marco
|