Solved

procedure print

Posted on 1998-11-17
10
175 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
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
 
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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 50 total points
ID: 1216070
???
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
In this article, I show you step by step with screenshots to assist you - HOW TO: Deploy and Install the VMware vCenter Server Appliance 6.5 (VCSA 6.5), with some helpful tips along the way.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now