Solved

Linking 2 variables

Posted on 2000-03-07
7
164 Views
Last Modified: 2010-04-16
Is it possible to enter a number(customer number)
which would then display the details attached to that number
(customer name)
(customer address)
I would be really greatful.
Thanks.
0
Comment
Question by:ScottyBhoy
7 Comments
 
LVL 12

Expert Comment

by:Hypo
ID: 2593001
You can combine a record and an array to do that. Do I need to explain how to use records and arrays for you?

Take a look at the example

Program Name;

uses crt;

type Customer = record
 Name : string;
 Adress : string;
end;

var Customers : array[1..3] of Customer;

procedure WriteCustomer(C : Customer);
begin
 Writeln('Name   : ', C.Name);
 Writeln('Adress : ', C.Adress);
 Writeln;
end;

begin
 Customers[1].Name := 'Heini';
 Customers[1].Adress := 'keen road 8';
 Customers[2].Name := 'Rolfs';
 Customers[2].Adress := 'torp road 1';
{etc. etc.}
 Writeln('First Customer')
 WriteCustomer(Customers[1]);
 Writeln('Second Customer')
 WriteCustomer(Customers[2]);
end.
0
 

Author Comment

by:ScottyBhoy
ID: 2595146
Adjusted points to 75
0
 
LVL 1

Expert Comment

by:bakry99
ID: 2595254
if Data is a Record then
you have to explain where is the data stored ( in a File or in tha Ram "array").
after that you have to search about
your record match with Customer Number
and then Display other Info(name,address,...).
  Bakry
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 48

Expert Comment

by:dbrunton
ID: 2595255
Why the rejection?  Please explain your question more clearly.  Do you understand records and arrays?
0
 
LVL 32

Accepted Solution

by:
Batalf earned 75 total points
ID: 2595590
It is possible:

You need an array of records.

Program Name;

uses crt;

type Customer = record
 custid : integer;
 Name : string;
 Adress : string;
end;

Const Maxcust=10;

var
Customers : array[1..maxcust] of Customer;
counter : integer;
custid : integer;

begin
  /* Procedure here for typing data
  into the array*/

  Repeat
  Write('Type in customerid ');
  Readln(custid);
  Until (Custid<MaxCust) and (Custid>0)
   
  For Counter:=1 to MaxCust do
  BEGIN
       if Customers[Counter].custid
       = custid
       begin
           writeln('Id : ',Customers[counter].custid;
           writeln('Name : ',Customers[counter].name;
           writeln('Adress : ',Customers[counter].adress;
       
  END;

END.


There could be some errors in my example but I hope you could se the point.

Regards Batalf
   

0
 
LVL 32

Expert Comment

by:Batalf
ID: 2595597
This Procedure :

  For Counter:=1 to MaxCust do
  BEGIN
       if Customers[Counter].custid
       = custid
       begin
           writeln('Id : ',Customers[counter].custid;
           writeln('Name : ',Customers[counter].name;
           writeln('Adress : ',Customers[counter].adress;
       

make a search through your array, and give you the result on the screen if it could find a match(custid in array = the custid you typed in).

0
 

Author Comment

by:ScottyBhoy
ID: 2600127
Cheers Mate!!!!!!!!!!!!!!!!!!!
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Data breaches are on the rise, and companies are preparing by boosting their cybersecurity budgets. According to the Cybersecurity Market Report (http://www.cybersecurityventures.com/cybersecurity-market-report), worldwide spending on cybersecurity …
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 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