Forum: Cfengine Help
Subject: Re: How to extract values (not keys) from an array to slist?
Author: sauer
Link to topic: https://cfengine.com/forum/read.php?3,21174,21175#msg-21175

Mike Svoboda Wrote:
-------------------------------------------------------
> So, I can use getindexes() to extract the indexes
> of an array into an slist.  I need to do the
> opposite, and extract just the values.  Anyone
> have a working solution?
> 
> I just need to be able to create an slist with all
> of the values of the array.

Without the ability to append to a list (or a scalar, for that matter), the 
only way I can see to do that would be to iterate over all of the list 
elements, use a method to append each of them to a file, then use the class set 
by the method when it's done to read that file back in to an slist using one of 
the file reading functions.  And then go home and futily attempt to wash the 
dirty, dirty feeling away.

Presuming, of course, that you actually need an slist (for something like a 
join or a grep) and you can't just directly iterate over the array using the 
index list.

_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to