?
Solved

procedure print

Posted on 1998-11-17
10
Medium Priority
?
185 Views
Last Modified: 2010-04-16
Q1  :  how do i save data entered by user when prompted by a program?
Q2  : how do i do a procedure print that printed out a list of all records when this selection is selected?
hotel record = serial no,guestname,tel no ,checkin date, checkout date, and paymode.
0
Comment
Question by:HoLi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 

Author Comment

by:HoLi
ID: 1216061
i need this in 1 day's time, please help me,plzzzz?thx
0
 
LVL 3

Expert Comment

by:vikiing
ID: 1216062
¿Are you Nad22's schoolmate ?, give a look at question 10099196.

0
 
LVL 2

Expert Comment

by:omsec
ID: 1216063
thats quite much to program :P
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 6

Expert Comment

by:My name is Mud
ID: 1216064
in Q1 is as easy as a READLN(DATA), where DATA is the VAR of a TYPE where you put what ever the user inputs and it has to be the same as the TYPE of the VAR, for ex., if you want the user to respon with a number (0..9) you declare de VAR like so:

VAR
    DATA: BYTE; {is byte and not integer cos you don't need to spend a lot of memory                          1byte is a lot of mem, in a data base with a million records that is}

BEGIN
  WRITE('Please enter a number from 0 trugh 9: '); {You always tell the user what to do}
  READLN(DATA);  {You place the number in the VAR DATA}
  WRITELN('The number you entered has... ',DATA); {and thats it}
END.

but if you want to save it to a disk, that depends on wether you want to keep the DATA the user inputs every time you run the program or to erase it and saves a new DATA, ok.

Using RESET to append to a FILE:

VAR
  DATA: INTEGER;
  FF: FILE OF INTEGER;

BEGIN
  ASSIGN(FF,'DATAFILE.DAT');
  RESET(FF);
  SEEK(FF,EOF(FF));
  REPEAT
    WRITE('Please enter a number from 0 thru 9: '); {You always tell the user what to do}
    READLN(DATA);  {You place the number in the VAR DATA}
    WRITELN('The number you entered has... ',DATA); {and thats it}
    WRITE(FF,DATA); {You write the data to the file}
  UNTIL DATA=0;  {until the user press 0}
  CLOSE(FF);
END.

Using REWRITE to create a FILE:

VAR
  DATA: INTEGER;
  FF: FILE OF INTEGER;

BEGIN
  ASSIGN(FF,'DATAFILE.DAT');
  REWRITE(FF);
  REPEAT
    WRITE('Please enter a number from 0 thru 9: '); {You always tell the user what to do}
    READLN(DATA);  {You place the number in the VAR DATA}
    WRITELN('The number you entered has... ',DATA); {and thats it}
    WRITE(FF,DATA); {You write the data to the file}
  UNTIL DATA=0;  {until the user press 0}
  CLOSE(FF);
END.


In Q2 you want to print this record

USES
  PRINTER;
TYPE
  HOTELTYPE = RECORD OF
     SERNO: INTEGER;
     GUESTNAME: STRING[30];
     TELNO: STRING[8];
     CHECKI: STRING[8];
     CHECKO: STRING[8];
     PAYMODE: BYTE;
  END;
VAR
  HOTEL: ^HOTELTYPE;

PROCEDURE GETDATA(DATA: HOTELTYPE);
BEGIN
  WRITE('Input the Serial No..' );
  READLN(DATA.SERNO);
  .
  .
  .
  WRITE('Input the Pay Mode..' );
  READLN(DATA.PAYMODE);
END;

PROCEDURE PRINTDATA(DATA: HOTELTYPE);
BEGIN
  WRITELN(PRN,'Serial No..',DATA.SERNO );
  .
  .
  .
  WRITELN(PRN,'Input the Pay Mode..',DATA.PAYMODE);
END;

BEGIN
  NEW(HOTEL,SIZEOF(HOTELTYPE));
  GETDATA(HOTEL);
  PRINTDATA(HOTEL);
END.

Please notify me if this wasn't your Q1 or if the proggys did not work

{WHEN I WROTE THIS I WAS AT WORK AND HERE I DON'T HAVE PASCAL}
0
 
LVL 1

Expert Comment

by:The_Brain
ID: 1216065
yuk, UPPERCASE, looks like COBOL. ;)  use lower case when programming it makes it tonnes easier to read.  C++ is case-sensitive, you have no choice.  :)
0
 
LVL 6

Expert Comment

by:My name is Mud
ID: 1216066
Sorry Man!!. I will do lowercase, :)
0
 

Expert Comment

by:misguided
ID: 1216067
not again!!!!...we don't program for free!! again..go get a book about basic pascal...and read..
0
 
LVL 1

Expert Comment

by:nabilaal
ID: 1216068
Hi,

I revised the answer of (whatboy) and he is really an expert, and he gain the points, trust me, it will work. Thnx.
0
 
LVL 6

Expert Comment

by:My name is Mud
ID: 1216069
Nabilaal i'm not an expert, but what about my points 'cos you are not HoLi
0
 
LVL 6

Accepted Solution

by:
My name is Mud earned 100 total points
ID: 1216070
???
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this modest contribution, I want to share with the IT community (especially system administrators, IT Support Engineers and IT Help Desks) about Windows crashes/hangs and how to deal with these particular problems.
The top devops trends for 2017 are focused on improved deployment frequency, decreased lead time for change and decreased MTTR.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question