Board index » delphi » Help with Array and INI file

Help with Array and INI file

Can anyone tell me how to fix a bug in my program?
My program has around 12 comboboxes with 99 items in each. I'm using a procedure to get the values
since the items for all combos are the same. I want to create an ini file to store the items selected so the user
doesn't have to reselect the items next time the program is run. Below is the code I am using (sorry about the
length of this post) When I run the program it shows the item that was saved but due to the procedure being
used it acts as if the combo hasnt got a value in it? Any ideas?  I removed some of the values in this post to
make it smaller.

procedure TForm1.AnyComboBoxChange(Sender: TObject);
const
  XPLevels: array [0..98] of Integer
          = (0, 83, 174, 276, 388, 512, 650, 801, 969, 1154, 1358, 1584,
          9684577, 10692629, 11805606, 13034431);
var
  Index: Integer;
begin
  LevelXP := 0;
  Index:=(Sender as TComboBox).ItemIndex;
  LevelXP:=XPLevels[Index];
end;

procedure TForm1.ComboBox11Change(Sender: TObject);
begin
  AnyComboBoxChange(Sender);
end;

procedure TForm1.FormCreate(Sender: TObject);
var
INI: TIniFile;
I, Item: Integer;

begin
ComboBox1.ItemIndex := 0;

  INI := TIniFile.Create('RCalc.dat');

ComboBox2.ItemIndex := INI.ReadInteger('ComboBox2','Item', 0);
ComboBox3.ItemIndex := INI.ReadInteger('ComboBox3','Item', 0);

  INI.Free;

end;

 

Re:Help with Array and INI file


Is this the source code for a RuneScape level calculator? :) (just
wondering)

Re:Help with Array and INI file


Yeah as a matter of fact it is..  :)

After I've fixed this bug you can download it from either my website or RS Help.
My Site
http://kickme.to/merlin73

RS Help
http://www.zybez.com

Quote
On Wed, 26 Jun 2002 07:50:14 +1200, "Nicholas Sherlock" <n_sherl...@hotmail.com> wrote:
>Is this the source code for a RuneScape level calculator? :) (just
>wondering)

Re:Help with Array and INI file


I've written one already, is there any part of it you need help with? I
wrote routines to turn a skill level (attack, mining etc) into EXP and turn
EXP back into a level if you're interested?

Cheers,
Nicholas Sherlock

Quote
"MerLiN" <merli...@ihug.com.au> wrote in message

news:e9jhhuci6b3d3edljg4h6d83r8ub4r19vt@4ax.com...
Quote
> Yeah as a matter of fact it is..  :)

> After I've fixed this bug you can download it from either my website or RS
Help.
> My Site
> http://kickme.to/merlin73

> RS Help
> http://www.zybez.com

> On Wed, 26 Jun 2002 07:50:14 +1200, "Nicholas Sherlock"
<n_sherl...@hotmail.com> wrote:

> >Is this the source code for a RuneScape level calculator? :) (just
> >wondering)

Re:Help with Array and INI file


Yeah that would be great. As I said b4 once I fix this current bug the program will be
finished except for enter missing information on levels.
Quote
On Wed, 26 Jun 2002 16:05:58 +1200, "Nicholas Sherlock" <n_sherl...@hotmail.com> wrote:
>I've written one already, is there any part of it you need help with? I
>wrote routines to turn a skill level (attack, mining etc) into EXP and turn
>EXP back into a level if you're interested?

>Cheers,
>Nicholas Sherlock

>"MerLiN" <merli...@ihug.com.au> wrote in message
>news:e9jhhuci6b3d3edljg4h6d83r8ub4r19vt@4ax.com...
>> Yeah as a matter of fact it is..  :)

>> After I've fixed this bug you can download it from either my website or RS
>Help.
>> My Site
>> http://kickme.to/merlin73

>> RS Help
>> http://www.zybez.com

>> On Wed, 26 Jun 2002 07:50:14 +1200, "Nicholas Sherlock"
><n_sherl...@hotmail.com> wrote:

>> >Is this the source code for a RuneScape level calculator? :) (just
>> >wondering)

Re:Help with Array and INI file


Ok, here's the exptolevel and leveltoexp functions from my AutoMiner Premium
Edition calculator add-on :) (from
http://nadventure2002.tripod.com/programming/autominer.html ):

function exp2lvl(exp: integer): integer; {changes an EXP value into a
runescape skill level}
var level, points: integer;
begin
   points := 0;
   for level := 0 to maxint - 1 do
   begin
      points := points + trunc(level + 300 * power(2, level / 7) );
      if points / 4>= exp {we have our level!} then
         break;
   end;
   result := level + 1;
end;

function lvl2exp(exp: integer): integer; {calculates the exp required to
reach a level}
var level, points: integer;
begin
   points := 0;
   for level := 1 to exp - 1 do
      points := points + trunc(level + 300 * power(2, level / 7) );
   result := points div 4;
end;

Cheers,
Nicholas Sherlock of NAdventure Productions fame

Quote
"MerLiN" <merli...@ihug.com.au> wrote in message

news:3iiihu40tr80hmqf8jpdh6rq3qfui5u5tk@4ax.com...
Quote
> Yeah that would be great. As I said b4 once I fix this current bug the
program will be
> finished except for enter missing information on levels.

> On Wed, 26 Jun 2002 16:05:58 +1200, "Nicholas Sherlock"
<n_sherl...@hotmail.com> wrote:

> >I've written one already, is there any part of it you need help with? I
> >wrote routines to turn a skill level (attack, mining etc) into EXP and
turn
> >EXP back into a level if you're interested?

> >Cheers,
> >Nicholas Sherlock

> >"MerLiN" <merli...@ihug.com.au> wrote in message
> >news:e9jhhuci6b3d3edljg4h6d83r8ub4r19vt@4ax.com...
> >> Yeah as a matter of fact it is..  :)

> >> After I've fixed this bug you can download it from either my website or
RS
> >Help.
> >> My Site
> >> http://kickme.to/merlin73

> >> RS Help
> >> http://www.zybez.com

> >> On Wed, 26 Jun 2002 07:50:14 +1200, "Nicholas Sherlock"
> ><n_sherl...@hotmail.com> wrote:

> >> >Is this the source code for a RuneScape level calculator? :) (just
> >> >wondering)

Other Threads