[Thread Prev][Thread Next][Index]

Re: [ferret_users] Define, change/add/remove element in an array.




Hi,

You can update listTemp in the way Nicolas wants but you have to be careful. Also, as Ashkay points out you can't update a single value in the way shown.

let  listTemp={`temp5`,`listTemp[i=2]`,`listTemp[i=3]`,`listTemp[i=4]`}

works and avoids the recursion problem since  old values of listTemp are evaluated first before the new variable is created.

I think a better approach is to create a string variable/symbol for your base command and use the string functions (or even better use the SPAWN features to invoke sed or some scripts (shell/perl/python) to make changes).

Russ



On 20/08/14 15:47, Akshay Hegde wrote:
listTemp[i=1] = `temp5 is not valid in Ferret. The left-hand side of a definition is always a simple variable name.

--
Akshay Hegde,                                    
Forum Advisor                                       
The Unix and Linux Forum Users                    
http://www.unix.com                              
http://in.linkedin.com/pub/akshay-hegde/59/b3/b1b




On Wed, Aug 20, 2014 at 10:54 AM, Nicolas Freychet <nicolas.freychet@xxxxxxxxx> wrote:
Hi everyone,

Is there a simple comand to change/add elements inside an array.

For instance, I defined a single row array with :

         let listTemp = {`temp1`,`temp2`,`temp3`,`temp4`}

But then, I'd like to add new values `temp5`, `temp6`.... or change `temp1` to a new value.
I tried something like : "listTemp[i=1] = `temp5`" but it doesn't work.

If anyone knows how to do it....

Thanks,
Nicolas



[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement