Recent

Author Topic: Array Operators?  (Read 3320 times)

greertr

  • Full Member
  • ***
  • Posts: 113
    • Virtual Pilot Dashboard
Array Operators?
« on: December 09, 2016, 04:22:50 pm »
Where can I find a list of array operators.

Example of array simcounts: 
Code: Pascal  [Select][+][-]
  1.    For i := 0 to stringgrid1.rowcount-1 do
  2.   // flight sim string designators in stringgrid1 cell 9:  FS9 FSX XP9 XP10 XP11 FG AFS2
  3.      begin //count how many times each sim is used using int vars
  4.        if (stringgrid1.cells[9,i] = 'FS9') then fs9 := fs9 + 1;
  5.        if (stringgrid1.cells[9,i] = 'FSX') then fsx := fsx + 1;
  6.        if (stringgrid1.cells[9,i] = 'XP9') then xp9 := xp9 + 1;
  7.        if (stringgrid1.cells[9,i] = 'XP10') then xp10 := xp10 + 1;
  8.        if (stringgrid1.cells[9,i] = 'XP11') then xp11 := xp11 + 1;
  9.        if (stringgrid1.cells[9,i] = 'FG') then fg := fg + 1;
  10.        if (stringgrid1.cells[9,i] = 'AFS2') then afs2 := afs2 + 1;
  11.        //determine which flight sim was used the most times
  12.        {type
  13.           simcount_array = array [0..6] of integer;
  14.         var
  15.           Numbers: simcount_array;}
  16.        simcounts[0] := fs9;
  17.        simcounts[1] := fsx;
  18.        simcounts[2] := xp9;
  19.        simcounts[3] := xp10;
  20.        simcounts[4] := xp11;
  21.        simcounts[5] := fg;
  22.        simcounts[6] := afs2;
  23.        //High(simcounts);
  24.        //showmessage(inttostr(High(simcounts)));
  25.  
  26.      end;  

I need to be able to identify not only the highest integer value of the array, but the variable name for the cell with the highest number.

thx in adv

Thaddy

  • Hero Member
  • *****
  • Posts: 18729
  • To Europe: simply sell USA bonds: dollar collapses
Re: Array Operators?
« Reply #1 on: December 09, 2016, 04:47:16 pm »
Example:
Code: Pascal  [Select][+][-]
  1. var
  2.  a:array[0..10,0..3] of integer;
  3. begin
  4.   writeln(High(a):5,High (a[0]):5);
  5. end.
  6.  

prints 10 3

High(a) gives first dimension
High(a[0]) gives second dimension
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Array Operators?
« Reply #2 on: December 09, 2016, 04:59:24 pm »
Are you looking for the highest index of an integer array, or the highest integer value stored in an array of integers?

greertr

  • Full Member
  • ***
  • Posts: 113
    • Virtual Pilot Dashboard
Re: Array Operators?
« Reply #3 on: December 09, 2016, 05:00:43 pm »
highest value and name of the associated variable...

and i just noticed the high operator is giving me the index not the value

thx

Thaddy

  • Hero Member
  • *****
  • Posts: 18729
  • To Europe: simply sell USA bonds: dollar collapses
Re: Array Operators?
« Reply #4 on: December 09, 2016, 05:20:04 pm »
highest value and name of the associated variable...

and i just noticed the high operator is giving me the index not the value

thx

Yes, but if you have the index you can read the value, maybe??? >:D
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Array Operators?
« Reply #5 on: December 09, 2016, 05:57:34 pm »
If your array is sorted, then intArray[High(intArray)] contains the highest value.
If the array is not sorted, then you'll have to search for the highest value (or sort the array).

 

TinyPortal © 2005-2018