Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

integer = two separate numbers? 1

Status
Not open for further replies.

Bamben

Programmer
Jul 22, 2009
70
IT
Is there any way to make an integer two or more separate numbers at the same time?

mydogs:array[0..9] of dogs;

i:=1,2,3;
myvoice.sit(mydogs);


..............................................................

procedure TMainForm.xHold;
begin
if N = 1 then begin T := 0; SimpleSIP1.HoldCall(CallPack[T]);end;
if N = 2 then begin T := 0, 1; SimpleSIP1.HoldCall(CallPack[T]);end;
if N = 3 then begin T := 0, 1, 2; SimpleSIP1.HoldCall(CallPack[T]);end;
if N = 4 then begin T := 0, 1, 2, 3; SimpleSIP1.HoldCall(CallPack[T]);end;
if N = 5 then begin T := 0, 1, 2, 3, 4; SimpleSIP1.HoldCall(CallPack[T]);end;
if N = 6 then begin T := 0, 1, 2, 3, 4, 5; SimpleSIP1.HoldCall(CallPack[T]);end;
if N = 7 then begin T := 0, 1, 2, 3, 4, 5, 6; SimpleSIP1.HoldCall(CallPack[T]);end;
if N = 8 then begin T := 0, 1, 2, 3, 4, 5, 6, 7; SimpleSIP1.HoldCall(CallPack[T]);end;
if N = 9 then begin T := 0, 1, 2, 3, 4, 5, 6, 7, 8; SimpleSIP1.HoldCall(CallPack[T]);end;
if N = 10 then begin T := 0, 1, 2, 3, 4, 5, 6, 7, 8, 9; SimpleSIP1.HoldCall(CallPack[T]);end;
end;

I am reading on the net but I am just getting more and more confused as everything I try to copy goes wrong with this array.
 
The only way to have multiple numbers, or elements, set to a single variable is to use an array, or a set.

Your code above should be rewritten as

Code:
var
  mydogs : array[0..9] of dogs;
  i : Integer
begin
  for i := 1 to 3 do
    myvoice.sit(mydogs[i]);

Code:
procedure TMainForm.xHold;
var
  c, N : Integer;
begin
  for c := 0 to N - 1 do
    SimpleSIP1.HoldCall(CallPack[c]);

Loops are your friend.
 
also dont repeat code if you can avoid it, the above can be written like so
Code:
procedure TMainForm.xHold;
begin
  if N = 1 then T := 0;
  if N = 2 then T := 0, 1;
  if N = 3 then T := 0, 1, 2;
  if N = 4 then T := 0, 1, 2, 3;
  if N = 5 then T := 0, 1, 2, 3, 4;
  If N = 6 then T := 0, 1, 2, 3, 4, 5;
  if N = 7 then T := 0, 1, 2, 3, 4, 5, 6;
  if N = 8 then T := 0, 1, 2, 3, 4, 5, 6, 7;
  if N = 9 then T := 0, 1, 2, 3, 4, 5, 6, 7, 8;
  if N = 10 then T := 0, 1, 2, 3, 4, 5, 6, 7, 8, 9;

  SimpleSIP1.HoldCall(CallPack[T])
end;
[\code]

Aaron
 
I want to give a star to everything you just said (I wont use any of it though).

I have given up with this array of ISipCall.

I think I have made a bad Impression with people here, I have been wasting my time trying to make this array work when It will NEVER work! I have probably done about 50 versions of accessing the whole array and about 20 versions of accessing parts of it. I believe that when ever I do it the correct way I get only ONE error 'Incompatible types blaa blaa'. I seriously am not stupid though I may seem so.

I have made a real baaaad impression :(
 
The only bad impression you made is not listening...

When I was introduced to pascal programming (Delphi didn't exist, BTW) an associate handed me 3 books on pascal. The 2nd time I asked him for help, he promised to help me with anything, provided I could prove I'd read at least half of one of them.

From then on, I'd walk into his office with my finger on the page that I needed his help to understand.

It didn't take long to realize that pascal is a self-teaching language. IOW, if you start with the basics, it will teach itself. Pascal was actually written as a teaching tool to promote programming skills that apply to any programming language.

Many pascal programmers eventually move on to other programming languages out of necessity. You will find that the very best C++, Java, or SAP coders learned pascal first.

Do you recall your reply to the 1st link (Chapter 1) I sent you? Then I sent you a link from chapter 8. You'd never seen it. I'm guessing that applies to chapters 2..7 as well and I'll bet there's one that covers arrays!

There are several other on-line tutorials. I own at least a dozen books on pascal programming and Delphi.

We've all proven that we'll help you.

Now it's your turn...


Roo
Delphi Rules!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top