•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Pascal and Delphi section within the Software Development category of DaniWeb, a massive community of 426,937 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,420 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Pascal and Delphi advertiser: Programming Forums
Views: 6342 | Replies: 62
![]() |
•
•
Join Date: Nov 2007
Posts: 44
Reputation:
Rep Power: 1
Solved Threads: 0
So I started all over since I can't use records. What I wrote here wont compile.
I get these errors
c6.p:23: warning: missing program header
c6.p:23: only one program declaration allowed
c6.p:23: syntax error before `Procedure'
Not sure where I should go from here.
program Assignment6(input, output);
Var
input : text;
temporary_result : real;
equation : string[255];
myArrayEquation : array[1..100] of string[255];
first_digit : char;
num : integer;
BEGIN
assign(input, 'input.txt');
reset(input);
read(input, equation);
end.
procedure ignore_space;
begin
while first_char := ' ' do
read(input, first_digit);
end;
procedure find_number;
begin
num := 0;
while (ord(first_digit) >= ord('0')) and (ord(first_digit) <= ord('9')) do
begin
num := num * 10 + (ord(first_digit) - ord('0'));
read(input, first_digit);
end;
end;
I get these errors
c6.p:23: warning: missing program header
c6.p:23: only one program declaration allowed
c6.p:23: syntax error before `Procedure'
Not sure where I should go from here.
Last edited by Gotovina7 : Nov 19th, 2007 at 8:35 pm.
•
•
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,876
Reputation:
Rep Power: 11
Solved Threads: 193
You are thinking in C. Don't put anything after the end. (that's "end" with a period after it). A program looks just like a giant procedure, with subroutines (procedures and functions) in it.
Did your professor tell you how he expects you to store your equation in an array? Or give any direction on how to solve it?
Did your professor tell you how he expects you to store your equation in an array? Or give any direction on how to solve it?
•
•
Join Date: Nov 2007
Posts: 44
Reputation:
Rep Power: 1
Solved Threads: 0
•
•
•
•
You are thinking in C. Don't put anything after the end. (that's "end" with a period after it). A program looks just like a giant procedure, with subroutines (procedures and functions) in it.
Did your professor tell you how he expects you to store your equation in an array? Or give any direction on how to solve it?
Ooh I see now.
But yea, my prof didn't really say anything about how we store the equation in the array
•
•
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,876
Reputation:
Rep Power: 11
Solved Threads: 193
I think you ought to go sit down with your professor and ask for some more details about how he wants you to solve the problem. If you ask correctly (professors, as all people, generally love to talk about their subject) you might get a lot more information than otherwise, which will help you figure things out. Don't let him push you out. It is his job to help you understand, so if you are still confused about something in particular, just say: "I don't understand why ..." or "If I understand right, I need to ...".
Good luck.
Good luck.
•
•
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,876
Reputation:
Rep Power: 11
Solved Threads: 193
•
•
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,876
Reputation:
Rep Power: 11
Solved Threads: 193
That's because you keep thinking the computer can help you. Computers never help anyone. They're too stupid.
Turn the computer off. Get out some colored paper and some crayons and draw how you (that is, how you, personally) can solve equations like:
1+2+3
-9+10
5*(2+3)
(2*(1+3))-1
(These are ordered by increasing difficulty.) Be sure to nitpick. "First, my eyeball saw '1'. That's a number. Then my eyeball saw a '+'. That's good, because a number needs to be followed by an operator." Etc.
Once you can tell yourself how to solve the problem, then it is time to start thinking in terms of how to make the computer do it. Each step you made might be one or two or three steps the computer will make. Each one of those steps might be made up of even smaller steps.
For example, a big step might be "find the outermost matching parentheses." A smaller step would be something like "find the first '('", and "find the matching ')' [skipping intervening '(' and ')']".
Start thinking your way through this, then when you think you can explain how to do each collection of steps (both big steps and small steps), then post back and I'll help you more.
Turn the computer off. Get out some colored paper and some crayons and draw how you (that is, how you, personally) can solve equations like:
1+2+3
-9+10
5*(2+3)
(2*(1+3))-1
(These are ordered by increasing difficulty.) Be sure to nitpick. "First, my eyeball saw '1'. That's a number. Then my eyeball saw a '+'. That's good, because a number needs to be followed by an operator." Etc.
Once you can tell yourself how to solve the problem, then it is time to start thinking in terms of how to make the computer do it. Each step you made might be one or two or three steps the computer will make. Each one of those steps might be made up of even smaller steps.
For example, a big step might be "find the outermost matching parentheses." A smaller step would be something like "find the first '('", and "find the matching ')' [skipping intervening '(' and ')']".
Start thinking your way through this, then when you think you can explain how to do each collection of steps (both big steps and small steps), then post back and I'll help you more.
Last edited by Duoas : Nov 24th, 2007 at 7:52 pm.
•
•
Join Date: Nov 2007
Posts: 44
Reputation:
Rep Power: 1
Solved Threads: 0
Man I am just soo lost for this assignment. I keep trying different things but nothing works. This is what I got i guess.
The problem is the "num1 := num;" part. I can't seem to get this to work. I get undeclared identifier.
program Assignment6(input, output);
Var
file1 : text;
c : char;
error : boolean;
num1 : integer;
function convert(c: char): integer;
begin
convert := ord(c) - ord('0');
end; { convert }
procedure find_digits(num : integer);
num := 0;
while (ord(c) >= ord('0')) and (ord(c) <= ord('9')) do
begin
num := num * 10 + (ord(c) - ord('0'));
read(file1, c);
end;
end; { find_digits }
procedure ignorespaces;
begin
while c = ' ' do
read(file1, c);
end; { ignore_spaces }
BEGIN
assign(file1, 'input.txt');
reset(file1);
read(file1, c);
error := false;
ignorespaces;
If ((ord(c) >= ord('0')) and (ord(c) <= ord('9'))) then
begin
find_digits;
num1 := num;
end;
end.
The problem is the "num1 := num;" part. I can't seem to get this to work. I get undeclared identifier.
Last edited by Gotovina7 : Nov 24th, 2007 at 7:58 pm.
•
•
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,876
Reputation:
Rep Power: 11
Solved Threads: 193
Your find_digits is good, but it never lets go of "num".
I would make it a function:
Then you can learn num:
You also need that var c because c is always the next character read from the file. If you don't have that, then the last character read from file by find_digits will be lost. Make sense?
Hope this helps.
find_digits;{ What is num? }I would make it a function:
function find_digits( var c: char ): integer;Then you can learn num:
the_number := find_digits( c );You also need that var c because c is always the next character read from the file. If you don't have that, then the last character read from file by find_digits will be lost. Make sense?
Hope this helps.
Last edited by Duoas : Nov 24th, 2007 at 7:58 pm.
![]() |
•
•
•
•
•
•
•
•
DaniWeb Pascal and Delphi Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- C++ Calculator Program (C++)
- Really need help with the interactive Calculator program, or will be dead (C++)
- pascal triangle program (C++)
- starting a calculator program in C (C)
- Java Swing Calculator program not running. It has 0 errors (Java)
- Wierd error messages with calculator program (C++)
- need help with calculator program in C (C)
Other Threads in the Pascal and Delphi Forum
- Previous Thread: RES file creaton under Vista
- Next Thread: Deleting components in D2007



Linear Mode