for me, text is "exit\n"
I guess you are on windows, so text is "exit\r\n"
The readline module might help you.
On 08/02/2012 04:15 PM, Danil Gazizov wrote:
I'm confused of how to compare string const with variable.
Look at this simple example where keyboard input compares with const
string.
I suggest this is encoding problem. Please, tell me what should be
done to exit process ?
File encoding is utf8
process.stdin.setEncoding();//default is utf-8
process.stdin.resume();
process.stdin.on("data", function(text) {
//shows entered length=*6*
console.log('entered length=' + text.length);
//shows compare length=*4*
console.log('compare length=' + 'exit'.length);
if (text == 'exit'){
//never works
console.log('matched!');
}
});
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en