How to I make a console based application with I/O.
1 Attachment(s)
Attachment 9891I'm working on a project that is text based that runs in the terminal. I'm working on the script on actions and reactions but I need to know what should I program it in. All it needs to do is Print a question or comment on the screen, allow the user to input a text like A1, A2 that will redirect the user to a action and possibly access different files for answers to some questions. It's going to be like a console based or terminal based application that talks to its users with limited commands. I need to know what programming language should I use, I have difficulty with Python I don't know why.
I always here it is the easiest programming language to learn but every time i try something goes wrong. It is to annoying, or not compatible with my current version which is Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2 Any other good programming language, would bash be good for this type of idea, maybe ruby or perl, I'm not even close to advanced enough for C# or C++ and it is completely terminal based. Picture is kinda example of the kinda of interface I want but not the general idea only the interface and Input output ability |
There is no correct answer to your question!
Personally, I'd find out if Bash provides enough functionality. I'd prefer an interpreted "script" language over a compiled one, since these kinds of programs tend to evolve over time, and having it be trivial to fix issues or add new features is extremely useful. I'd start with Bash, simply because I've done a lot of similar stuff with Bash, and it seems to fit. To show you how simple similar stuff is in Bash, here is a commented version of guess-the-number game: Code:
#!/bin/bash Code:
VALUE=$( awk -v min=$MIN_VALUE -v max=$MAX_VALUE 'BEGIN { srand(); printf("%d\n", min+int(rand()*(max-min+1))) }' ) Other details that come very handy with command-line scripts are ANSI escape sequences. For example, I like to output important error messages in red: Code:
message="Some error message" Code:
if ( stty &>/dev/null ); then Code:
if ( stty &>/dev/null ) <&1 ; then |
If your terminal application needs to be platform-independent then I would probably prefer Python or Java (maybe a bit of a overkill) over a simple bash script.
What are your issues with Python? |
All times are GMT -5. The time now is 05:29 AM. |