Console is a very simple application that only creates a text console and displays « Hello World ! » .

As you may guess, the code to do that is quite simple :
void ConsoleMainL()
{
console->Printf(_L("Hello World!\n"));
}
There is probably not much to say about this. Just note the use of _L( ) macro that shall be used to create build independant strings (that can use 8 or 16 bits text depending on the use of Unicode or not).
Actually, most of the work is done in the « console framework » located in console.h. This is a strange place to put some C++ code, and it has some drawbacks if you are a « serious » developer. However, it allows a very simple use of the framework by just « including » it. Here is the code to create the console :
CConsoleBase *console;
console=Console::NewL(_L("Console"),TSize(KConsFullScreen,KConsFullScreen));
TInt Err;
TRAP(Err,ConsoleMainL());
if(Err)
console->Printf(_L("TRAP: Error(%d)\n"),Err);
console->Printf(_L("\n[Press any key]"));
console->Getch();
delete console;
CConsoleBase and Console are not described in most Symbian documentation. A quick look at e32cons.h (in epoc/include directory) will give you clues about the available method for CConsoleBase :
Printf()
Getch
SetPos(X) and SetPos(X,Y)
WhereX() and WhereY()
Other functions are virtual and can only be used through CEikConsole class (which is not as straightforward to use due to the use of Eikon).
Console only adds to CConsoleBase the NewL() constructor and the ability to use the trap harness (the TRAP() primitive) : this construction is used to catch and report any potential errors that may occurs in the code called from ConsoleMainL.
To add support of a CleanupStack, you can replace E32Main() (in console.h) by the following code:
{
//
// Mark Heap (to check memory leakage)
// and create a Cleanup Stack
//
__UHEAP_MARK;
CTrapCleanup* cleanup=CTrapCleanup::New();
//
// Create a full screen console
//
TRAPD(error,createConsoleL());
//
// Delete the CleanUp Stack
// "Unmark" the heap
//
delete cleanup;
__UHEAP_MARKEND;
return(0);
}
And then add the createConsole()function just above:
{
console=Console::NewL(_L("Console"),TSize(KConsFullScreen,KConsFullScreen));
CleanupStack::PushL(console);
//
// Do my console program,
// and trap any error that may occurs in it
//
TInt Err;
TRAP(Err,ConsoleMainL());
if(Err)
console->Printf(_L("TRAP: Error(%d)\n"),Err);
//
// Wait the user to press any key before closing
//
console->Printf(_L("[Press any key]\n"));
console->Getch();
CleanupStack::PopAndDestroy();
}
Hi,
Would you say that this Hello World application (console-based and thus, utilizes the full screen) is a good foundation for a game that has control over the whole screen? I'd like to hear your opinion because I saw a sample application in the Symbian site that uses the same Hello World application as basis for a game.
Why am I asking this? :) I'm trying to find out how to make apps (and games) that are full screen. Any thoughts?
Hi,
This program is OK, but How I can load it in a real targed after build the armi code?
thanks, L.A
You can create a SIS file just like with standard APP file and install it on the phone the usual way.
Or you can send directly the EXE through irda/bluetooth.
In both case,you will need a file explorer application (ex: ) , go to the inbox directory (E:\system\mail on my 3650) and find your EXE in one of the subdirectories.
You can also read for more details.
Hi
I am doing some test with console . actually it is httpexampleclient in UIQ example. I want to excute on P800.
plz tell me how I excute it on p800.
thanx all
I found out the way.
I just change the ".exe" extantion of file to APP..
thanx
This console is very nice, Its a great help for debugging.
You can run the application normaly and send all the debug to the console window.
Before I used AlertWins but they are a bit anoying and sometime they change the events and focus of your controls.
This is evem cleaner and more practical then log file debuging.