[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

use of type,procedure,function

Posted on 1999-11-02
3
Medium Priority
?
188 Views
Last Modified: 2010-04-16
what is the use of the type definition.
what is the use of procedure.
how is function used
0
Comment
Question by:k_f_v
3 Comments
 
LVL 5

Accepted Solution

by:
scrapdog earned 160 total points
ID: 2179045
The "type" definition can be used to create aliases or structures.

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

type
  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:

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

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:

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

you could do this:

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

var
  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 difference...it 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.
 
0
 
LVL 6

Expert Comment

by:My name is Mud
ID: 2179070
Excuse me MR. k_f_v but i think you made a mistake in:

  http://www.experts-exchange.com/jsp/qShow.jsp?ta=pascal&qid=10222890 

I think you give the points to someone else... can you correct this situation please...
0
 
LVL 1

Expert Comment

by:cedric80
ID: 2263306
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.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There’s hardly a doubt that Business Communication is indispensable for both enterprises and small businesses, and if there is an email system outage owing to Exchange server failure, it definitely results in loss of productivity.
The onset of year 2018 has been a usual business for IT teams still struggling to find their way out in terms of strengthening their cloud security.
There may be issues when you are trying to access Outlook or send & receive emails or due to Outlook crash which leads to corrupt or damaged PST file. To eliminate the corruption from your PST file, you need to repair the corrupt Outlook PST file. U…
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question