View Single Post
Old 09-20-2016, 05:08 PM   #11
James HE
Human being with feelings
James HE's Avatar
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,430

wow, what a hard challenge it can be to translate what the jsfx help is telling you ha ha ha. It's funny (sometimes beautiful) how simple it is once you get it.

function file_to_numbered_strings(file,offset)local(handle)
//offset= starting string number
//returns number of lines read
  while( strlen(offset) && offset < 1023 )
    ( offset+=1;

so this breaks up each line in a txt file into numbered strings. From there, matching into variables should be fine.

Offset will generally be 0, but you never know - you might want to to chain these together for different files - just pass the returned offset to the next function call.

Note that there are 1024 slots for numbered strings, so I made this stop reading at that limit (cause I'm not sure what happens then). If you'd need to read war and Peace with JS, you could start stuffing the strings into memory - or to even serialize them, but for now, lets just keep it simple and assume 1024 lines is enough.

A different function could also parse the lines into a #NamedBigString - possibly adding newlines or some other character (or not) - and then you just get your variables from it. I would do that if I needed to serialize the string - or even if I needed to make sure some other function doesn't overwrite the numbered strings and i needed to preserve the slots (or pass it to another function later in the code - cause things get weird if you don't)

If you need anything else, let me know. I have EEL string functions that can chop up complex strings (i.e a track chunk) like a sou chef chopping an onion. (peek into my ReaLComps script files (the library that comes with it) if you want - most are in there)

Last edited by James HE; 09-20-2016 at 05:26 PM.
James HE is offline   Reply With Quote