Solved

procedure print

Posted on 1998-11-17
10
180 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
TClientSocket.SendStream is slow... 2 970
Delphi - What Does "F" Symbolize? 2 478
Capture cookies with delphi 5 1,026
Delphi 2010 auto upgrade has "lost" a file 7 1,080
This article describes my battle tested process for setting up delegation. I use this process anywhere that I need to setup delegation. In the article I will show how it applies to Active Directory
There's a lot of hype surrounding blockchain technology. Here's how it works and some of the novel ways it' s now being used - including for data protection.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

860 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