View Full Version : In need of a simple example.
locke.dragon
May 11th, 2007, 12:56 PM
For the project I'm working on, I need a simple GUI written in C that can edit variables in a text document. Could someone point me in the direction of an example that would do something like this? I'm not very good at writing code from scratch, but I'm able to easily work with code as long as I have an example. Please help.
Blacktalon
May 11th, 2007, 03:33 PM
Hmm...that sounds to much like doing some one's homework.
But if you want an example code try doing a search through google, that's the best help you find pretty much.
But if you need some help coming up with ideas to help you get started on how this would work, I can definately help you there:
1. Use some code that takes in a paramater of a file name.
2. inside you code ask for an letter or word that you would liked changed.
3. save that input.
4. Ask what you would like it changed to.
5. Save that input
6. Use a search (Linear probably would be best for this even though it would be pretty slow).
7. Rewrite the word with the changed word.
8. Save file, and exit.
This one should be to bad to implement, it will just take a little bit of time and effort.
Good luck!
locke.dragon
May 11th, 2007, 03:45 PM
thanks for the advice, but just for future reference, it's not homework, it's a dock i'm working on.
http://www.thelinuxdock.blogspot.com/
Blacktalon
May 11th, 2007, 03:57 PM
Gotcha!
Sorry I can't help much more then that but I am not very good at 'C', I know Java myself
locke.dragon
May 11th, 2007, 03:59 PM
would java work in this situation? the GUI doesn't have to be C, as long as it can edit a text file that has C code in it, recompile somehow, and re-run the C program, anything would do! :D
nicholas22
May 11th, 2007, 04:55 PM
Basically you could try GTK+ if you need pure C/C++ but this might be quite a steep learning curve.
Or you could would use a Java front-end and JNI, which links to C/C++ libraries.
Java has ample GUI-building tool support, such as the NetBeans, Eclipse, JBuilder IDEs.
Hope this helps
locke.dragon
May 11th, 2007, 05:00 PM
yeah. that helps alot. thanks! is there any way you could post links to those programs/plug-ins?
wtruong
May 11th, 2007, 05:07 PM
you should just use a shell script, perl, or python. replacing words is so much easier in there
locke.dragon
May 11th, 2007, 05:08 PM
could you possibly point me in the direction of a simple example GUI?
FuturePast
May 11th, 2007, 05:58 PM
personally I would do a shell script using zenity and sed.
locke.dragon
May 11th, 2007, 06:03 PM
cool. thanks for the idea. that might be easier. but would anyone here be willing to either point me to an example program or write one for me? i'd be more than happy to include you as a member of the project and i'd kiss your feet if you wrote the script/GUI/whatever for me. :P
FuturePast
May 11th, 2007, 06:30 PM
$ cat someText
Programming Talk:
This forum is for all %REPLACE% programming questions.
The questions do not have to be directly related to Ubuntu and any language is allowed.
$ sed --in-place "s/%REPLACE%/$(zenity --entry)/g" someText
$ cat someText
Programming Talk:
This forum is for all DoesThisHelp programming questions.
The questions do not have to be directly related to Ubuntu and any language is allowed.
WW
May 11th, 2007, 06:42 PM
Since I am trying to learn more python, this seemed like a good exercise. I took an older python program that I wrote, and hacked it up to do something that might be close to what you want. Copy the files edit_thing.py and main.c.txt to a directory, rename main.c.txt to main.c (the forum software wouldn't let me attach main.c) and then in that directory, run
$ python edit_thing.py &
locke.dragon
May 11th, 2007, 06:52 PM
omgsh!!! http://i159.photobucket.com/albums/t147/clipsandeggs/faint.gif i can't thank you enough WW! this is EXACTLY what i'm looking for! i think that with some time and effort on my part, this will be EXACTLY what my project needs. thank you thank you thank you! (boy am i over-reacting. http://i159.photobucket.com/albums/t147/clipsandeggs/sweat.gif) http://i159.photobucket.com/albums/t147/clipsandeggs/mwahaha.gif
vBulletin® v3.7.4, Copyright ©2000-2008, Jelsoft Enterprises Ltd.