Hello In this session.
We are going to learn getting inputs.
So Donna this far from the resource section of this course is lesson 0 to get input.
Is it
chaotic and put it in the Fossum projects for the
and then zip it
Venditti Yeah.
Is it far.
And now you have a new folder open the folder and never click
so far has the same mean sections you have the comments get input and the comments also seized in this
file this program prompts a user to enter the name and then prints hello followed by the name.
So that is who is compiled this program and run it to see what it does.
Take on run and then click on compare.
Now if you have a new file called Get input EIC.
So let's navigate to this folder rightly copy the to open your command prompt and you can clear screen
by typing see how s and pressing into.
Now we go back to their pattern directory my type ECD followed by spacebar followed by DOT and another.
So it is you bring up to the pattern directory and now we're here.
We can text CV and directly to paste a path daily copy presenter time to view the contents of this folder.
They should be getting input Casey which is this file that is run this time get press attack key for
auto completion press attack key again and you get EFA and you run PRESENTER And now he asks for your
name type your name in presenter and he says hello full by your name.
So this is the behaviour of the program.
Now let me explain how it works.
We have the format specification to tell the assembler it is a pfa console based application.
The entry point is setting from the start label which is over here
and we have the include directive to include the library for all Windows programs.
And here we specify a constant constants are normally specifying how capital letters.
And here if you want to specify 16 for this content and this commander tell you that this constant is
constant.
To specify the maximum size of input strings we are willing to take this constant is used over here.
When we declare a variable called input string and always been using No it is used here and then we
have the separator followed by the data section where we specify the hardcoded strings you have two
strings one string is into name and then you have to enter your name string.
He had a string is it would message string and you have a mis history has this string Hello followed
by a place holder the place holder syntax has a percentage sign followed by the type of data that is
to be placed in here so s means string.
So when this program runs he will replace this percentage has the string that you specify so the string
that is going to replace this is coming from here the input string issue we get from the user data allies
explain then we have a new section called BSA section a media sensation.
Here's the section where you specify variables which are on the sign so in this case we use the Christian
map to indicate that the value has not been assigned to these variables.
Now the difference between the time the assesses data contains those variables which has a values assigned
to them and b assess contain those variables which is not the same any values yet.
If you want increase strings we use Navy but over here we can also use VB if you want to create a single
by VI in this case we want to create 4 by for buying variable for example to store integer numbers so
D means to the data of table.
So in programming in Windows API.
Double what it means for bytes.
So these are numbers and here we declare a string string which is not enough to input how a name.
So we call it input string a decline D.B. this out here VB but differences over here we already specify
the string.
Oh here we declare a string which is 16 bytes long Max input size is referring to the constant sixteen
and your plus one image 17.
And the reason why you plus one is so that he leave a room for the 0 Terminator Nen view P means to
duplicate to duplicate the empty string over the sixteen bytes so question my here is hang on me zero
now.
There's nothing in there so now that you declared the BSA session in a session is the taxation.
This is entry point.
So first thing we do is to call the function to show the string to name which is string and it will
print this line to name or here and tell you name after printing this night and turning your cursor
will remain on the same line because there is no new line characters here.
So the is here for you to put your name.
Then the second part is you would declare handle.
You will call the gate function gets turned a handle function to create a handle and this is needed
and because of the next function refer the re file requires a handle.
That's why you need to create a handle here first so that you can use it in this refile function if
you only get more details.
You can search for m s t n type missed here in here 3 far painting the first one and you can see really
far has these barometers 1 2 3 4 5 barometers which corresponds to these fiber returns.
And one other parameter is her input handle.
She can see from here as you learn from the ICC for DVD when you push barometers to.
You push them in reverse order from the parameter list in the API that's the reason why you see here
in the API SSA and documentation shows the order of the parameter is up to down top to bottom.
By then you push it to this day you push it in reverse order from bottom to the top.
So when you reduce refire first parameter is here corresponding to this
and your second parameter is here.
The input string corresponding to LP buffer and a parameter is your no bias to read which corresponds
to this in the fourth barometer.
Is here by two right.
It is corresponding to this.
And the last one is overlap which we live in is blank now.
So now we know that even in this to use handle.
That's why we need to create a handle here using the get standard handle and this input handle here
is created.
The clay out here.
Input handle Ed. Clay has a number so that we can use this here.
So now let's take a look.
Head get standard handle by looking at a Microsoft M is the n library.
Standard handle
the first result.
So get ahead get handed.
Extend a hand to a sense one time to handle this.
So the return type he's either fashioned sexist the written word is a handle.
So that's why we're here.
The past the return value in your ex Navy CV.
He could handle by moving in there.
So as you recall every time we call a function in the we know API if we return the result in here X
so over here can stand at hand.
Guess their handle and returns the result he X and you want to see if the handle inside this variable
input handle so that we can use it far as the second parameter.
Now the barometer for Gates and the he may specify the time will handle and I believe he used his standard
put handle.
So that's why you need to call this function now you understand this.
You can come to the refined so the and use the to handle an input how nervous we obtain from here.
In order to reach far so let's go back to the MSP and how do the name other function is called refine.
You actually can read more and just fast.
In this case we are using this function to read a line from the console.
So we need this to read your input here.
So over here whenever you type we'll be safe in this string in blue buffer helping buffer the he's in
here.
So there is a reason why we need to delay the input string up here
so the maximum number of bytes characters is 16
if your name is longer than 16.
You have to increase this value here.
So after reading from the console.
He will save your name inside the string.
So now in this input string has got your name.
Now we move on to the next function.
We are going to print f now.
This time we used print f two barometers.
If you look here your first perimeter is a Hopwood message string which is here.
Use here and your second barometer is a name in buffering which comes from here.
So the input string will be replacing your percentage has so when you run when you can't print print
f Lupin.
Hello
because hello comes from the uppermost string and then any priest he ever made history he will substitute
this percentage as if the second string in boosting and that's why you get union Hello followed by your
name.
Okay.
And then once you've finished then you're supposed to clean this text.
So here is a mistake here.
This I should be and as to why the Times too because you're losing to barometers to the stack.
Each barometer that you push through minus 4 bytes from the stack address.
So when you push to carry this a minus invites two times voice.
So you have to add back to these words.
So this one pushes one you would use it for both use pushes and energy with a fallback by so totally
invites.
So this is how you box for peanuts.
Notice that for the Microsoft API functions you don't have to enlist a pony for a C functions which
is non make so API you need to clean this thing.
So if you have three parameters you had to put for those three or four parameters push here to put forth
and so on.
And finally you come to their last function issue exit process and the program ends.
Now notice here you have to have the parts because you are using standard Hinder and refile and standard
handler comes from the country too.
So you need to end is and then refile also comes from country 2.
So you need to add another line here sir.
So this is how the input string works.
And feel free to experiment with this.
I modify to change any number of strings and you want to show a number of substitution strings and you
want these.
So yes I for this video in lesson.
Thank you.
How I see you in a song.