Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

procedure print

Posted on 1998-11-17
10
Medium Priority
?
187 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
Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

WooCommerce is becoming the most powerful e-commerce plugin for Wordpress. And why not. The platform comprises of numerous core plugins that may come in handy, powerful options to make your website development task much easier.
Tech spooks aren't just for those who are tech savvy, it also happens to those of us running a business. Check out the top tech spooks for business owners.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

598 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