×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    2

    Compiled application does't show in emulator

    I'm trying to follow tutorial from S60 Programming - A Tutorial Guide from WILEY. In chap 3, they start with simple console BlackJack game. However I found there are many erors that I had to fix it(not to perfection as I'm rusty with C++). On the end I got program compiling without errors but I cann't find my application in emulator (MENU >> INSTALLED).

    Can anybody guide me?

    Code:
    /*
    ============================================================================
     Name		: Blackjack.h
     Author	  : Peter
     Copyright   : Your copyright notice
     Description : Exe header file
    ============================================================================
    */
    
    #ifndef __BLACKJACK_H__
    #define __BLACKJACK_H__
    
    
    //  Include Files
    
    #include <e32base.h>
    
    
    //  Function Prototypes
    
    GLDEF_C TInt E32Main();
    
    
    #endif  // __BLACKJACK_H__
    Code:
    /*
    cards.h
    */
    
    #ifndef CARDS_H_
    #define CARDS_H_
    #include <e32base.h>
    class CCards : CBase
    {
    	public:
    		static CCards* NewL(TInt aNumPacks);
    		static CCards* NewLC(TInt aNumPacks);
    		TInt Deal();
    		void Shuffle();
    	private:
    		void ConstructL();
    		CCards();
    		//CCards(TInt aVal);
    	//public:
    		//~CCards();
    	private: //data
    		TInt iDeck[52];
    		TInt iNextCard;
    };
    
    #endif /*CARDS_H_*/
    Code:
    /*
    cards.cpp
    */
    #include <e32Math.h>
    #include "cards.h"
    
    CCards* CCards::NewL(TInt aNumPacks)
    {
    	CCards* self = CCards::NewLC(aNumPacks);
    	CleanupStack::Pop(self);
    	return(self);
    }
    CCards* CCards::NewLC(TInt aNumPacks)
    {
    	TInt temp = aNumPacks;
    	CCards* self = new (ELeave) CCards(/*aNumPacks*/);
    	CleanupStack::PushL(self);
    	self->ConstructL();
    	return(self);
    }
    void CCards::ConstructL()
    {
    }
    CCards::CCards()
    {
    	for(TInt i=0; i<52; i++)
    		{
    		iDeck[i] = i;
    		}
    }
    /*CCards::~CCards()
    {
    }*/
    
    TInt CCards::Deal()
    {
    	TInt card = iDeck[iNextCard];
    	iNextCard = (iNextCard+1)%52;
    	return card;
    }
    
    void CCards::Shuffle()
    	{
    	TTime time;
    	time.UniversalTime();
    	TInt64 seed = time.Int64();
    	TInt temp;
    	TInt swap;
    	
    	for(TInt i=0; i<52; i++)
    		{
    		swap = Math::Rand(seed)%(52);//create random swap position
    		
    		temp = iDeck[i];	//puts the ith card in a temp variable
    		iDeck[i] = iDeck[swap];	//swap the two cards
    		iDeck[i] = temp;
    		}
    	}
    Code:
    /*
    ============================================================================
     Name		: Blackjack.cpp
     Author	  : Peter
     Copyright   : Your copyright notice
     Description : Exe source file
    ============================================================================
    */
    
    //  Include Files  
    
    #include "Blackjack.h"
    #include <e32base.h>
    #include <e32std.h>
    #include <e32cons.h>			// Console
    #include "cards.h"
    
    //  Constants
    
    _LIT(KTextConsoleTitle, "Console");
    _LIT(KTextFailed, " failed, leave code = %d");
    _LIT(KTextPressAnyKey, " [press any key]\n");
    
    _LIT(KAce, "Ace");
    _LIT(KJack, "Jack");
    _LIT(KQueen, "Queen");
    _LIT(KKing, "King");
    _LIT(KOf, "of");
    _LIT(KHearts, "Hearts");
    _LIT(KClubs, "Clubs");
    _LIT(KDiamonds, "Diamonds");
    _LIT(KSpades, "Spades");
    
    
    //  Global Variables
    
    LOCAL_D CConsoleBase* gConsole;  // write all messages to this
    
    
    //  Local Functions
    
    LOCAL_C void MainL()
    	{
    	//
    	// add your program code here, example code below
    	//
    	CCards* deckOfCards = CCards::NewL(1);
    	TInt i, card;
    	for(i=0; i<15; i++)
    		{
    		card = deckOfCards->Deal();
    		TInt suit = card/13;
    		card%=13;
    		
    		if(0==card)
    			{
    			gConsole->Printf(KAce);
    			}
    		else if(10==card)
    			{
    			gConsole->Printf(KJack);
    			}
    		else if(11 == card)
    			{
    			gConsole->Printf(KQueen);
    			}
    		else if(12 == card)
    			{
    			gConsole->Printf(KKing);
    			}
    		else
    			{
    			gConsole->Printf(_L("%d"), card+1);
    			}
    			
    		gConsole->Printf(KOf);
    		
    		if(0 == suit)
    			{
    			gConsole->Printf(KHearts);
    			}
    		else if(1 == suit)
    			{
    			gConsole->Printf(KClubs);
    			}
    		else if(2 == suit)
    			{
    			gConsole->Printf(KDiamonds);
    			}
    		else
    			{
    			gConsole->Printf(KSpades);
    			}
    		}
    	delete deckOfCards;
    	}
    
    
    LOCAL_C void DoStartL()
    	{
    	// Create active scheduler (to run active objects)
    	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
    	CleanupStack::PushL(scheduler);
    	CActiveScheduler::Install(scheduler);
    
    	MainL();
    
    	// Delete active scheduler
    	CleanupStack::PopAndDestroy(scheduler);
    	}
    
    
    //  Global Functions
    
    GLDEF_C TInt E32Main()
    	{
    	// Create cleanup stack
    	__UHEAP_MARK;
    	CTrapCleanup* cleanup = CTrapCleanup::New();
    
    	// Create output console
    	TRAPD(createError, gConsole = Console::NewL(KTextConsoleTitle, TSize(KConsFullScreen,KConsFullScreen)));
    	if (createError)
    		return createError;
    
    	// Run application code inside TRAP harness, wait keypress when terminated
    	TRAPD(mainError, DoStartL());
    	if (mainError)
    		gConsole->Printf(KTextFailed, mainError);
    	gConsole->Printf(KTextPressAnyKey);
    	gConsole->Getch();
    	
    	delete gConsole;
    	delete cleanup;
    	__UHEAP_MARKEND;
    	return KErrNone;
    	}

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,751

    Re: Compiled application does't show in emulator

    The way of executing console-based applications also depends on the SDK edition you use. In case of S60 2nd edition (pre-9.x Symbian), you should explicitly start your .exe from epoc32\release\wins[cw]\udeb\. In case of S60 3rd edition (or Symbian 9.x) you can also do this manual startup or provide a _reg.rsc file as you would do for GUI apps, since both GUI and non-GUI applications are .exe-s.

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    2

    Re: Compiled application does't show in emulator

    My project are saved in different place then Symbian default, could be that any of the problems?
    It is just quess as only one file with _reg.rsc is in C:\Symbian\9.2\S60_3rd_FP1\Epoc32\Data\z\private\10003a3f\apps that has been saved in Symbian default project directory. Other projects been save in different location and I can not find _reg.rsc files for them

  4. #4
    Nokia Developer Moderator
    Join Date
    Oct 2006
    Location
    Finland
    Posts
    4,563

    Re: Compiled application does't show in emulator

    Quote Originally Posted by peter_budo View Post
    My project are saved in different place then Symbian default, could be that any of the problems?
    It is just quess as only one file with _reg.rsc is in C:\Symbian\9.2\S60_3rd_FP1\Epoc32\Data\z\private\10003a3f\apps that has been saved in Symbian default project directory. Other projects been save in different location and I can not find _reg.rsc files for them
    I think you should consider the project files to be in the same place. A little re-organization early helps save a lot of time later on
    edit:_reg.rsc file is created after the building of _reg.rss (Thats the file which a developer has to write, not the .rsc)
    Last edited by Symbian_Neil; 2008-02-20 at 13:20.

Similar Threads

  1. WLAN Connection from Emulator
    By capri07 in forum Mobile Java Networking & Messaging & Security
    Replies: 4
    Last Post: 2007-12-13, 05:13
  2. SDK 3rd emulator autostarts application
    By iulian_moldovan in forum Symbian
    Replies: 0
    Last Post: 2006-05-10, 07:30
  3. Application doesn't show up in menu on phone
    By gijsbert in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2005-02-08, 21:48
  4. how to delete make application from emulator?
    By khinsen in forum Symbian Tools & SDKs
    Replies: 4
    Last Post: 2005-01-21, 01:37
  5. Replies: 3
    Last Post: 2004-08-05, 08:46

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×