Archive for the ‘Pascal’ Category.

Klippa og klistra

The heading means cut and paste.  Here is another one from the old school days.  One of my best teachers Freyr Þórarinsson told us once that we should cut and paste as much as possible.  From all available sources.  We were just awestruck, we never heard anything like that.  Just cheat, that’s what he means cheating ?  He’s the teacher, how is that possible.  Of course he didn’t mean cheating, what he meant was to use all available sources.  Borrow code give code etc, it’s a common practice today but was less obvious to us then.  As it happened we had created a hang out group at school and needed a name.  Once we grasped the concept of course we ran with “Klippa og klistra”.

Today’s developer spends a lot of time online getting / giving code snippets that can be used to address the normal day to day problems.   Don’t believe me, try StackOverflow, look at how it constantly updates.  If you want to restrict developers productivity yank the internet wire from the devs computer.  Next take away the books on the bookshelf.

The same teacher allowed us to use everything we wanted for our Pascal exam.  It was simple, duplicate an application that he wrote, you had 4 hrs to do the job.  Use whatever resources available to you, can you say cut and paste ?   As it was Dos based Pascal program there was not much that the teacher could change from one program to the other.  We had access to former programs they were something along the lines of.  Create attendance program, needs to hold a list of people for the class, you have one screen to put in the students.  You have another to mark them present or absent another to graph the attendance etc.  The sub screens were always prompted for from the main menu / screen.

1. Create student.

2. Attendance

3. View attendance

4. Graph


8. Quit


F1 for help

Simple enough, so I wrote a program that would generate the code for the main menu and the stubs for the sub screens.  At the start of the exam I ran the generator, it would just ask for the headlines.  After that it would spit out the code for the main screen and the stubs for the sub screens with complete F1 help option.  Load into Pascal and compile.  In about 2-3 minutes I had the main screen working and was able to start filling in the stubs that represented each sub screen.  The generator code was available and in full view on my network drive.  I did not get any kind of warning or downgrade on my score as you could use whatever resources you wanted, the teacher was true to his words.

The said teacher would challenge us to think outside of the box.  On the memorable list recursive and The Towers of Hanoi, Quine ( self-reproducing program ) here in Pascal or just plain C.