Solved

procedure print

Posted on 1998-11-17
10
178 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

With more and more people tethered to the internet, advertisers can reach you in new and creative ways. Push notifications on your smartphone, customized advertisements based on your previous searches, and email inboxes filled with promotional pitch…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

932 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

9 Experts available now in Live!

Get 1:1 Help Now