00001
00002
00003
00004
00005
00006 #include <e32cons.h>
00007
00008
00009 LOCAL_C void UseBasicTypesL();
00010
00012
00013
00014
00016 GLDEF_C TInt E32Main()
00017 {
00018
00019
00020 TRAPD(error, UseBasicTypesL());
00021
00022 _LIT(KMsgPanic,"Error in Symbian OS Basics Lab: ");
00023 __ASSERT_ALWAYS(!error, User::Panic(KMsgPanic, error));
00024
00025 return 0;
00026 }
00027
00028
00030
00031
00032
00034 LOCAL_C void UseBasicTypesL()
00035 {
00036
00037 _LIT(KLabTitle,"Symbian OS Basics Lab");
00038
00039
00040
00041
00042
00043
00044
00045 CConsoleBase* console = Console::NewL(KLabTitle, TSize(KConsFullScreen, KConsFullScreen));
00046
00047
00048
00049
00050 const TInt KOne = 1;
00051 const TInt KTwo = 2;
00052
00053
00054 TInt sum = KOne + KTwo;
00055
00056 _LIT(KSumOutput, "%d + %d is %d\n");
00057
00058 console->Printf(KSumOutput, KOne, KTwo, sum);
00059
00060 _LIT(KMaxIntOutput, "TInt max: %d\n");
00061 console->Printf(KMaxIntOutput, KMaxTInt);
00062
00063 _LIT(KMinIntOutput, "TInt min: %d\n");
00064 console->Printf(KMinIntOutput, KMinTInt);
00065
00066
00067
00068
00069
00070
00071 TBool flag = EFalse;
00072
00073
00074 if (!flag)
00075 {
00076 _LIT(KFlagFalse, "flag is EFalse\n");
00077 console->Printf(KFlagFalse);
00078 }
00079
00080
00081 flag = !flag;
00082
00083
00084 if (flag)
00085 {
00086 _LIT(KFlagTrue, "flag is ETrue\n");
00087 console->Printf(KFlagTrue);
00088 }
00089
00090
00091
00092
00093 _LIT(KEnterSpace, "Press space to start timer\n");
00094 console->Printf(KEnterSpace);
00095
00096
00097 TKeyCode key = console->Getch();
00098 while (EKeySpace != key)
00099 {
00100 _LIT(KCharVal, "Char entered is '%c'\n");
00101
00102
00103 TText keyVal = key;
00104
00105
00106 console->Printf(KCharVal, keyVal);
00107 key = console->Getch();
00108 }
00109
00110
00111
00112
00113 RTimer timer;
00114 if (KErrNone == timer.CreateLocal())
00115 {
00116 TRequestStatus status;
00117 const TTimeIntervalMicroSeconds32 KTimerInterval = 5000000;
00118
00119
00120
00121 timer.After(status, KTimerInterval);
00122
00123
00124
00125 User::WaitForRequest(status);
00126
00127
00128 _LIT(KTimerComplete, "Timer completed after %d micro secs\n");
00129 console->Printf(KTimerComplete, KTimerInterval );
00130 }
00131 else
00132 {
00133 _LIT(KTimerError, "Error creating timer\n");
00134 console->Printf(KTimerError);
00135 }
00136
00137 timer.Close();
00138
00139
00140 _LIT(KMsgPressAnyKey,"Press any key to end");
00141 console->Printf(KMsgPressAnyKey);
00142 console->Getch();
00143
00144 delete console;
00145 }
00146
00147
00148
00149