OESF Portables Forum
Everything Else => Zaurus - Everything Development => Distros, Development, and Model Specific Forums => Archived Forums => Linux Applications => Topic started by: Capn_Fish on May 01, 2007, 09:00:07 pm
-
I'm making a program for the Z that I need to take a variable and use it as part of a "system (xxxx)" command (or some other command to have the program call another command with args). How do I do that? Sorry if a) this is really obvious or this question doesn't make sense. I have very little C++ knowledge, but am trying to learn.
Links to a solution would also be appreciated.
Thanks in advance.
-
http://www.cprogramming.com/tips/showTip.p...count=30&page=1 (http://www.cprogramming.com/tips/showTip.php?tip=12&count=30&page=1)
-
I'm making a program for the Z that I need to take a variable and use it as part of a "system (xxxx)" command (or some other command to have the program call another command with args). How do I do that? Sorry if a) this is really obvious or this question doesn't make sense. I have very little C++ knowledge, but am trying to learn.
Links to a solution would also be appreciated.
Thanks in advance.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=160221\"][{POST_SNAPBACK}][/a][/div]
sprintf is your friend
-
OK, I got everything sorted out (for the moment).
Thanks for the response.
-
New question: Is jumping in WAY over my head and trying to figure out GUI programming with GTKmm with very little C++ knowledge not recommended (for reasons other than the frustration factor)?
-
New question: Is jumping in WAY over my head and trying to figure out GUI programming with GTKmm with very little C++ knowledge not recommended (for reasons other than the frustration factor)?
[div align=\"right\"][a href=\"index.php?act=findpost&pid=160999\"][{POST_SNAPBACK}][/a][/div]
i'd recommend trying out the qt3 widgets first. took me 3 days to learn qt3 api and write pdaXcfg. i did all this natively on the z so compilation and debugging was much slower. you can actually install qt3 on a pc, compile and debug your app on the pc and when it all looks ok, recompile on the zaurus. there also is qt designer, a gui to create qt3 guis which also works on either pc or zaurus... gtkmm is a bit harder to learn...
-
New question: Is jumping in WAY over my head and trying to figure out GUI programming with GTKmm with very little C++ knowledge not recommended (for reasons other than the frustration factor)?
[div align=\"right\"][a href=\"index.php?act=findpost&pid=160999\"][{POST_SNAPBACK}][/a][/div]
i'd recommend trying out the qt3 widgets first. took me 3 days to learn qt3 api and write pdaXcfg. i did all this natively on the z so compilation and debugging was much slower. you can actually install qt3 on a pc, compile and debug your app on the pc and when it all looks ok, recompile on the zaurus. there also is qt designer, a gui to create qt3 guis which also works on either pc or zaurus... gtkmm is a bit harder to learn...
[div align=\"right\"][a href=\"index.php?act=findpost&pid=161003\"][{POST_SNAPBACK}][/a][/div]
What about FLTK?
And I'd assume it'd take me much longer than 3 days if that's how long it took you, as I don't have the background you do
-
Depending on you background, you might want to try an easier
language first, say python, ruby....
C++ is probably the most complicated language out there (even if qt makes things easier, and probably gtkmm also).
Don't worry about performances, even the Zaurus is perfectly able to run python applications, and if your application is good or is something people are missing, they will use it anyway.
-
Depending on you background, you might want to try an easier
language first, say python, ruby....
C++ is probably the most complicated language out there (even if qt makes things easier, and probably gtkmm also).
Don't worry about performances, even the Zaurus is perfectly able to run python applications, and if your application is good or is something people are missing, they will use it anyway.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=161016\"][{POST_SNAPBACK}][/a][/div]
yeah. python, perl. they all run reasonably fast on the Z, so use the easiest one. python is already pre-installed on pdaXrom since the config tools use it so less stuff needs to be installed in order to run your apps, whereas if you write things in fltk or something else, you will need to install extra libs.
the main reason I choose to learn QT3 instead of python is the load speed. Since qt3 is just additional apis for c++, they are compiled binaries and qt3 libs already exist in pdaXrom (Package Manager and PPP tools for example are QT3) so nothing extra needs to be installed. python and perl are interpretors, you need to have those installed and each app written in those languages requires the interpretor loaded before it loads the app, so essentially more loading time and memory used. since qt3 is a compiled shared library, ie, .so, it only needs to be loaded once and can be shared amongst multiple qt apps.
hence if you want your apps to load very fast, use GTK+ ( C ), not gtkmm (C++) because C is slightly faster than C++ and gtk+ is already installed and loaded by most X apps. qt3 also loads pretty fast, but may be unloaded if no qt3 apps have been used for a while and because the ratio of gtk+ apps is much higher than qt3 apps, chances are the gtk+ libraries are never unloaded and always there...
perl and python apps which dont use gui are also quite fast to load, however, in order to use the GUI, those interpretors need to load a bridge, ie python gtk bindings which is pygtk.
there is not much difference in execution time for the binaries/scripts written in those languages, but the loading time of the interpretors/extra libraries adds additional time for the application to start hence, the perceived speed of the application is slower.
so i chose QT3 because it uses C++ which is Object Oriented instead of procedural like in C, and it loads faster because it is supported by a mutli-threaded shared libraries and already pre-installed on pdaXrom (qt-mt.so). also, the QT3 widget are quite easy to use and make it much easier than standard C/C++ or GTK+
-
I wonder if pyqt and python + gtk-server ( http://www.gtk-server.org/ (http://www.gtk-server.org/) )
suffer from the same startup overhead
-
Nah, I like C++, and I'll look into QT3.
Thanks.
-
You need -devel libs to compile QT3 on the Z, no? Do these exist, or should I do the dev work on my larger computer?
Thanks.
EDIT: I'm going to put my GUI development on hold until I solidify my C++ base. Thanks for the help, and I'll probably need more in the future.
As a side note, FLTK looks pretty good...
-
Is there any way to only use one string-like variable (char[xyz] or string) in my code? Some things complain if I use a char[xyz], but not a string, others work the opposite way, and it would be easier to just use one type instead of converting back and forth.
Thanks.
-
Is there any way to only use one string-like variable (char[xyz] or string) in my code? Some things complain if I use a char[xyz], but not a string, others work the opposite way, and it would be easier to just use one type instead of converting back and forth.
Thanks.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=162874\"][{POST_SNAPBACK}][/a][/div]
sounds like QString is what you want
-
Is there any way to only use one string-like variable (char[xyz] or string) in my code? Some things complain if I use a char[xyz], but not a string, others work the opposite way, and it would be easier to just use one type instead of converting back and forth.
Thanks.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=162874\"][{POST_SNAPBACK}][/a][/div]
sounds like QString is what you want
[div align=\"right\"][a href=\"index.php?act=findpost&pid=162881\"][{POST_SNAPBACK}][/a][/div]
I'm not using QT. Is that an issue?
Is it possible to just use either strings or character arrays?
-
Is there any way to only use one string-like variable (char[xyz] or string) in my code? Some things complain if I use a char[xyz], but not a string, others work the opposite way, and it would be easier to just use one type instead of converting back and forth.
Thanks.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=162874\"][{POST_SNAPBACK}][/a][/div]
sounds like QString is what you want
[div align=\"right\"][a href=\"index.php?act=findpost&pid=162881\"][{POST_SNAPBACK}][/a][/div]
I'm not using QT. Is that an issue?
Is it possible to just use either strings or character arrays?
[div align=\"right\"][a href=\"index.php?act=findpost&pid=162882\"][{POST_SNAPBACK}][/a][/div]
either convert between them, or design your apps better to just use only methods that supports either one of them only.
alternatively, use a easier to use framework which has already solved this problem for you...
-
Use std::string wherever you can (and pass const/non-const references to all your functions), it will make your life much easier. But there will be cases where you need to convert, generally for third-party library functions.
Conversion is pretty darn trivial, though.
1) .c_str() to get a const pointer to a std::string, you can use that straight in the function call e.g. someFunction(myString.c_str());
2) create an old style char buffer in local scope for functions which modify their contents, then assign the buffer to the std::string you're using in the rest of your code. std::string is smart enough to understand "myStdString=myCString;"
-
Is there any way to only use one string-like variable (char[xyz] or string) in my code? Some things complain if I use a char[xyz], but not a string, others work the opposite way, and it would be easier to just use one type instead of converting back and forth.
Thanks.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=162874\"][{POST_SNAPBACK}][/a][/div]
sounds like QString is what you want
[div align=\"right\"][a href=\"index.php?act=findpost&pid=162881\"][{POST_SNAPBACK}][/a][/div]
I'm not using QT. Is that an issue?
Is it possible to just use either strings or character arrays?
[div align=\"right\"][a href=\"index.php?act=findpost&pid=162882\"][{POST_SNAPBACK}][/a][/div]
I guess there is no easy way out but to convert them back and forth. Not too familiar with the string definition in QT3, but there might be some cast members that return a pointer from string that can be used as a char pointer in some functions.
Using MFC (Microsoft Foundation Classes) as an example,
CString sMyText;
char szMyText[100];
char * lpszMyText;
sMyText = "Some data here";
lpszMyText = sMyText.GetBuffer(sMyText.GetLength());
// Use lpszMyText
strcpy(szMyText, lpszMyText);
lpszMyText = NULL; // Not required but good practise to null the pointers
// Release buffer pointer
sMyText.ReleaseBuffer();
Hope this make sense.
-
Slowly working around my problem, but I have another question:
There is a clear() function to strings. Is there a similar function for character arrays?
Sorry if that's a really dumb question, but I'm still new to C++.
Thanks in advance.
-
Never mind, I worked around it.