|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Hi,
I am writing a console program in Pascal. It needs to ask the user for a date, and then submit this date to 8 other pascal programs that have already been written. These 8 other programs then do their own thing with the date (create files etc.) I was wondering what the best way to structure this would be? Should I copy all 8 original PAS files into my new file? This could potentially get very messy, as each of the PAS files has variables and constants etc, and if I did it this way wouldn't I have to combine all the variables in one area, and make sure that no two variables have the same name etc etc. I'm not even sure if this is possible really. Is there an easy way so that each original program retains its own 'space' and be completely separate from the other modules, while still being able to access about 10 lines of code at the beginning of the new program? I'm using the Free Pascal compiler. Thanks! |
|
#2
|
||||
|
||||
|
If the other programs are written in Pascal, each program would start with something like this:
Code:
program Somename; const .... var .... begin .... rest of stuff end. All you have to do is convert it to: Code:
procedure Somename; const .... var .... begin end; Note the change from "end." to "end;" in the last line and we renamed "program" to "procedure" Now you can call these procedures from your main program. Since you've made the variables all declared within a procedure, they are scoped to the procedure and its descendants and will not conflict with variables in other procedures.
__________________
Up the Irons What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home. "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest Down with Sharon Osbourne Puzzle of the Month solved by sizeablegrin, etienne141 and L7Sqr, superior C/C++ programmers of the month |
|
#3
|
|||
|
|||
|
Thanks very much Scorpions4eva!
I will go and do that right now. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Delphi Programming > How to structure this program? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|