SexScripts : Getting lines from a file into an array - https://ss.deviatenow.com:443/viewtopic.php?f=4&t=658 | Page 1 of 1 |
Getting lines from a file into an array |
arthurb [ Sun Nov 20, 2016 11:10 am ] |
---|---|
Hi, I'd like to be able to populate an array with lines from a file. Just simply have each element in the array be a string with from each line from the file. This is so I can say make a drop down list from it or pick a random line. Can you help me with how to do this? Thanks arthurb |
Re: Getting lines from a file into an array |
Liz [ Sun Nov 20, 2016 11:28 am ] |
---|---|
Both the sexcards and subcontrol-control scripts do this. if you don't find it will dig out a quick example tomorrow... but this is a bit from subcontrol task editor... Code: def f1 = new File(fname)
def lines = f1.readLines() def List<String> TaskList = [] def i=0; lines.each { def Title = it.tokenize('[')[0] TaskList.add(Title.tokenize(']')[1]); i=i+1; } |
Re: Getting lines from a file into an array |
arthurb [ Sun Nov 20, 2016 12:57 pm ] |
---|---|
Great, thanks! |
Re: Getting lines from a file into an array |
arthurb [ Sun Nov 20, 2016 1:13 pm ] |
---|---|
I've found the Sex_cards script. Just the ticket |
Page 1 of 1 | All times are UTC + 1 hour [ DST ] |