Leading the way to the Future
Welcome Guest, Login!
16 Jun 2010 06:04:10 pm by bsl
The standard file handles STDIN, STDOUT, and STDERR, are already open on the TI-Nspire .
It was a matter of a little detective work finding them.
All 3 are directed to RS232 however.

The attachment has a hand coded CAS and NONCAS proof of concept program for these handles.
The result you should get on the emulator console is:
Code:

TERMINAL> Is fgets working ?       // I entered "Is fgets working ?" and hit return
You entered:Is fgets working ?

TERMINAL>

The equivalent C program should look like this(pseudo code):
Code:

/*  terminal.c (noncas version) */

int main(void){
FILE *stdin,*stdout,*stderr;
char buffer[32];
 stdin = (FILE *) 0x105bb5f0;
 stdout = (FILE *) 0x105bb63c;
 stderr = (FILE *) 0x105bb688;
 printf("TERMINAL> ");       // terminal prompt
 fgets(buffer,32,stdin);     // get user input
 printf("You entered:%s\nTERMINAL> ",buffer);
 return 0;
}

IDEA: Include a while loop above to make a real terminal program that processes strings for commands.

printf is usefull for debugging messages to the console.
fgets used in this way can be used in development to change execution of a program during development.

The attachment also contains CAS NONCAS handle definitions and fgets definition for os.h

[attachment=3194:StdFileHandles.zip]
16 Jun 2010 08:16:26 pm by bwang
Excellent Smile