de en es fr
Let the machine help
Light teasing, exhibition, BDSM, sissyfication, watersports... with sounds and pictures


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Getting lines from a file into an array
PostPosted: Sun Nov 20, 2016 11:10 am 
Offline
Veteran
User avatar
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


Top
 Profile Send private message 
 
 Re: Getting lines from a file into an array
PostPosted: Sun Nov 20, 2016 11:28 am 
Offline
Veteran
User avatar
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;
}

_________________
Liz

You can't take something off the Internet - it's like taking pee out of a pool.
https://play-clan.site profile: Liz


Top
 Profile Send private message 
 
 Re: Getting lines from a file into an array
PostPosted: Sun Nov 20, 2016 12:57 pm 
Offline
Veteran
User avatar
Great, thanks! :D


Top
 Profile Send private message 
 
 Re: Getting lines from a file into an array
PostPosted: Sun Nov 20, 2016 1:13 pm 
Offline
Veteran
User avatar
I've found the Sex_cards script. Just the ticket 8-)


Top
 Profile Send private message 
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Maroon Fusion theme created by Oxydo
Software, theme modifications, phpBB modification by Doti 2010 - 2020
This website uses session cookies only.