In this lecture with a great script which will give to use it has the possibility to reject their inputs.
So great script called in a stage star David siobhán.
And on the next line right common I read data from users and make them option to recheck it for data
if data if maybe if provided data are correct
so we can now start gathering some data.
We can ask the user for name so equal and our name
and read user input into a variable called name then we will ask for age and your age and we will read
it into the age.
And then we ask also for the department
and thirdly are the.
Now we can bring to users some summary of what they typed so we can write.
You have and following
so on the next line the bright name followed by output of the whatever name and the same.
We will do for h h followed by output of variable h and the same also for department
or I.
I forgot to read the department of Grabow.
So I will print that variable and I will read it on proper place.
After asking the users department
I can now structure the summary output
and what to do next.
We have displayed to users dead imports.
Now we need to ask them if they agree with data they have entered.
So right.
Is that correct.
And to suggest yes or no possibility is that correct.
Then it does answer into a variable called answer surprisingly.
And now it's time for using a gay structure.
So depending of what ANS-Forth user has chosen that means yes represented by y character are not represented
by any character.
So depending on these Bouvard decide what should happen now we will start with K structures so right
case followed by variable for fall by keyboard in.
So if that variable answer is equals to y in uppercase or which is represented as pipe or it is equal
to y in lowercase we perform some bloke of commands.
Please remember that if you want to run some book of commands for more than one of those as in our case
for uppercase and lowercase VI we don't need to create two or more blocks.
We are herradura using pipe which represents or so if variable bounds for is equal to uppercase of II
or lowercase Why then do the same block of commands for them.
Also don't forget that you need to close the value optional using cried button.
Then if a user has entered why we will save to some file users data so maybe it would be better to just
copy block of code we have already created.
And directed to a file impled not to text.
For example.
And also I will add that to that final few big full signs Ridgeville presence and of these user data
and now I can close this block of commands using Goodbar semicolon and maybe I can put to screen your
data very saved
your
data was saved into employee file.
Now what happens if a user has entered uppercase or lowercase and
before writing commands Please note that I am not using quotation marks around character and this is
not needed as it is only one character which cannot be separated by internal field separator.
My advice for a whole by script is to scroll station Marek's.
If you are working with string which has some space inside.
So if a user entered in a character revealed print nothing was saved.
Around descript again.
If you have an opt
data employee file and finish the section by double semicolon.
Now for a case user will enter something different then why or the character will use asterisk.
But do know why asterisk it is good to mention that gay structure works with wildcards and in the wildcard
as there is a real presence all characters.
So if user didn't answer why or end a character then we will definitely end up in this section because
we are catching all characters here and this is also a reason why we are using asterisk at the bottom
because if we move a static section up for example before section with Vol. II the asterisk section
would be all the better for them and we would never could.
Commands which are inside section we divide value are in sections specified by n character.
So now what would happen if you set or enter to something different.
We will print Verrone answer provided
and we can close the section using double semicolon.
Now we can also close case structure using Issaq keyword so we have basic structure of our script.
But something is missing.
If user will for example ask for yes instead of only y character in that.
Is that correct question.
Descript would reply.
Wrong answer provided and no data will be stored.
User wouldn't need to run the script again so it would be nice to have some option to change user answer
in a case use or provide something different.
And then why or and character and will do that using while loop will keep looping through the code.
If variable called check is equals to zero
now we can specify a body of dialogue using could do and done keyboard
but we should also specify what value has that variable check from the beginning and I will assign zero
to it.
So loop through that code between do and damn if a value of variable check is zero.
Now our Laub would never stop.
As it is 0 and never changing.
So if you want to do a loop to finish we need to change the value of variable check.
So I will invite and and the sections change the value of variable check for example to value 1.
Now if users answer is Y or.
And the value of variable check is not zero.
So that means the loop is finished and won't be repeated if on another case use or first for example
and blah blah he will go to Asterisk section and as there is no changing of value of variable check
then the value of variable check is still 0 and LWB will be continuing with.
Question.
Is that correct.
Now descript is dumb and we can say
ground exec with permission and we can describe no
entry or name.
Peter age 51 Department I-T.
Is that correct.
And Peter says oh I don't have 51.
I'm only 50.
So it is not correct.
So when he Daibes know he got the wrong answer provided as we are taking only the character.
So when he type an he will see nothing was said and the scrip again.
So great it is working perfectly.
So now they're under script again named Peter age 50 Department I.D. and let's say with using Y character
your data were saved in the employee file.
Great except that I have written to him you're dead.
We're saved.
Anyway now let's check that employee file
and we can see that Peter's record over.
Right now we can add another person
Jane age 60 departement age and confident with for example uppercase why and we can check employee file
and grade.
We have two records here.
Screeding works perfectly.
When we go back to scrape
we see that in a while we are starting with line where are we asking users.
Is that correct.
But it is completely up to you.
But to start with it you can for example place the beginning of a while before asking on user name.
So then if it was of reply something different then why or correct that.
Then the user would be forced to enter data as name age and department again.