1// requires b30 2long a=-40, b = 23, __b=34; 3 4byte zz; 5 6byte buf[]; 7long data[]; 8byte foo[][]; 9string weird = "fred"; 10 11//#define Testing OnRev(OUT_BC, 50) 12 13void George(byte b); 14/* 15void George(byte b) 16{ 17 int g1 = 4, g2=-3; 18 byte b1[], b2=33; 19 20 b2 = g1+g2+b; 21// b1 = OUT_BC; 22 OnFwd(OUT_BC, b2); 23 Wait(1000); 24// byte b1[], b2=33; 25 Testing; 26 Wait(1000); 27} 28*/ 29 30//void MyTestSub(int x, int y, short j); 31void MyTestSub(int x, int y, short j) 32//void MyTestSub(x, y, j) 33{ 34 byte g1=3, 35 g2=5; 36 int foo=-3; 37 foo = GetOutput(OUT_A, TachoCount); 38 SetSensor(IN_3, SENSOR_ROTATION); 39 George(g2*10); 40 foo = x + y * j; 41 g1 = foo/4; 42 NumOut(0, 0, true, g1); 43 OnFwd(OUT_BC, g1); 44 Wait(4000); 45} 46 47task Fred() 48{ 49 ArrayInit(data, 0, 4); 50 data[0] = 23; 51 weird[2] = "Wd" ; 52// data[0] = weird[0]; 53// NumOut(0, LCD_LINE4, data[0], true); 54 weird += BrickDataName(); 55 TextOut(50, LCD_LINE1, weird, true); 56 GetBrickDataAddress(buf); 57 b = ArrayLen(buf); 58 NumOut(0, LCD_LINE1, b); 59 for (a=0, b=2; a < b; a++) 60 { 61 NumOut(a*15, LCD_LINE2, buf[a]); 62 } 63 Wait(10000); 64 OnFwd(OUT_BC, -75); 65 Wait(5000); 66} 67 68char j=-40, k = 23, x=4; 69mutex myMutex; 70 71string msg="test" , blech; 72 73string FooBar(int a, string b) 74{ 75 string result ="r=" ; 76 result += NumToStr(a); 77 result += b; 78 return (result); 79} 80 81int Multiply(int a, int b) 82{ 83 return (a * b); 84} 85 86task main (){ 87 int xxxx = 23; 88 Precedes(Fred); 89// Stop( xxxx == 23 ); 90 91// Fred; 92 93 msg = FooBar(10, "_fred" ); 94 TextOut(0, LCD_LINE1, msg, true); 95 NumOut(0, LCD_LINE2, xxxx); 96 xxxx = Multiply(2, 3) + 4; 97 NumOut(0, LCD_LINE3, xxxx); 98 xxxx = Multiply(2, 3); 99 NumOut(0, LCD_LINE4, xxxx); 100 NumOut(0, LCD_LINE5, Multiply(10, xxxx)); 101 xxxx = ("fred" == "fred") + 2 + (5 >= (2*2)); 102 NumOut(0, LCD_LINE6, xxxx); 103 Wait(10000); 104 Stop( "fred" == "fred" ); 105 106 RotateMotorEx(OUT_BC, 75, 90, 0, true, true); 107 RotateMotorEx(OUT_BC, 75, 90, 100, true, true); 108 RotateMotorEx(OUT_BC, 75, 90, -100, true, true); 109 RotateMotorEx(OUT_BC, -75, 90, 0, true, true); 110 RotateMotorEx(OUT_BC, -75, 90, 100, true, true); 111 RotateMotorEx(OUT_BC, -75, 90, -100, true, true); 112 Stop(true); 113 114 a = (j < 5) ? 23 : 48; 115 116 if (j < 5 && ((k&0x7f) != 0)) { 117 OnRev(OUT_B, 40); 118 } 119 else { 120 OnFwd(OUT_B, 70); 121 } 122 123 Random(5000); 124 125 if (true) 126 OnRev(OUT_B, 40); 127 else { 128 OnFwd(OUT_C, 30); 129 } 130 131 { 132 OnFwd(OUT_A, 20); 133 a=Random(5000) * 2; 134 NumOut(0, 20, true, a); 135 Wait(a); 136 Off(OUT_A); 137 } 138 139 do 140 { 141// foobar; 142 OnFwd(OUT_BC, 50+40); 143 Wait(500); 144 Off(OUT_BC); 145 Wait(1000); 146 a++; b++; 147 } while (a < 10); 148 149 repeat(10) 150 { 151 repeat(4) 152 { 153 OnFwd(OUT_BC, 50); 154 Wait(1000); 155 Off(OUT_BC); 156 Wait(2000); 157 } 158 } 159 160 Acquire(myMutex); 161 asm { 162 add a, a, 1 163 sub b, a, 2 164 OnRev(OUT_BC, 50) 165 } 166 Release(myMutex); 167 168 SetSensorType(IN_1, IN_TYPE_SWITCH); 169 170 PlayTone(TONE_A4, MS_500); 171 while(!SoundState()) 172 /* do nothing */ ; 173 Wait(500); 174 175 PlayFile( "test.rso" ); 176 177myLoop: LineOut(30, 50, 50, 30, false); 178 179 LineOut(0, 0, 30, 50, false); 180 PointOut(30, 40, false); 181 CircleOut(30, 40, 10, false); 182 RectOut(30, 50, 20, 10, false); 183 184// goto myLoop 185 186 msg += ".r" + "s" + "o" ; 187 188 PlayFile(msg); 189// Wait(1000); 190 191 msg = NumToStr(10); 192 TextOut(0, 50, msg); 193 msg = StrCat("test" , " " , "please" ); 194 TextOut(0, 35, msg); 195 msg = SubStr("please" , 1, 3); 196 TextOut(0, 0, msg); 197 msg = Flatten(0x31); 198 NumOut(50, 0, StrLen(msg)); 199 TextOut(60, 0, msg); 200 msg = StrReplace("please" , 2, "AA" ); 201 TextOut(50, 8, msg); 202 203 204 205 a = 100 - FreeMemory(); 206// a = FreeMemory(); 207 208 NumOut(50, LCD_LINE2, a, true); 209 NumOut(50, LCD_LINE3, FreeMemory()); 210 NumOut(50, LCD_LINE4, BatteryLevel()); 211 212 213 PlayTone(440, 2000); 214 NumOut(10, LCD_LINE1, SoundState(), true); 215 NumOut(10, LCD_LINE2, SoundFlags()); 216 Wait(50); 217 StopSound(); 218 219 x--; 220 if ((x%3)!=0) { 221 TextOut(10, LCD_LINE1, "whoops"); 222 } 223 224 225 until(ButtonPressed(BTN2, true)); 226 until(!ButtonPressed(BTN2, true)); 227 228 SetSensorLowspeed(IN_1); 229// SetButtonState(BTN2, 0); 230 ResetSensor(IN_1); 231 232 while(BluetoothStatus(0) != 0); 233 while(!BluetoothStatus(0)); 234 235 while (!ButtonPressed(BTN2, true)) 236 { 237 NumOut(10, LCD_LINE5, SensorUS(IN_1), true); 238 Wait(10); 239 } 240 241 while(!ButtonPressed(BTN4, true)) ; 242 243 MyTestSub(12, 45, 10); 244 245} 246 247 248#define Testing OnRev(OUT_BC, 50) 249 250byte d, e, f; 251 252void George(byte b) 253{ 254 int g1 = 4, g2=-3; 255 byte b1[], b2=33; 256 257 b2 = g1+g2+b; 258// b1 = OUT_BC; 259 OnFwd(OUT_BC, b2); 260 Wait(1000); 261// byte b1[], b2=33; 262 Testing; 263 Wait(1000); 264} 265 266