Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4095
Number of posts: 14004

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Segmenting a program. Posted by Descolada on 16 Mar 2003 at 4:52 PM
Hi, I really need some help with Pascal. I took a five month high school course on think Pascal, we did types, arrays, functions,procedures,polys etc, but we never got into any of the complicated stuff like pointers and resources. Now I have written out a program that's just a little bit too long. I need to brake my program up into a couple smaller parts right? How? I make a new one of those .p files, then add it to my program. I always get errors like, "there are two main programs", or "uses expected here". There are some special things I have to write such as: uses, interfaces, and implementation, but after a lot of net searching I cant figure it out. I could use some help please.
Report
Re: Segmenting a program. Posted by zibadian on 17 Mar 2003 at 12:07 AM
: Hi, I really need some help with Pascal. I took a five month high school course on think Pascal, we did types, arrays, functions,procedures,polys etc, but we never got into any of the complicated stuff like pointers and resources. Now I have written out a program that's just a little bit too long. I need to brake my program up into a couple smaller parts right? How? I make a new one of those .p files, then add it to my program. I always get errors like, "there are two main programs", or "uses expected here". There are some special things I have to write such as: uses, interfaces, and implementation, but after a lot of net searching I can’t figure it out. I could use some help please.
:
You mean you want to know how to write units. Here is the basic appearance of a unit:
unit UnitName; { this name must be equal to the filename }

interface

{ here you declare all the functions/procedures/variables/types which 
are to be used by the program. example:}

procedure WriteProgName; { Note: begin-end part }

implementation

uses
  Crt;

{ here you declare all the private functions/procedures/variables/types.
  You also write the implementations of the previously declared
  routines. }

procedure WriteProgName;
begin
  Clrscr;
  writeln('My program');
  writeln;
  writeln('Designed by: me');
end;

end.

In your program you can add UnitName to the uses list and then use WriteProgName like any other procedure. I hope this was what you were looking for.
Report
Re: Segmenting a program. Posted by Descolada on 17 Mar 2003 at 1:00 AM
IT WORKS!!!!!!!!!!!!!!!! YAY! OH BOY! SUPER! I've spent so long trying to figure that out! Thanks!



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.