use of type,procedure,function

what is the use of the type definition.
what is the use of procedure.
how is function used
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The "type" definition can be used to create aliases or structures.

For example, you could create an alias for a string[10]:

  mystring = string[10];

and then use "mystring" wherever you would use string[10].  That way, if you want to change the length of the string, you would only have to change it in the type definition, and not everywhere you defined it.

You can also define structures.  A structure is a group of primitive types (such as integers), or even other structures.  A classic example:

  employee = record
               firstname, lastname :string;
               salary :real;

This way you can group all of the info for one employee in a single type, and use that type for your variables used to store employees.

So rather than do this:

  employee1firstname :string;
  employee1lastname :string;
  employee1salary :real;
  employee2firstname :string;
  employee2lastname :string;
  employee2salary :real;

you could do this:

  employee = record
               firstname, lastname :string;
               salary :real;

  employee1, employee2 :employee;


Procedures are sub programs used within a program to do a certain task that you might need to do repetitively.

For example, you might print a list of scores to the screen several times.  Rather than code this out several times, you write the code one, pace it in a procedure, and call the procedure whenever you want to do this.

A function is the same as a procedure, with one returns a value.

You might want to write a function to find the greatest common factor between two numbers.  This would in theory be a procedure, but since you want a value returned from it (the answer), you make it into a function.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
My name is MudSystems EngineerCommented:
Excuse me MR. k_f_v but i think you made a mistake in: 

I think you give the points to someone else... can you correct this situation please...
Function got a return value but procedure don't have a return value. Function can only use within VAR. Function must declare a variables and this variables just for use in a fuction. It cannot share variables with Main.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.