Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Linking 2 variables

Posted on 2000-03-07
7
Medium Priority
?
175 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
[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
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
[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

 
LVL 49

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 300 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

While opting for any web-to-print solution, you need to discuss with your team and some of your end users and know their opinions about your decisions. In this article we list down some questions you need to ask yourself.
What we learned in Webroot's webinar on multi-vector protection.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

715 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