Wednesday, December 8, 2010

In which we learn about procedures

Konbanwa, minna-san!
I...get obsessed with different series very easily. Sometimes my love for a certain series dies out. (For example, I used to adore Hot Gimmick, but now it's...meh. It's not like I don't love it anymore (I mean - who can resist Ryoki-sama? *wink/fangirl squeal*), but it's just not as important to me.) But at other times, I will continue to love that series forever and ever... Like Inuyasha. I started watching it, what, six...years ago? I still adore it. And FullMetal Alchemist, which I started watching at around the same time. Of course, I absolutely cannot forget Detective Conan/Case Closed~! I'm a huge mystery/detective fan, so I love this one. Right now, I love Durarara!! It has a really unique/amazing/epic/addictive storyline and even more unique/amazing/epic/addictive characters. I don't want to stop loving it...


From left: Izaya Orihara, Anri Sonohara, Mikado Ryuugamine, Masomi Kida, Shinra Kishitani, Shizuo Heiwajima. The figure in the moon is Celty Sturlson, a dullhan.
Durarara!! (c) Ryohgo Narita
 Ah, but these are simply the ramblings of a crazy fangirl/writer. To get back on topic...

According to my Programming Glossary, a procedure is a subprogram that performs a defined task. It is very similar to a function. However, a procedure does not have a result (because it's not returning a value) and it can have zero or more arguments. An example of a procedure with zero arguments looks like this:

procedure sayHello
     put "Hello!"
end sayHello

sayHello

This code outputs "Hello!"
However, you can "upgrade" it, using an argument. This code will output "Hello, Shizu-chan!"

procedure greetUser (greeting : string, userName : string)
     put greeting + ", " + userName + "!"
end greetUser

greetUser ("Hello", "Shizu-chan")

Simple, ne? *smile*
Of course, if this was Izaya-kun speaking, Shizu-chan would say: "Get out of Ikebukuro!!!"
D'awws, we love you, Shizu-chan~

You can also ask the user to give you the greeting and name. However, then you must make greeting and userName variables (within the procedure, if that makes sense).

procedure greetUser (var greeting : string, var userName : string)
     put greeting", " + userName"!"
end greetUser

var greeting : string
var userName : string

put "Greeting? " ..
get greeting : *

put "Name? " ..
get userName

greetUser (greeting, userName)

Got it? *smiles again*

Well, I hope that explanation was plausible. I'm generally horrible at explanations (and you wonder how I'll ever become a teacher).

Anyways, after we were taught how to create a procedure, we evaluated ourselves on our understanding of programming. Then we got into groups based on our evaluation. By Friday, Mr. Arkin wants us to fully understand all the concepts of programming! With a bit of work, I'm sure we can do it~!

Ganbatte, minna-san~!

No comments:

Post a Comment