Author Topic: C++ Question  (Read 17530 times)

Capn_Fish

  • Hero Member
  • *****
  • Posts: 2342
    • View Profile
    • http://
C++ Question
« 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.
« Last Edit: May 01, 2007, 09:37:47 pm by Capn_Fish »
SL-C750- pdaXrom beta 1 (mostly unused)
Current distro: Gentoo

freizugheit

  • Sr. Member
  • ****
  • Posts: 409
    • View Profile
    • http://
C++ Question
« Reply #1 on: May 01, 2007, 09:56:37 pm »

Meanie

  • Hero Member
  • *****
  • Posts: 2803
    • View Profile
    • http://www.users.on.net/~hluc/myZaurus/
C++ Question
« Reply #2 on: May 01, 2007, 10:19:44 pm »
Quote
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
SL-C3000 - pdaXii13 build5.4.9 (based on pdaXrom beta3) / SL-C3100 - Sharp ROM 1.02 JP (heavily customised)
Netgear MA701 CF, SanDisk ConnectPlus CF, Socket Bluetooth CF, 4GB Kingston CF,  4GB pqi SD, 4GB ChoiceOnly SD, 2GB SanDisk SD USB Plus, 1GB SanDisk USB Plus, 1GB Transcend SD, 2GB SanDisk MicroSD with SD adaptor, Piel Frama Leather Case, GoldX 5-in-1 USB cable, USB hub, USB mouse, USB keyboard, USB ethernet, USB HDD, many other USB accessories...
(Zaurus SL-C3000 owner since March 14. 2005, Zaurus SL-C3100 owner since September 21. 2005)
http://members.iinet.net.au/~wyso/myZaurus - zBook3K

Capn_Fish

  • Hero Member
  • *****
  • Posts: 2342
    • View Profile
    • http://
C++ Question
« Reply #3 on: May 01, 2007, 10:31:25 pm »
OK, I got everything sorted out (for the moment).

Thanks for the response.
SL-C750- pdaXrom beta 1 (mostly unused)
Current distro: Gentoo

Capn_Fish

  • Hero Member
  • *****
  • Posts: 2342
    • View Profile
    • http://
C++ Question
« Reply #4 on: May 10, 2007, 06:17:42 pm »
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)?
« Last Edit: May 10, 2007, 06:17:58 pm by Capn_Fish »
SL-C750- pdaXrom beta 1 (mostly unused)
Current distro: Gentoo

Meanie

  • Hero Member
  • *****
  • Posts: 2803
    • View Profile
    • http://www.users.on.net/~hluc/myZaurus/
C++ Question
« Reply #5 on: May 10, 2007, 08:15:01 pm »
Quote
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...
SL-C3000 - pdaXii13 build5.4.9 (based on pdaXrom beta3) / SL-C3100 - Sharp ROM 1.02 JP (heavily customised)
Netgear MA701 CF, SanDisk ConnectPlus CF, Socket Bluetooth CF, 4GB Kingston CF,  4GB pqi SD, 4GB ChoiceOnly SD, 2GB SanDisk SD USB Plus, 1GB SanDisk USB Plus, 1GB Transcend SD, 2GB SanDisk MicroSD with SD adaptor, Piel Frama Leather Case, GoldX 5-in-1 USB cable, USB hub, USB mouse, USB keyboard, USB ethernet, USB HDD, many other USB accessories...
(Zaurus SL-C3000 owner since March 14. 2005, Zaurus SL-C3100 owner since September 21. 2005)
http://members.iinet.net.au/~wyso/myZaurus - zBook3K

Capn_Fish

  • Hero Member
  • *****
  • Posts: 2342
    • View Profile
    • http://
C++ Question
« Reply #6 on: May 10, 2007, 09:35:41 pm »
Quote
Quote
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  
SL-C750- pdaXrom beta 1 (mostly unused)
Current distro: Gentoo

pgas

  • Hero Member
  • *****
  • Posts: 1097
    • View Profile
    • http://
C++ Question
« Reply #7 on: May 11, 2007, 01:54:06 am »
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.
« Last Edit: May 11, 2007, 01:55:50 am by pgas »
SLC-860 cacko / senao wifi

Meanie

  • Hero Member
  • *****
  • Posts: 2803
    • View Profile
    • http://www.users.on.net/~hluc/myZaurus/
C++ Question
« Reply #8 on: May 11, 2007, 02:19:24 am »
Quote
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+
« Last Edit: May 11, 2007, 02:23:36 am by Meanie »
SL-C3000 - pdaXii13 build5.4.9 (based on pdaXrom beta3) / SL-C3100 - Sharp ROM 1.02 JP (heavily customised)
Netgear MA701 CF, SanDisk ConnectPlus CF, Socket Bluetooth CF, 4GB Kingston CF,  4GB pqi SD, 4GB ChoiceOnly SD, 2GB SanDisk SD USB Plus, 1GB SanDisk USB Plus, 1GB Transcend SD, 2GB SanDisk MicroSD with SD adaptor, Piel Frama Leather Case, GoldX 5-in-1 USB cable, USB hub, USB mouse, USB keyboard, USB ethernet, USB HDD, many other USB accessories...
(Zaurus SL-C3000 owner since March 14. 2005, Zaurus SL-C3100 owner since September 21. 2005)
http://members.iinet.net.au/~wyso/myZaurus - zBook3K

pgas

  • Hero Member
  • *****
  • Posts: 1097
    • View Profile
    • http://
C++ Question
« Reply #9 on: May 11, 2007, 04:21:17 am »
I wonder if pyqt and python + gtk-server ( http://www.gtk-server.org/ )
suffer from the same startup overhead
SLC-860 cacko / senao wifi

Capn_Fish

  • Hero Member
  • *****
  • Posts: 2342
    • View Profile
    • http://
C++ Question
« Reply #10 on: May 11, 2007, 07:51:09 am »
Nah, I like C++, and I'll look into QT3.

Thanks.
SL-C750- pdaXrom beta 1 (mostly unused)
Current distro: Gentoo

Capn_Fish

  • Hero Member
  • *****
  • Posts: 2342
    • View Profile
    • http://
C++ Question
« Reply #11 on: May 15, 2007, 01:51:08 pm »
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...
« Last Edit: May 15, 2007, 02:44:52 pm by Capn_Fish »
SL-C750- pdaXrom beta 1 (mostly unused)
Current distro: Gentoo

Capn_Fish

  • Hero Member
  • *****
  • Posts: 2342
    • View Profile
    • http://
C++ Question
« Reply #12 on: June 08, 2007, 09:13:42 pm »
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.
SL-C750- pdaXrom beta 1 (mostly unused)
Current distro: Gentoo

Meanie

  • Hero Member
  • *****
  • Posts: 2803
    • View Profile
    • http://www.users.on.net/~hluc/myZaurus/
C++ Question
« Reply #13 on: June 08, 2007, 10:50:07 pm »
Quote
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
SL-C3000 - pdaXii13 build5.4.9 (based on pdaXrom beta3) / SL-C3100 - Sharp ROM 1.02 JP (heavily customised)
Netgear MA701 CF, SanDisk ConnectPlus CF, Socket Bluetooth CF, 4GB Kingston CF,  4GB pqi SD, 4GB ChoiceOnly SD, 2GB SanDisk SD USB Plus, 1GB SanDisk USB Plus, 1GB Transcend SD, 2GB SanDisk MicroSD with SD adaptor, Piel Frama Leather Case, GoldX 5-in-1 USB cable, USB hub, USB mouse, USB keyboard, USB ethernet, USB HDD, many other USB accessories...
(Zaurus SL-C3000 owner since March 14. 2005, Zaurus SL-C3100 owner since September 21. 2005)
http://members.iinet.net.au/~wyso/myZaurus - zBook3K

Capn_Fish

  • Hero Member
  • *****
  • Posts: 2342
    • View Profile
    • http://
C++ Question
« Reply #14 on: June 08, 2007, 10:57:26 pm »
Quote
Quote
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?
SL-C750- pdaXrom beta 1 (mostly unused)
Current distro: Gentoo