I'm new to Javascript, and I'm wanting to write a simple program that asks the user to state what it is they want calculated, "one plus one" for instance. Then I would like the program to store that information and use it as instructed.
I want it to be similar to a basic Python program, where the user asks is prompted and inputs their information from a command line. One of the technologies I've been using is node.js, and I would like to continue using it. From its API, I found the process object: http://nodejs.org/docs/v0.4.1/api/process.html I asked on #node.js in IRC, no one responded, then I sent an email to their mailing list on Google Groups, but their moderators must have blocked the message from going through which is disappointing, but I guess they aren't focused on helping new guys. The message wasn't nearly as long as this one, I'm just asking *all* the questions that come to my head for this message. Looking at http://nodejs.org/docs/v0.4.1/api/process.html#process.stdin you can see some example code for using stdin: process.stdin.resume(); process.stdin.setEncoding('utf8'); process.stdin.on('data', function (chunk) { process.stdout.write('data: ' + chunk); }); process.stdin.on('end', function () { process.stdout.write('end'); }); I understand line 2, but I'm confused about the rest, and was hoping someone might be willing to help me understand this. Also, from node- repl, you can type in process and then press enter to get a list of stuff. I don't know what you would call them, and I'm not quite sure how to manipulate all of them. It firsts gives you some environment information and then this: pid: 2233, execPath: '/home/adrian/bin/node', compile: [Function], _needTickCallback: [Function], reallyExit: [Function], chdir: [Function], cwd: [Function], getuid: [Function], setuid: [Function], setgid: [Function], getgid: [Function], umask: [Function], dlopen: [Function], _kill: [Function], memoryUsage: [Function], binding: [Function], EventEmitter: [Function: EventEmitter], assert: [Function], _tickCallback: [Function], nextTick: [Function], stdout: [Getter], stderr: { writable: true, readable: false, write: [Function], destroySoon: [Function], destroy: [Function], end: [Function] }, stdin: [Getter], openStdin: [Function], exit: [Function], kill: [Function], addListener: [Function], on: [Function], removeListener: [Function], debug: [Function], error: [Function], watchFile: [Function], unwatchFile: [Function], mixin: [Function], createChildProcess: [Function], inherits: [Function], _byteLength: [Function], _events: { SIGWINCH: [ [Function] ] } } I understand that you can use most of these, but I'm not sure how. I know stdin is used by typing process.stdin<something>. I also don't understand why stdin is not considered a function. Here's some more stuff that I don't understand how to use: > process.stdin { bufferSize: 0, fd: 0, type: null, allowHalfOpen: false, _readWatcher: { socket: [Circular], callback: [Function: onReadable] }, readable: true, _writeQueue: [], _writeQueueEncoding: [], _writeQueueFD: [], _writeQueueCallbacks: [], _writeWatcher: { socket: [Circular], callback: [Function: onWritable] }, writable: true, _writeImpl: [Function], _readImpl: [Function], _shutdownImpl: [Function], _events: { keypress: [ [Function] ], newListener: [Function: onNewListener], data: [Function: onData] } } > How do you use the functions, _readImpl and _writeImple for instance. _writeWatcher and _readWatcher both take two arguments that look like key:value pairs. Anyway, that's it for now. If someone has the time, I would greatly appreciate the help. -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
