Jump to content

How Do I Put Program into Sub Programs / Modules

- - - - -

  • Please log in to reply
2 replies to this topic

#1
MrAnderson

MrAnderson

    Newbie

  • Members
  • Pip
  • 8 posts
Can Anyone Help Me!
I have tried to place my program into Procedures, But it keeps crashing at launch.
It compiles successfully though.

Here's the Code.

It's not the entire program, I just tried one single module, but i can't get it to run .
Also I'm suppose to store the data entered in two arrays which is declared in the MAIN function. Do i need to put this in as parameters for the functions.

I'm lost, Not good with functions and subprograms. It has never been taught to me before. I just have the basic understanding.


Program Expenditure;


Var

CustomerNames : array[1..10] of String;

ExpenditureAmt: array[1..10] of String;


{Modules/Procedures For The Main Function}

Procedure InputData;


Var

Terminate  :Integer;

CustomerID :Integer;


Begin

	Terminate := 0;

	CustomerID:= 0;

	

	While Terminate <> 0 do

		Begin

			CustomerID := CustomerID + 1;

			Writeln ('Input the First and Last Names of the Customer');

			Readln (CustomerNames[CustomerID]);

			Writeln('Input the expenditure of ' , CustomerNames[CustomerID]);

			Readln (ExpenditureAmt[CustomerID]);

			

			Writeln ('To Terminate Data Entry Press 0 or ANY Other Number TO Continue');

			Readln (Terminate);	

		End;

End;



{START MAIN}

Begin

InputData

End.

{END MAIN}



#2
Zorfox

Zorfox

    Learning Programmer

  • Members
  • PipPipPip
  • 36 posts
When you say crash what does it do? Is it a quick flash of the screen and then end?

It appears you are assigning terminate the value of 0 to initialize it. Then your saying do stuff while terminate does not equal 0. Basically the procedure will exit immediatley. Try initializing terminate with 1 and see how that works.

#3
MrAnderson

MrAnderson

    Newbie

  • Members
  • Pip
  • 8 posts
lol!
Thanks Bro, I didnt realized it was set to 0.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users