Kamis, 20 Januari 2011

PROCEDURE FUNCITION

PROCEDURE

1. Preliminary In programming, when the size and complexity of the program is small, it is no problem when used in conventional encoding method that is monolithic. But when the program becomes increasingly large and complex, monolithic method would be very difficult for programming and program modifications, not to mention tracking when problems occur. Making the program with a variety of functions and capabilities will also be difficult, because it must always pay attention to the overall program. 


It required a modular programming method, where the programmer can separate certain processes to a separate part of the program. This separation allows the development of complex programs becomes easier, because certain processes have been isolated to minimize the complexity of the overall program code. In Pascal, one way to perform the separation is to use the procedure. 


The procedure is a separate processing code that is placed in a separate block that serves as a subprogram (a program that is part of the overall program.) With this procedure, the program can be more easily made and more easily understood so that more easily developed. Because the procedure also accommodates the provision and return value, then the whole program will also still be able to manipulate the value as well as a monolithic program.
2. The word used reserve Program: The specification name of the program and its parameters, is decorative and not affect the overall program itself 


Uses: define the name of the unit to be referenced by the program Var: linking an identifier and its type with a location in memory where the values of these types can be stored Begin: starting a program block End: end a program block 


Procedure: part of a program that runs a specific process, often based on a set of parameters If: mention the conditions for a statement that can be executed Then: mention the statement of action must be executed when the conditions are met Repeat: define statement or block of statements that will be repeated until the state stops filled Until: defines the state of rest for the loop that begins with the Repeat Case: mention the statement expression that searches for the appropriate conditions based on the condition of the available options statement 


Of: the word is used in conjunction Case reserves to mention the choice of appropriate conditions and actions to be executed when a condition selected Do: used to describe the action to perform For: defines the initial value iteration To: defines the value of the final iteration (iteration positive) Record: used to declare the record contains a collection of data from various types of data Type: used to declare an identifier that has a specific data type
3. The procedure used Write: writing a variable into a component file in a text file used to write one or more values to a file Writeln: executing the write procedure, then pulled out a marker of end-of-line (EOL) to the program files Read: read a file into a variable component, in a text file used to read one or more values into one or more variables Readln: executes a read procedure, and then move to the next line in program files Clrscr: cleaning the screen and return the cursor to the top left corner 




a.       Program pertama
Program m7c1;
uses wincrt;
var
     pil : char;
procedure menu;
begin
     clrscr;
     writeln ('MENU');
     writeln ('1. Bakso');
     writeln ('2. Bakmi');
     writeln ('3. Siomay');
     writeln ('4. Soto');
     writeln ('0. Bayar');
end;
procedure kerja (n:char);
begin
     case n of
     '1': begin
               write ('Pesan Bakso'); readln;
          end;
     '2': begin
               write ('Pesan Bakmi'); readln;
          end;
     '3': begin
               write ('Pesan Siomay'); readln;
          end;
     '4': begin
               write ('Pesan Soto'); readln;
          end;
     '0': begin
               writeln ('Bayar dan bye');
          end;
     end;
end;
begin
     repeat
           menu;
           writeln;
           write ('Pilihan anda? '); readln (pil);
           kerja (pil);
     until pil = '0';
end.

Tidak ada komentar:

Posting Komentar