Click to See Complete Forum and Search --> : NB progaming: Need help making a simple program.
MacTown06
06-02-2004, 02:08 PM
I know linux pretty well, I have been into it for a couple months. I have been wanting to get into programing, C ++ has always interested me. But to make it clear: I currently know nothing about programing.
Anyways, here's what I want...
I want to write a program that is just a list. When you start the program I want a list of program names, then you scroll through them. when you select one it launches that program.
I want it to look like the xwmconfig that came with slackware (picture below). and i want to make it so the names of the programs are not accutially related to the commands they launch.
If you have any tips at all please post, I dont know anything.
hammer123
06-02-2004, 02:38 PM
trying to run before you can walk eh? I did that.
Ok that menu appears to have been made using the ncurses library. I know it can be used with C, C++ and bash scripts. You need to learn a language first.
Dark Ninja
06-02-2004, 02:54 PM
My recommendation would be to start with Java -- it's much easier to learn than C++ (IMO) and avoids some of the pitfalls that catch newbie programmers when learning C++.
Plus...the documentation for Java is through the roof. :p Just a suggestion.
maccorin
06-02-2004, 03:46 PM
Originally posted by Dark Ninja
My recommendation would be to start with Java -- it's much easier to learn than C++ (IMO) and avoids some of the pitfalls that catch newbie programmers when learning C++.
Plus...the documentation for Java is through the roof. :p Just a suggestion.
Why do people find it necessary to say "I recommend you try <X> language instead"... he said he wants to know C++, posting a jab for java instead is useless. C++ isn't my favorite language either, but that wasn't his question was it?
to the OP:
I think hammer123 hit it on the nail, you may wanna grab a c++ book first and go through it, _then_ you should learn ncurses, and at that point you should have enough knowledge to do what you want to do.
hammer123
06-02-2004, 04:06 PM
Originally posted by maccorin
Why do people find it necessary to say "I recommend you try <X> language instead".
Dark Ninja may be a fine contributor to this forum but he likes to spam threads with support for a language people have to download runtimes for but can't get source for.
If you want C++ I have heard people recommend Stroustrup's book since he made the language. I have not looked at it much though and don't know if it is for non programmers, how about starting with a Tutorial to learn the syntax. I have looked at the free online book "Thinking in C++" and thought it was incredibly slow paced and used very strange examples.
MacTown06
06-02-2004, 05:23 PM
thanks to all...
I guess i was getting a little ahead of myself. Its cool though, I will be back! Give me a couple months (or so) and i will bring this form back with more specific questions.
evac-q8r
06-02-2004, 05:35 PM
Originally posted by hammer123
Ok that menu appears to have been made using the ncurses library.
Actually this was done using dialog. It is an extremely easy to use interface which can even be typed in at the command line so that it may be incorporated within script if need be. There is also something called xdialog which allows you to create menus as well. It gives you more of a GUI feel rather than the text mode if your interested. The regular dialog application is probably an extension to the curses library in some form or fashion, but they allow you create calendars, checklist, gauges, menus, radiolist, message boxes all similar to the ones in Xconfigurator if you're familiar with this (and no prior experience with programming is necessary). Look in the man pages for assistance. Try a GOOGLE search as well.
Again you can create this using ncurses, but you'll need to be at least an average to advanced programmer.
EVAC
Dark Ninja
06-02-2004, 05:35 PM
Why do people find it necessary to say "I recommend you try <X> language instead"... he said he wants to know C++, posting a jab for java instead is useless. C++ isn't my favorite language either, but that wasn't his question was it?
Haha, okay, you have a point. Yes, I was just going off the fact that the "C" languages (++ or otherwise) are a pain. I was just figuring it might be okay to start out with something where he wouldn't have to worry about pointers/references/and the like would make the introduction a lot easier.
Dark Ninja may be a fine contributor to this forum but he likes to spam threads with support for a language people have to download runtimes for but can't get source for.
Now hold on here! Get your facts straight. I wouldn't consider it spam. I was honestly trying to help him based on my own experiences. I personally had crazy issues with C++, and practically gave up on programming because of it. If he really wants to learn C++, he's not going to listen to me anyway. However, I only base my answers to ANY question off what I know -- and that is why I recommended Java. I picked that up in a matter of a couple weeks...and for the first time I also truly understood the OO paradigm.
(BTW - Not angry or anything. I guess that kinda was spam...just saying...I'm trying to help. That's all.) :rolleyes:
Anyway, good luck with the C++, MacTown06.
bwkaz
06-02-2004, 05:52 PM
C is great. C++ is baroque (or worse). If you need OO, then Java might be an alternative (though the majority of the time, you don't really need OO). Or Python (it's OO is pretty decent).
IMNSHO, anyway...
Of course, if you want to learn C++, then feel free. ;)
maccorin
06-02-2004, 06:02 PM
Originally posted by bwkaz
C is great. C++ is baroque (or worse). If you need OO, then Java might be an alternative (though the majority of the time, you don't really need OO). Or Python (it's OO is pretty decent).
IMNSHO, anyway...
Of course, if you want to learn C++, then feel free. ;)
that pretty much sums up my viewpoint as well, although... i tend to write my OO software in C as well (if you say it can't be done, you should be shot ;p) (and would prolly use C++ before java...), but for a beginner C is _not_ the language to learn OO w/
python is prolly the best scripting language that _I_ know for OO, perl rules, but it's OO syntax is fugly.
knute
06-02-2004, 06:47 PM
Hey MacTown,
Let me give you a little heads up since you say you have no programming experience.
The very first thing that you need to learn before you set out learning a language is to start thinking like a programmer. Just because you have a book of commands, don't mean that you know how to use them.
It looks like you have a start on what it is that you want to do, so to start out, you have your problem that you want to solve. The next step, before you choose language and china patterns is to break that problem down into the steps needed to solve that problem, then to break them down until you know everything that has to be done.
Now, you are ready to choose a language to do what you want.
Oh yeah, and breaking the process down is easier if you keep in mind the 3 steps necessary to any program (input, process, output (in that order)).
Now, I've only given you an overview of the steps necessary to begin programming before you go into the intracies of a programming language.
Now, I know that it sounds like it's massive, but after you get some experience it becomes easier, which is why everyone that's posted till now has skipped it, because for one it's boring, and can be done with a pencil and piece of paper!
Trust me on this when I say, that you can completely ignore what I've said here, but know that you will have made your programming task that infinately much harder.
HTH
maccorin
06-02-2004, 06:50 PM
i've got a list of tips for coding newbies at
http://maccorin.homelinux.org/?page=tips
MacTown06
06-03-2004, 11:01 PM
okay, well I am following through. Pardon me if anything I say is stupid, its just because I dont know any better....
Well, I figured the easyest way to get into program is script files, just making a text file that is a list of commands. So I started doing research on how to make a script file do what I wanted it to do (that list of programs thing) and this is what I have so far:
dialog --title "Game Launching Tool" --menu "\nWelcome to the Elliot's home made game launching tool.\nWhich option would you like?\n" 17 75 7 "KTron" "" "Shutdown" ""
if [ "$REPLY" = "KTron" ]; then
ktron
fi
if [ "$REPLY" = "Shutdown" ]; then
halt
fi
So when I do a ./program to my program, it comes up with a lsit of "Ktron" and "Shutdown". When I choose one of them it just returns to the xterm defult thing. ANd obviously I dont want it to do this, I want it to carry out the commands "halt" or "ktrong" when I choose one.
So why is it no? ANy ideas?
madcompnerd
06-03-2004, 11:38 PM
Originally posted by MacTown06
thanks to all...
I guess i was getting a little ahead of myself. Its cool though, I will be back! Give me a couple months (or so) and i will bring this form back with more specific questions.
You picked a good language, hopefully it will force you to learn a bit about how things work. And don't forget, pointers are our friends ;).
psi42
06-04-2004, 12:25 AM
Originally posted by MacTown06
dialog --title "Game Launching Tool" --menu "\nWelcome to the Elliot's home made game launching tool.\nWhich option would you like?\n" 17 75 7 "KTron" "" "Shutdown" ""
if [ "$REPLY" = "KTron" ]; then
ktron
fi
if [ "$REPLY" = "Shutdown" ]; then
halt
fi
So when I do a ./program to my program, it comes up with a lsit of "Ktron" and "Shutdown". When I choose one of them it just returns to the xterm defult thing. ANd obviously I dont want it to do this, I want it to carry out the commands "halt" or "ktrong" when I choose one.
So why is it no? ANy ideas?
IIRC dialog sends the user response to stderr, so you will need to redirect stderr (file descriptor #2) to a text file for reading.
dialog --title "Game Launching Tool" --menu \
"\nWelcome to the Elliot's home made game launching \
tool.\nWhich option would you like?\n" 17 75 7 "KTron" "" \
"Shutdown" "" 2>./response
REPLY=`cat ./response`
clear
echo $REPLY
echo
:)
~psi42
sploo22
06-04-2004, 12:33 AM
REPLY=`dialog --title "Game Launching Tool" --menu "
Welcome to the Elliot's home made game launching tool.
Which option would you like?
" 17 75 7 "KTron" "" "Shutdown" "" 2>&1`
if [ "$REPLY" = "KTron" ]; then
ktron
fi
if [ "$REPLY" = "Shutdown" ]; then
halt
fi
This should work too, and it doesn't use a temporary file.
bwkaz
06-04-2004, 06:50 PM
Originally posted by sploo22
This should work too, and it doesn't use a temporary file. It also doesn't widen the forums (at least, not anymore... :p).
It would also be possible to use a case instead of your multiple if's:
case "$REPLY" in
KTron) ktron ;;
Shutdown) halt ;;
esac
MacTown06
06-06-2004, 08:13 PM
Originally posted by sploo22
REPLY=`dialog --title "Game Launching Tool" --menu "
Welcome to the Elliot's home made game launching tool.
Which option would you like?
" 17 75 7 "KTron" "" "Shutdown" "" 2>&1`
if [ "$REPLY" = "KTron" ]; then
ktron
fi
if [ "$REPLY" = "Shutdown" ]; then
halt
fi
This should work too, and it doesn't use a temporary file.
I used it, and I love it, thanks guys...
Now i want to tell you guys why im doing this... I took an older computer that was going to waste in our house. I loaded it up with slackware and I am trying to make it autologin and autostartx to my "game launching tool" and then just keep adding games to it. Its going pretty good, I don't know if its possiable to do an auto login and auto startx yet though.