VoyForums
[ Show ]
Support VoyForums
[ Shrink ]
VoyForums Announcement: Programming and providing support for this service has been a labor of love since 1997. We are one of the few services online who values our users' privacy, and have never sold your information. We have even fought hard to defend your privacy in legal cases; however, we've done it with almost no financial support -- paying out of pocket to continue providing the service. Due to the issues imposed on us by advertisers, we also stopped hosting most ads on the forums many years ago. We hope you appreciate our efforts.

Show your support by donating any amount. (Note: We are still technically a for-profit company, so your contribution is not tax-deductible.) PayPal Acct: Feedback:

Donate to VoyForums (PayPal):

Login ] [ Contact Forum Admin ] [ Main index ] [ Post a new message ] [ Search | Check update time | Archives: 1234[5]678910 ]


[ Next Thread | Previous Thread | Next Message | Previous Message ]

Date Posted: 09:45:34 08/20/02 Tue
Author: Poppe
Subject: Problem with a list in Pascal?

I would be very grateful if someone could help me out with this one.
I've a program were the user should put in data about dogs, and then be able to write them out on the screen.

PROGRAM inlu5(Input, Output);
TYPE String_15=packed ARRAY[1..15] of CHAR;

hundpekare =^hundtyp;

hundtyp=record
namn : String_15;
ras : String_15;
age : Integer;
vikt : Integer;
next : hundpekare;
END;


VAR first,ny,temp : hundpekare;
continue : Boolean;
kom : Char;
i,antal : Integer;

BEGIN
Writeln('Welcome to dogprogram!');

new(first);
first^.next:=NIL; {pekaren nollställs}
Write('Name of dog?'); Readln(first^.namn);
Write('Race of dog?'); Readln(first^.ras);
Write('Age of dog?');Readln(first^.age);
Write('Weight of dog?'); Readln(first^.vikt);

continue:=true;
Repeat
BEGIN
Write('Do you want to put in data about another dog?Y/N');
Readln(kom);
CASE kom OF
'Y','y': BEGIN

new(temp);
temp:=first;
Writeln(first^.namn:5,':',first^.ras:5,':',first^.age:2,' first^.'); Writeln(temp^.namn:5,':',temp^.ras:5,':',temp^.age:2,' temp^.');

repeat
BEGIN
Writeln('Loop!');
temp:=temp^.next;
END;
until (temp^.next=NIL);

Write('Name?'); Readln(temp^.next^.namn);
Write('Race?'); Readln(temp^.next^.ras);
Write('Age?');Readln(temp^.next^.age);
Write('Weight?'); Readln(temp^.next^.vikt);
temp:=NIL;
END;
'N','n': continue:=false;
Otherwise
BEGIN
Writeln('Wrong kommando, try again!');
continue:=true;
END;
END;
END;
Until NOT continue;

Writeln(antal);
Write('Do you want to write the register? Y/N:');
Readln(kom);
Case kom of
'Y','y': BEGIN
{ I dont know how to make this correct}
END;
'N','n': Writeln('Bye');
Otherwise Writeln('Wrong kommando. Bye!');
END;
END.

[ Next Thread | Previous Thread | Next Message | Previous Message ]

[ Contact Forum Admin ]


Forum timezone: GMT-5
VF Version: 3.00b, ConfDB:
Before posting please read our privacy policy.
VoyForums(tm) is a Free Service from Voyager Info-Systems.
Copyright © 1998-2019 Voyager Info-Systems. All Rights Reserved.