We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Processing to txt and txt to processing
Page Index Toggle Pages: 1
Processing to txt and txt to processing (Read 1439 times)
Processing to txt and txt to processing
Apr 21st, 2010, 7:44am
 
hello,
I want to make something with txt files.
I have already use the function println to writte in the txt file whit processing. (I've a question about that; can I oblige the .txt to not go to the begin of the line between two "println"?)

and my other question is ; can I make a program who read a txt program and make action who is command by the letters into the txt?
(Im sorry my english is not very good, but I hope You anderstand my questions)

thanks!
Re: Processing to txt and txt to processing
Reply #1 - Apr 21st, 2010, 8:03am
 
bolendo wrote on Apr 21st, 2010, 7:44am:
I've a question about that; can I oblige the .txt to not go to the begin of the line between two "println"
print()...

Quote:
can I make a program who read a txt program and make action who is command by the letters into the txt
Yes.
See loadStrings().
Re: Processing to txt and txt to processing
Reply #2 - Apr 21st, 2010, 8:12am
 
ah!
thanks it's look easy^^
Re: Processing to txt and txt to processing
Reply #3 - Apr 22nd, 2010, 9:21am
 
ok I m using loadstrings but I want know how can I, for example go to my 2nd letter from my line 3?
how can I find the command who can be use with loadstrings?
Re: Processing to txt and txt to processing
Reply #4 - Apr 22nd, 2010, 10:10pm
 
Search String Functions in the reference.
And String reference, which mentions other methods, particularly substring().
Re: Processing to txt and txt to processing
Reply #5 - Apr 23rd, 2010, 1:40am
 
okay, now the problem is, I can't use strings function because I dont't now how to convert  "string[]" to "string".
I want to use "charAt(int)" but it isn't compatible with a "string[]" how can I convert?
Re: Processing to txt and txt to processing
Reply #6 - Apr 23rd, 2010, 1:55am
 
Look at Array reference.
And, well, perhaps take a look at the Learning section too...
Re: Processing to txt and txt to processing
Reply #7 - Apr 26th, 2010, 1:39am
 
Yes thank, but my first problem to anderstand all the learning section is my english.
I must to finish my project early, I've not understand with the array reference, I'm lock. Just can you say me the code to recup the letter 3 line 2 from a txt to my processing program and writte something like
"if ((letter3line2)=="a")..." and make conditionnal with this element...
very thank you to help me
Re: Processing to txt and txt to processing
Reply #8 - Apr 26th, 2010, 1:56am
 
String [] allStrings = loadStrings( "filename.txt" );
String secondLine = allStrings[1];
char thirdLetter = secondLine[2];
if( thirdLetter = 'a' ){
//...
}
if( secondLine.equals( "boat" ) ){
//...
}
Re: Processing to txt and txt to processing
Reply #9 - Apr 26th, 2010, 3:45am
 
Thanks: that say me: The type of the expression must be an array type but it resolved to String

char thirdLetter = secondLine[2]; is overline!

Re: Processing to txt and txt to processing
Reply #10 - Apr 26th, 2010, 5:48am
 
> char thirdLetter = secondLine[2];

It doesn't work in Java...

> if( thirdLetter = 'a' ){

It doesn't work either, as you make an assignment... Smiley

That would be:
Code:
String thirdLetter = secondLine.substring(2, 3);
if (thirdLetter.equals("a")) println("That's the one!");
Page Index Toggle Pages: 1