1 00:00:00,870 --> 00:00:03,150 Hello In this session. 2 00:00:03,270 --> 00:00:06,860 We are going to learn getting inputs. 3 00:00:06,880 --> 00:00:14,510 So Donna this far from the resource section of this course is lesson 0 to get input. 4 00:00:14,510 --> 00:00:14,820 Is it 5 00:00:18,490 --> 00:00:22,610 chaotic and put it in the Fossum projects for the 6 00:00:26,980 --> 00:00:28,100 and then zip it 7 00:00:33,590 --> 00:00:34,910 Venditti Yeah. 8 00:00:34,930 --> 00:00:37,150 Is it far. 9 00:00:37,860 --> 00:00:43,170 And now you have a new folder open the folder and never click 10 00:00:47,780 --> 00:01:01,250 so far has the same mean sections you have the comments get input and the comments also seized in this 11 00:01:01,300 --> 00:01:09,730 file this program prompts a user to enter the name and then prints hello followed by the name. 12 00:01:09,830 --> 00:01:15,170 So that is who is compiled this program and run it to see what it does. 13 00:01:18,420 --> 00:01:23,650 Take on run and then click on compare. 14 00:01:23,760 --> 00:01:27,320 Now if you have a new file called Get input EIC. 15 00:01:29,160 --> 00:01:41,680 So let's navigate to this folder rightly copy the to open your command prompt and you can clear screen 16 00:01:41,680 --> 00:01:46,780 by typing see how s and pressing into. 17 00:01:48,000 --> 00:01:58,440 Now we go back to their pattern directory my type ECD followed by spacebar followed by DOT and another. 18 00:01:58,440 --> 00:02:04,280 So it is you bring up to the pattern directory and now we're here. 19 00:02:04,630 --> 00:02:17,000 We can text CV and directly to paste a path daily copy presenter time to view the contents of this folder. 20 00:02:17,260 --> 00:02:28,240 They should be getting input Casey which is this file that is run this time get press attack key for 21 00:02:28,270 --> 00:02:38,710 auto completion press attack key again and you get EFA and you run PRESENTER And now he asks for your 22 00:02:38,710 --> 00:02:48,240 name type your name in presenter and he says hello full by your name. 23 00:02:48,280 --> 00:02:51,410 So this is the behaviour of the program. 24 00:02:51,440 --> 00:02:56,160 Now let me explain how it works. 25 00:02:56,560 --> 00:03:05,310 We have the format specification to tell the assembler it is a pfa console based application. 26 00:03:05,410 --> 00:03:10,750 The entry point is setting from the start label which is over here 27 00:03:19,620 --> 00:03:27,460 and we have the include directive to include the library for all Windows programs. 28 00:03:27,480 --> 00:03:35,170 And here we specify a constant constants are normally specifying how capital letters. 29 00:03:35,340 --> 00:03:45,880 And here if you want to specify 16 for this content and this commander tell you that this constant is 30 00:03:46,030 --> 00:03:46,580 constant. 31 00:03:46,590 --> 00:03:54,440 To specify the maximum size of input strings we are willing to take this constant is used over here. 32 00:03:54,650 --> 00:04:07,510 When we declare a variable called input string and always been using No it is used here and then we 33 00:04:07,510 --> 00:04:18,710 have the separator followed by the data section where we specify the hardcoded strings you have two 34 00:04:18,710 --> 00:04:26,250 strings one string is into name and then you have to enter your name string. 35 00:04:26,480 --> 00:04:34,280 He had a string is it would message string and you have a mis history has this string Hello followed 36 00:04:34,280 --> 00:04:47,390 by a place holder the place holder syntax has a percentage sign followed by the type of data that is 37 00:04:47,390 --> 00:04:51,270 to be placed in here so s means string. 38 00:04:51,500 --> 00:04:59,870 So when this program runs he will replace this percentage has the string that you specify so the string 39 00:04:59,870 --> 00:05:11,080 that is going to replace this is coming from here the input string issue we get from the user data allies 40 00:05:11,170 --> 00:05:19,580 explain then we have a new section called BSA section a media sensation. 41 00:05:20,010 --> 00:05:28,270 Here's the section where you specify variables which are on the sign so in this case we use the Christian 42 00:05:28,270 --> 00:05:35,900 map to indicate that the value has not been assigned to these variables. 43 00:05:35,900 --> 00:05:43,930 Now the difference between the time the assesses data contains those variables which has a values assigned 44 00:05:43,930 --> 00:05:53,780 to them and b assess contain those variables which is not the same any values yet. 45 00:05:54,200 --> 00:06:01,470 If you want increase strings we use Navy but over here we can also use VB if you want to create a single 46 00:06:01,470 --> 00:06:13,360 by VI in this case we want to create 4 by for buying variable for example to store integer numbers so 47 00:06:13,480 --> 00:06:18,930 D means to the data of table. 48 00:06:19,400 --> 00:06:23,360 So in programming in Windows API. 49 00:06:24,020 --> 00:06:25,480 Double what it means for bytes. 50 00:06:27,350 --> 00:06:39,440 So these are numbers and here we declare a string string which is not enough to input how a name. 51 00:06:40,010 --> 00:06:50,780 So we call it input string a decline D.B. this out here VB but differences over here we already specify 52 00:06:50,780 --> 00:06:52,820 the string. 53 00:06:52,850 --> 00:07:04,540 Oh here we declare a string which is 16 bytes long Max input size is referring to the constant sixteen 54 00:07:05,770 --> 00:07:08,790 and your plus one image 17. 55 00:07:09,010 --> 00:07:16,940 And the reason why you plus one is so that he leave a room for the 0 Terminator Nen view P means to 56 00:07:16,940 --> 00:07:27,760 duplicate to duplicate the empty string over the sixteen bytes so question my here is hang on me zero 57 00:07:28,060 --> 00:07:28,840 now. 58 00:07:28,950 --> 00:07:38,930 There's nothing in there so now that you declared the BSA session in a session is the taxation. 59 00:07:38,940 --> 00:07:40,660 This is entry point. 60 00:07:41,410 --> 00:07:52,690 So first thing we do is to call the function to show the string to name which is string and it will 61 00:07:52,690 --> 00:08:02,730 print this line to name or here and tell you name after printing this night and turning your cursor 62 00:08:02,730 --> 00:08:08,840 will remain on the same line because there is no new line characters here. 63 00:08:09,010 --> 00:08:13,000 So the is here for you to put your name. 64 00:08:14,110 --> 00:08:17,300 Then the second part is you would declare handle. 65 00:08:18,760 --> 00:08:27,290 You will call the gate function gets turned a handle function to create a handle and this is needed 66 00:08:27,290 --> 00:08:34,250 and because of the next function refer the re file requires a handle. 67 00:08:34,250 --> 00:08:41,700 That's why you need to create a handle here first so that you can use it in this refile function if 68 00:08:41,700 --> 00:08:43,810 you only get more details. 69 00:08:43,950 --> 00:08:57,240 You can search for m s t n type missed here in here 3 far painting the first one and you can see really 70 00:08:57,320 --> 00:09:05,080 far has these barometers 1 2 3 4 5 barometers which corresponds to these fiber returns. 71 00:09:07,580 --> 00:09:11,880 And one other parameter is her input handle. 72 00:09:12,010 --> 00:09:21,490 She can see from here as you learn from the ICC for DVD when you push barometers to. 73 00:09:21,970 --> 00:09:29,520 You push them in reverse order from the parameter list in the API that's the reason why you see here 74 00:09:29,910 --> 00:09:38,130 in the API SSA and documentation shows the order of the parameter is up to down top to bottom. 75 00:09:38,310 --> 00:09:44,270 By then you push it to this day you push it in reverse order from bottom to the top. 76 00:09:44,820 --> 00:09:51,920 So when you reduce refire first parameter is here corresponding to this 77 00:10:01,250 --> 00:10:03,560 and your second parameter is here. 78 00:10:03,560 --> 00:10:12,860 The input string corresponding to LP buffer and a parameter is your no bias to read which corresponds 79 00:10:12,860 --> 00:10:15,590 to this in the fourth barometer. 80 00:10:15,600 --> 00:10:17,430 Is here by two right. 81 00:10:18,680 --> 00:10:20,460 It is corresponding to this. 82 00:10:20,740 --> 00:10:24,970 And the last one is overlap which we live in is blank now. 83 00:10:26,210 --> 00:10:30,150 So now we know that even in this to use handle. 84 00:10:30,140 --> 00:10:37,880 That's why we need to create a handle here using the get standard handle and this input handle here 85 00:10:38,490 --> 00:10:40,050 is created. 86 00:10:40,430 --> 00:10:41,810 The clay out here. 87 00:10:41,810 --> 00:10:47,000 Input handle Ed. Clay has a number so that we can use this here. 88 00:10:50,670 --> 00:10:52,090 So now let's take a look. 89 00:10:52,110 --> 00:10:57,410 Head get standard handle by looking at a Microsoft M is the n library. 90 00:11:00,670 --> 00:11:01,640 Standard handle 91 00:11:05,070 --> 00:11:05,830 the first result. 92 00:11:07,450 --> 00:11:09,160 So get ahead get handed. 93 00:11:09,680 --> 00:11:13,090 Extend a hand to a sense one time to handle this. 94 00:11:16,260 --> 00:11:22,330 So the return type he's either fashioned sexist the written word is a handle. 95 00:11:23,160 --> 00:11:24,850 So that's why we're here. 96 00:11:25,200 --> 00:11:31,290 The past the return value in your ex Navy CV. 97 00:11:31,300 --> 00:11:33,750 He could handle by moving in there. 98 00:11:35,410 --> 00:11:43,660 So as you recall every time we call a function in the we know API if we return the result in here X 99 00:11:44,460 --> 00:11:46,900 so over here can stand at hand. 100 00:11:48,090 --> 00:11:57,420 Guess their handle and returns the result he X and you want to see if the handle inside this variable 101 00:11:57,900 --> 00:12:05,360 input handle so that we can use it far as the second parameter. 102 00:12:05,670 --> 00:12:13,580 Now the barometer for Gates and the he may specify the time will handle and I believe he used his standard 103 00:12:13,810 --> 00:12:14,840 put handle. 104 00:12:16,950 --> 00:12:23,120 So that's why you need to call this function now you understand this. 105 00:12:23,120 --> 00:12:31,560 You can come to the refined so the and use the to handle an input how nervous we obtain from here. 106 00:12:31,730 --> 00:12:42,740 In order to reach far so let's go back to the MSP and how do the name other function is called refine. 107 00:12:42,780 --> 00:12:45,530 You actually can read more and just fast. 108 00:12:45,580 --> 00:12:49,840 In this case we are using this function to read a line from the console. 109 00:12:51,370 --> 00:12:56,890 So we need this to read your input here. 110 00:12:56,980 --> 00:13:07,340 So over here whenever you type we'll be safe in this string in blue buffer helping buffer the he's in 111 00:13:07,340 --> 00:13:07,610 here. 112 00:13:10,630 --> 00:13:15,620 So there is a reason why we need to delay the input string up here 113 00:13:18,940 --> 00:13:24,440 so the maximum number of bytes characters is 16 114 00:13:27,830 --> 00:13:29,990 if your name is longer than 16. 115 00:13:29,990 --> 00:13:33,020 You have to increase this value here. 116 00:13:35,540 --> 00:13:38,350 So after reading from the console. 117 00:13:39,280 --> 00:13:43,590 He will save your name inside the string. 118 00:13:43,590 --> 00:13:46,500 So now in this input string has got your name. 119 00:13:46,500 --> 00:13:48,860 Now we move on to the next function. 120 00:13:49,110 --> 00:13:51,560 We are going to print f now. 121 00:13:51,570 --> 00:13:54,030 This time we used print f two barometers. 122 00:13:55,740 --> 00:14:02,640 If you look here your first perimeter is a Hopwood message string which is here. 123 00:14:02,880 --> 00:14:12,440 Use here and your second barometer is a name in buffering which comes from here. 124 00:14:12,660 --> 00:14:20,240 So the input string will be replacing your percentage has so when you run when you can't print print 125 00:14:20,330 --> 00:14:21,030 f Lupin. 126 00:14:21,040 --> 00:14:21,640 Hello 127 00:14:24,110 --> 00:14:32,810 because hello comes from the uppermost string and then any priest he ever made history he will substitute 128 00:14:33,500 --> 00:14:44,220 this percentage as if the second string in boosting and that's why you get union Hello followed by your 129 00:14:44,220 --> 00:14:45,120 name. 130 00:14:46,580 --> 00:14:47,430 Okay. 131 00:14:47,640 --> 00:14:52,370 And then once you've finished then you're supposed to clean this text. 132 00:14:52,730 --> 00:14:54,720 So here is a mistake here. 133 00:14:54,720 --> 00:15:01,820 This I should be and as to why the Times too because you're losing to barometers to the stack. 134 00:15:01,830 --> 00:15:06,890 Each barometer that you push through minus 4 bytes from the stack address. 135 00:15:07,080 --> 00:15:11,750 So when you push to carry this a minus invites two times voice. 136 00:15:12,600 --> 00:15:16,700 So you have to add back to these words. 137 00:15:16,830 --> 00:15:23,570 So this one pushes one you would use it for both use pushes and energy with a fallback by so totally 138 00:15:23,640 --> 00:15:24,520 invites. 139 00:15:24,540 --> 00:15:27,800 So this is how you box for peanuts. 140 00:15:28,010 --> 00:15:38,310 Notice that for the Microsoft API functions you don't have to enlist a pony for a C functions which 141 00:15:38,310 --> 00:15:41,550 is non make so API you need to clean this thing. 142 00:15:42,600 --> 00:15:49,890 So if you have three parameters you had to put for those three or four parameters push here to put forth 143 00:15:50,510 --> 00:15:51,740 and so on. 144 00:15:52,230 --> 00:15:59,770 And finally you come to their last function issue exit process and the program ends. 145 00:15:59,820 --> 00:16:10,070 Now notice here you have to have the parts because you are using standard Hinder and refile and standard 146 00:16:10,100 --> 00:16:14,470 handler comes from the country too. 147 00:16:14,520 --> 00:16:22,350 So you need to end is and then refile also comes from country 2. 148 00:16:23,400 --> 00:16:25,830 So you need to add another line here sir. 149 00:16:27,630 --> 00:16:31,740 So this is how the input string works. 150 00:16:31,980 --> 00:16:35,180 And feel free to experiment with this. 151 00:16:35,440 --> 00:16:44,970 I modify to change any number of strings and you want to show a number of substitution strings and you 152 00:16:44,970 --> 00:16:45,570 want these. 153 00:16:47,430 --> 00:16:50,560 So yes I for this video in lesson. 154 00:16:50,580 --> 00:16:50,980 Thank you. 155 00:16:50,980 --> 00:16:52,800 How I see you in a song.