Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 7th, 2006, 12:26 PM   #1
irish
Programmer
 
Join Date: Nov 2005
Location: Belfast
Posts: 34
Rep Power: 0 irish is an unknown quantity at this point
Little bit of pascal help

Ok so I found out I might be learning pascal for AS Computing. So I started looking at it late last night and ive found it easy enough so far. I have one problem though, I can't work out how to reuse a previous set of code for a later section of the program.

1:	program	XIF
2:
3:	var	value:	integer;
4:
5:	begin
6:		Writeln('Please enter a value for x:');
7:		Readln(value);
8:		if value > 5 then
9:			Writeln('Input accepted');
10:		else
11:			Writeln('Invalid input, try again:');
12:		At this point it would return to line 7 
13:		(to read the input as the value var).
14:	End.

I did google the problem and looked at some tutorial sites, but things like these wouldnt work:

CONDITION:
Readln(value);
	if value > 5 then
		Writeln('Input accepted');
	else
		Writeln('Invalid input, try again:');

GOTO 7;

Btw I am using Turbo Pascal (just for the info).
irish is offline   Reply With Quote
Old Sep 7th, 2006, 12:39 PM   #2
hoffmandirt
Hobbyist Programmer
 
hoffmandirt's Avatar
 
Join Date: Jul 2005
Location: PA
Posts: 125
Rep Power: 4 hoffmandirt is on a distinguished road
Send a message via AIM to hoffmandirt
Did you look up how to write procedures using pascal? I'm not sure if those are what you want, but when I think of reusable code, the first thing that comes to my mind is functions/procedures/sub routines, whatever you want to call them.
hoffmandirt is offline   Reply With Quote
Old Sep 7th, 2006, 1:27 PM   #3
_James_
Newbie
 
Join Date: Sep 2006
Location: UK
Posts: 20
Rep Power: 0 _James_ is an unknown quantity at this point
A Level Computing is not just about programming. If you are good at programming or have a natural ability you will find the AS course boring and simple. A2 is more demanding but still is not too hard for someone with some intelligence. Most people will start it thinking its all programming and probably wont have much experience in programming either. Take a shot gun into theroy lessons to shoot the person who has a huge ego and always answers questions incorrectly(there is always one, two years with this idoit who would never shut up really put me off theory lessons).

Firstly find out what language is taught. It might be pascal, but it could be VB6/.net. Secondly get a book on the language you will be taught. Read it through and then you will find that what you want to do is very easy to accomplish. Thirdly let your teacher teach you the basics. You might not even need a book if the standard of notes and teaching is good. If you have a good teacher you will understand more easily and you can ask questions just like this to them. Good luck
_James_ is offline   Reply With Quote
Old Sep 7th, 2006, 2:11 PM   #4
irish
Programmer
 
Join Date: Nov 2005
Location: Belfast
Posts: 34
Rep Power: 0 irish is an unknown quantity at this point
Quote:
A Level Computing is not just about programming.
I didnt try to say that i thought it was only about programming, i was simply saying that it was between pascal and vb, but my teacher said it was 90% going to be pascal so i started looking at that, im only wanting to be given a slight hint about what way i would/could go about finishing this small prog.

Quote:
Take a shot gun into theroy lessons to shoot the person who has a huge ego and always answers questions incorrectly
I dont know if you mean someone in my class or you are suggesting that I have a huge ego.
If you mean someone in my class: lol
If you mean me: I do not have a huge ego, you might have interpreted what I typed completely wrong.

And I do enjoy theory alot anyway, theres no one in my class that always answers questions wrong (ppl normally go quiet and wait for the teacher to give them the answer if they arent sure what it is lol).

Thanks for the advice anyway
irish is offline   Reply With Quote
Old Sep 7th, 2006, 2:29 PM   #5
_James_
Newbie
 
Join Date: Sep 2006
Location: UK
Posts: 20
Rep Power: 0 _James_ is an unknown quantity at this point
No you have got me all wrong. I was just telling you what A-Level computing is like. I did it a few years ago. You will find that 2/3 of all lessons will be theory. Its very boring at times. Just learn the material and you will be fine. The exams in the first year are largely based on theory and one is parly based on a project.

I was not saying you have a huge ego. I think what you are doing is a good idea. Learning in your own time shows you have a healthy interest in programming and it will come in handy. By asking for help in this forum you have shown that you have no huge ego.

I had a kid in my class for two years who was so anoying. When the teacher would ask a question he would just burt out some random rubbish that was normally very inaccurate without being asked. He would even randomly add to what the teacher was saying without any question being put forward. He was a poor programmer. He was always getting pissed off with me as I would complete the task set quickly and correctly in practical sessions. He would then try to show that my code was wrong just to make himself look good and he never succeded at that. In the end I told him to shut the fuck up. I did it out loud in class when the teacher was going over something I found interesting and wanted to understand. He kept interrupting and it was anoying everyone. The funny thing was he then stod up and left the room and I was told by the teacher that he had wanted to say that all year but could not swear at a student. I was in a bad mood that day, I was wrong to say it out loud.

Anyway. If you know the answer then answer when asked. Dont be a smart ass or you will make everyone else look at you when the teacher asks a question. I had this very issue in Chemistry. Its not good, as in the end even the teacher will ask you for an answer even if you have not put your hand up.
_James_ is offline   Reply With Quote
Old Sep 7th, 2006, 6:05 PM   #6
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Check out procedures and functions. They're not easy, so I'm not going to go into depth - that's what books and teachers are for - but they're basically ways of modularising code so you can re-use it. Look 'em up.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Sep 8th, 2006, 5:13 AM   #7
irish
Programmer
 
Join Date: Nov 2005
Location: Belfast
Posts: 34
Rep Power: 0 irish is an unknown quantity at this point
Thanks lads, bored in a 'study period' (nothing to study this time of year) at the minute so i might as well look em up now .

Thanks again
irish is offline   Reply With Quote
Old Oct 10th, 2006, 7:58 PM   #8
irish
Programmer
 
Join Date: Nov 2005
Location: Belfast
Posts: 34
Rep Power: 0 irish is an unknown quantity at this point
A hell of alot easier than I first thought it would be, i just needed to use:

repeat
         <statements>
until <condition>

Thanks for the advice ^^
irish is offline   Reply With Quote
Old Oct 10th, 2006, 8:34 PM   #9
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
You still need to look up procedures. They can be invoked from any point, whereas your example only reuses the code at that one particular place.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Oct 11th, 2006, 8:53 AM   #10
irish
Programmer
 
Join Date: Nov 2005
Location: Belfast
Posts: 34
Rep Power: 0 irish is an unknown quantity at this point
Thanks for the advice DaWei ^^
irish is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pascal? Indigno Other Programming Languages 14 Sep 24th, 2006 2:38 AM
Object Pascal Q: object instance as parameter KodeKid Delphi 1 May 16th, 2006 12:06 PM
Images in TURBO PASCAL S_A_L_M_A_N Other Programming Languages 4 Dec 20th, 2005 9:38 AM
Need help badly: Pascal conversion to C joan400 C 0 Apr 12th, 2005 9:48 PM
Delphi as opposed to Pascal? peace_of_mind Delphi 8 Apr 2nd, 2005 8:23 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:42 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC