Recent

Author Topic: Action on button click only works after the second click [SOLVED]  (Read 3705 times)

AlphaInc.

  • Jr. Member
  • **
  • Posts: 93
Re: Action on button click only works after the second click.
« Reply #15 on: April 03, 2021, 05:20:19 pm »
I'd normally suspect a dangling else as the cause of this, but #8 (the only place the entire code has been posted) doesn't show anything obvious.
The reason is that variable sLanguageLine isn't initialized at the beginning.

I will try this code later, but thank you in advance.
I will post again whether I had success or not.

AlphaInc.

  • Jr. Member
  • **
  • Posts: 93
Re: Action on button click only works after the second click.
« Reply #16 on: April 03, 2021, 05:24:20 pm »
That didn't fix the problem. Still get an empty message-box when language is set to english in the ini at starup.
Did you double click on empty space of your form to create OnClick event (or assigned it manually in Object inspector)?

Oh, and change the start of confCheck(), I just see you still read it in Line2 instead of sLanguageLine:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.confCheck();
  2. var
  3.    MyFile:Text;
  4.    Line1,Line2,Line3,Line4,Line5:String;
  5. begin
  6.    AssignFile(MyFile,cMyFileName);
  7.    Reset(MyFile);
  8.    ReadLn(MyFile,Line1);
  9.    ReadLn(MyFile,Line2);
  10.   If (Line2<>'lang=deu') and (Line2<>'lang=eng') then Line2:='lang=eng'; // new line
  11.   sLanguageLine:=Line2; // new line
  12.    ReadLn(MyFile,Line3);
  13.    ReadLn(MyFile,Line4);
  14.    ReadLn(MyFile,Line5);
  15.    CloseFile(MyFile);

Just saw this, do you mean the Button or the createForm procedure ?

dseligo

  • Hero Member
  • *****
  • Posts: 1674
Re: Action on button click only works after the second click.
« Reply #17 on: April 03, 2021, 06:14:03 pm »
That didn't fix the problem. Still get an empty message-box when language is set to english in the ini at starup.
Did you double click on empty space of your form to create OnClick event (or assigned it manually in Object inspector)?

Oh, and change the start of confCheck(), I just see you still read it in Line2 instead of sLanguageLine:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.confCheck();
  2. var
  3.    MyFile:Text;
  4.    Line1,Line2,Line3,Line4,Line5:String;
  5. begin
  6.    AssignFile(MyFile,cMyFileName);
  7.    Reset(MyFile);
  8.    ReadLn(MyFile,Line1);
  9.    ReadLn(MyFile,Line2);
  10.   If (Line2<>'lang=deu') and (Line2<>'lang=eng') then Line2:='lang=eng'; // new line
  11.   sLanguageLine:=Line2; // new line
  12.    ReadLn(MyFile,Line3);
  13.    ReadLn(MyFile,Line4);
  14.    ReadLn(MyFile,Line5);
  15.    CloseFile(MyFile);

Just saw this, do you mean the Button or the createForm procedure ?
I mean CreateForm event, my mistake.
And put those two lines in confCheck procedure.

AlphaInc.

  • Jr. Member
  • **
  • Posts: 93
Re: Action on button click only works after the second click.
« Reply #18 on: April 03, 2021, 11:16:00 pm »
That didn't fix the problem. Still get an empty message-box when language is set to english in the ini at starup.
Did you double click on empty space of your form to create OnClick event (or assigned it manually in Object inspector)?

Oh, and change the start of confCheck(), I just see you still read it in Line2 instead of sLanguageLine:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.confCheck();
  2. var
  3.    MyFile:Text;
  4.    Line1,Line2,Line3,Line4,Line5:String;
  5. begin
  6.    AssignFile(MyFile,cMyFileName);
  7.    Reset(MyFile);
  8.    ReadLn(MyFile,Line1);
  9.    ReadLn(MyFile,Line2);
  10.   If (Line2<>'lang=deu') and (Line2<>'lang=eng') then Line2:='lang=eng'; // new line
  11.   sLanguageLine:=Line2; // new line
  12.    ReadLn(MyFile,Line3);
  13.    ReadLn(MyFile,Line4);
  14.    ReadLn(MyFile,Line5);
  15.    CloseFile(MyFile);

Just saw this, do you mean the Button or the createForm procedure ?
I mean CreateForm event, my mistake.
And put those two lines in confCheck procedure.

After changing the confCheck it works perfectly. I can't thank you enough!

dseligo

  • Hero Member
  • *****
  • Posts: 1674
Re: Action on button click only works after the second click.
« Reply #19 on: April 04, 2021, 03:19:44 am »
After changing the confCheck it works perfectly. I can't thank you enough!
I'm glad to help, no problem

 

TinyPortal © 2005-2018