Queue to text file

jersmi's picture

I have a Queue outputting from an Iterator, shows in Viewer as QCStructure. How can I save the list of index members as a text file with each member on a separate line?

PreviewAttachmentSize
queue_to_string.qtz8 KB

Swiftlikeninja's picture
Re: Queue to text file

I made one small change to your structure and added a javascript patch I stumbled across on this site. I added a line break to the queue and the javascript will flatten the queue into a single string. The Javascript patch could be made to add the line break instead of the string printer but this was the quicker way for me to get something together. After this if you want to write these to a file then I believe Kineme has a text file writer to write the string to a text.

PreviewAttachmentSize
queue_to_string.qtz7.92 KB

jersmi's picture
Re: Queue to text file

Perfect solution, thanks a lot!

usefuldesign.au's picture
Re: Queue to text file

Hmm those look a lot like variable names I used to use.

That code has a lot of redundancies. Here it is with line breaks and cleaner.

function (__string Out) main (__structure StructIn)
{
    var    result = {},
        msg = "";
    if (StructIn)
    {
        for (i in StructIn)
        {                
            msg += StructIn[i]+"\n";
        }
    }
    result.Out = msg;
    return result;
}

Have a link to where you found the code I'll fix it up there too if necessary?

PreviewAttachmentSize
queue_to_string.qtz8.27 KB

Swiftlikeninja's picture
Re: Queue to text file

I'm not certain if its your code or monobrau's but i was able to drum up the original post. It looks like I repurposed a javascript key from structure patch to make a structure to string patch and just left some of the legacy code in there. Thanks for cleaning up the code.

http://kineme.net/forum/Discussion/DevelopingCompositions/Gettingkeystru...