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


Post new topic Reply to topic  [ 11 posts ] 
Author Message
 can SexScript read/write from/to other text files?
PostPosted: Fri Jan 13, 2012 5:39 am 
Offline
Regular
can SexScript read from other text files? Is it inherent all functions of Groovy?


Top
 Profile Send private message 
 
 Re: can SexScript read/write from/to other text files?
PostPosted: Fri Jan 13, 2012 10:33 am 
Offline
Site Admin
User avatar
Yes, I'll show you some code, but a lot of different things can be done. Which kind of text files are you thinking about ? Plain text ? .ini ? .xml ? .html ? ...


Top
 Profile Send private message 
 
 Re: can SexScript read/write from/to other text files?
PostPosted: Sat Jan 14, 2012 11:23 am 
Offline
Regular
txt and ini files please...
Thanks!


Top
 Profile Send private message 
 
 Plain text files
PostPosted: Sat Jan 14, 2012 1:06 pm 
Offline
Site Admin
User avatar
Here is some code to write into a text file, then read from it
Code:
//write 2 lines
def fo = new File("test.txt")
fo.write("first line")
fo.append(System.getProperty("line.separator"))
fo.append("second line")

//read and show all lines
def fi = new File("test.txt")
def lines = fi.readLines()
//"lines" is now a full list, use as you want
for(def line : lines) {
   show(line)
   wait(1)
}


NB for specialist : I always avoid closures, I find them too complex for SexScripts.


Top
 Profile Send private message 
 
 Ini files
PostPosted: Sat Jan 14, 2012 1:23 pm 
Offline
Site Admin
User avatar
Here is some code to write into a windows .ini file, then read from it
Code:
//write 2 lines in a section
def fo = new org.ini4j.Wini()
fo.put("section1", "key1", "value1")
fo.put("section1", "key2", "value2")
fo.store(new File("test.ini"))

//read those 2 values
def fi = new org.ini4j.Wini(new File("test.ini"))
show(fi.get("section1", "key1") + " "+fi.get("section1", "key2"))


Easy ? Send a thank you message to people behind ini4j


Top
 Profile Send private message 
 
 Re: can SexScript read/write from/to other text files?
PostPosted: Sun Jan 15, 2012 4:54 am 
Offline
Regular
yes, looks easy. Thanks.

Where can I learn the comprehensive tutor of this language? is it all same to groovy?


Top
 Profile Send private message 
 
 Re: can SexScript read/write from/to other text files?
PostPosted: Sun Jan 15, 2012 10:31 am 
Offline
Site Admin
User avatar
Yes, above code is main Groovy.


Top
 Profile Send private message 
 
 Re: Plain text files
PostPosted: Tue Mar 19, 2013 5:55 am 
Offline
Veteran
User avatar
doti wrote:
Here is some code to write into a text file, then read from it
Code:
//read and show all lines
def fi = new File("test.txt")
def lines = fi.readLines()
//"lines" is now a full list, use as you want
for(def line : lines) {
   show(line)
   wait(1)
}

Is it possible to just have SexScripts display just one (specified) line from a text file?


Top
 Profile Send private message 
 
 Re: can SexScript read/write from/to other text files?
PostPosted: Tue Mar 19, 2013 9:11 am 
Offline
Site Admin
User avatar
Because the line can have any size, you must read the full file, at least to the line you search. So add a numeric variable to count the lines.
Example showing the 4th line :
Code:
def n = 0
for(def line : lines) {
   if(n==4)
      show(line)
   n++
}


Top
 Profile Send private message 
 
 Re: can SexScript read/write from/to other text files?
PostPosted: Sun May 05, 2013 11:24 pm 
Offline
Active member
i'm not a coder, But if you want one specific line, Can't you use the ini file and have the line be a value and you call it with the key?
Maybe use sections to have different subjects.
Then it doesn't need to read the whole file. Just grab value from key.

Doti, is there a reason why you didnt define the file name at the start when writing to the file but only later in the store bit?


Top
 Profile Send private message 
 
 Re: can SexScript read/write from/to other text files?
PostPosted: Mon May 06, 2013 7:35 pm 
Offline
Site Admin
User avatar
0385 wrote:
i'm not a coder, But if you want one specific line, Can't you use the ini file and have the line be a value and you call it with the key?
Maybe use sections to have different subjects.
Then it doesn't need to read the whole file. Just grab value from key.


Yes (it'll work only with a ini file, not any text file)

0385 wrote:
Doti, is there a reason why you didnt define the file name at the start when writing to the file but only later in the store bit?

Not really, I think it works anyway, like this :
Code:
//write 2 lines in a section
def fo = new org.ini4j.Wini(new File("test.ini"))
fo.put("section1", "key1", "value1")
fo.put("section1", "key2", "value2")
fo.store()


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

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 5 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:  


cron
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.