Need serious help here.

15 posts / 0 new
Last post
Inspire
Inspire's picture
Offline
Mobile Conjurer
Joined: 28 Apr 2011
Posts:
Need serious help here.

Hi, I'm new to Mosync and C/C++ programming. I still can't grasp the concept of the codings. I tried to do the tutorials on the site provided but then I'm stuck at "Adding Resources to a Project", the 3rd tutorial. I still can't grasp the relation of header files and cpp files. I can't even do a simple label with text. Is there any simple coding with label and text that I can grasp the concept of it?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
insert
insert's picture
Offline
Joined: 3 May 2011
Posts:

Am new to C++ programming also. anyone could share ? thanks

workhard
workhard's picture
Offline
Mobile Conjurer
Joined: 3 May 2011
Posts:

u can try this
http://www.zwani.com/graphics/funny_pictures/?page=2

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Hi, I don't think that there is a simpler example than the 'Adding Resources to a Project' tutorial, sorry. There are some good tutorials here though http://www.cplusplus.com/doc/tutorial/

Header files contain the definition of what a class will do, the cpp file is the code that actually does it. If you write a class, say a Screen class for MoSync, then you will need to add widgets to it. To be able to use widgets, the compiler needs to know what a widget does and what it looks like. So to do this, you would include the widget header file (MAUI/Widget.h). You can then specify widgets which this screen will use.

When you create a widget, you also include MAUI/Widget.h and write the actual code to perform the methods specified in the headers.

There are tons of C++ tutorials on the web, and a lot of videos on YouTube, have a good look round. These free eBooks are also very good, and volume one is for C++ starters http://mindview.net/Books/TICPP/ThinkingInCPP2e.html

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:
Inspire wrote:

Hi, I'm new to Mosync and C/C++ programming. I still can't grasp the concept of the codings. I tried to do the tutorials on the site provided but then I'm stuck at "Adding Resources to a Project", the 3rd tutorial. I still can't grasp the relation of header files and cpp files. I can't even do a simple label with text. Is there any simple coding with label and text that I can grasp the concept of it?

Have you had a look at the example code? http://www.youtube.com/watch?v=LYFbGf-Reb8

Inspire
Inspire's picture
Offline
Mobile Conjurer
Joined: 28 Apr 2011
Posts:

Hi Sam, thanks for the sources and tutorials online. I had look through a simple tutorial like Hello World in C++. But the coding seems kind of different from Mosync. Although I believe both are C++ programming.


 For example :

#include <iostream>
using namespace std;

int main ()
{
  cout << "Hello World!";
  return 0;
}

This coding is different from Mosync's Hello World tutorial. Like Mosync doesn't include <iostream> or uses cout.


I had seen the youtube video a week ago but it only shows importing of projects and putting the application inside a phone. Pardon for my ignorance in C++ programming.

insert
insert's picture
Offline
Joined: 3 May 2011
Posts:

because i found out that most of the C++ books have coding #include in almost all the projects and uses some other codes in other books also. U might wan to test it out in MoSync and see if it works?

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Hi,
MoSync doesn't have the standard C libraries, like iostream, as the device support has to be wildly different and MoSync has to be as small as possible. The equivalent MoSync code would be:

#include <conprint.h>
int MAMain()
{
  printf("Hello World");
  return 0;
}

sasij
sasij's picture
Offline
Mobile Conjurer
Joined: 2 Apr 2011
Posts:

This is a piece of advice. Don't try and learn c++ and mosync at the same time. Maybe take a week(at the minimal level) and do some reading on c and c++ and how they work. Then when you're more comfortable with some of the concepts come back and give it another shot. Thats just advice, take it for what it's worth.

Inspire
Inspire's picture
Offline
Mobile Conjurer
Joined: 28 Apr 2011
Posts:

Are there any online sources for C programming for beginners who have no knowledge about C/C++?

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Yes, loads, just try googling 'C/C++ tutorials', www.cplusplus.com is good, as the post I've already made in this thread:

Quote:

There are tons of C++ tutorials on the web, and a lot of videos on YouTube, have a good look round. These free eBooks are also very good, and volume one is for C++ starters http://mindview.net/Books/TICPP/ThinkingInCPP2e.html

sasij
sasij's picture
Offline
Mobile Conjurer
Joined: 2 Apr 2011
Posts:

http://www.cprogramming.com/ also is a good one for beginners.

Inspire
Inspire's picture
Offline
Mobile Conjurer
Joined: 28 Apr 2011
Posts:

Hi guys! I'm back after getting the hang of C programming. I did some tryouts using Mosync IDE. The problem now is that when I use the example of Sam's Hello World code, the mobile screen just flashes for a split second and then disappears. I know that in C programming, you can solved it by using the getchar(); but how do you do it in Mosync IDE?

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

http://www.mosync.com/documentation/tutorials/detecting-events-cc

Try this:

#include <ma.h>   // the standard MoSync header
#include <conprint.h>   // provides printf()
 
int MAMain() {
    printf("Hello world!\n");
    // Declare a MoSync event struct.
    MAEvent e;
    while(1) {
        // Wait for an event
        maWait(0);
        // Store the latest event in the event struct.
        maGetEvent(&e);
        // determine whether or not it is a key press
        if(e.type == EVENT_TYPE_KEY_PRESSED) {
            // ...and whether it was the '0' key.
            if(e.key == MAK_0) {
                // ...in which case we exit.
                maExit(0);
            }
        }
        else if(e.type == EVENT_TYPE_CLOSE) {
            // ...and also if we get a close event.
            maExit(0);
        }
    }
    return 0;
}

Inspire
Inspire's picture
Offline
Mobile Conjurer
Joined: 28 Apr 2011
Posts:

Thanks Sam. Just a few more questions. If I were to make an application, can i solely use C programming? And also is there any function which is similiar to the scanf() function in C? Where the user is required to input a character or anything?