Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 17 total
Thread Why Am Not Able To Type Into The Edit Box?
Wed, Jul 5 2017 3:42 AMPermanent Link

Frederick Chin

I have isolated a form from my project that refuses to allow me to type in anything within the edit box. The project is attached.

If I remove the braces starting from the last procedure upwards and recompile, eventually, I will be able to type something into the edit box.

What is happening here?

--
Frederick



Attachments: testedit.zip
Wed, Jul 5 2017 3:54 AMPermanent Link

Uli Becker

> If I remove the braces starting from the last procedure upwards and recompile, eventually, I will be able to type something into the edit box.
>
> What is happening here?

Remove your empty KeyDown event handlers both of your edit control and
your form.

Uli
Wed, Jul 5 2017 4:08 AMPermanent Link

Frederick Chin

Uli,

/*
Remove your empty KeyDown event handlers both of your edit control and
your form.
*/

Interesting. Is it because the functions are expecting Boolean values but none were specified?

--
Frederick
Wed, Jul 5 2017 12:02 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Frederick,

<< Interesting. Is it because the functions are expecting Boolean values but none were specified? >>

Yes.  In fact, the compiler should have warned you about this.

Tim Young
Elevate Software
www.elevatesoft.com
Wed, Jul 5 2017 6:18 PMPermanent Link

Frederick Chin

Tim,

/*
Yes.  In fact, the compiler should have warned you about this.
*/

I am indeed surprised that the compiler did not do so because it could cause obscure errors, like the edit box thingy.

As a test, I created a function and procedure as follows:-

function TfrmMain.DoFunc : Integer;
begin
  if lNew then
     lNew:=False;
end;

procedure TfrmMain.frmLoginShow(Sender: TObject);
var
   nTest : Integer;
begin
     nTest:=dofunc;    // nTest is NaN
     nTest:=nTest+1;  
end;

The compiler happily ran the program without informing me that the function was not returning a value and the problem with nTest was not realised until runtime.

--
Frederick
Thu, Jul 6 2017 11:13 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Frederick,

<< The compiler happily ran the program without informing me that the function was not returning a value and the problem with nTest was not realised until runtime. >>

Are you sure about this ?  Which version/build are you using ?

When I do the same here:

function TForm1.DoFunc : Integer;
begin
 if lNew then
    lNew:=False;
end;

procedure TForm1.Button8Click(Sender: TObject);
var
  nTest : Integer;
begin
    nTest:=dofunc;    // nTest is NaN
    nTest:=nTest+1;  
end;

(I defined lNew as a global Boolean variable)

I get a compiler warning about the return value of DoFunc.

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Jul 6 2017 5:47 PMPermanent Link

Frederick Chin

Tim,

/*
Are you sure about this ?  Which version/build are you using ?
*/

I am using version 2.06b4 and my unit is as follows:-

unit main;

interface

uses WebCore, WebUI, WebForms, WebCtrls;

type

  TfrmMain = class(TForm)
     procedure frmMainShow(Sender: TObject);
  private
     { Private declarations }
     lNew : Boolean;
     function DoFunc : Integer;
  public
     { Public declarations }
  end;

var
  frmMain: TfrmMain;

implementation

procedure TfrmMain.frmMainShow(Sender: TObject);
var
  nTest : Integer;
begin
    nTest:=dofunc;    // nTest is NaN
    nTest:=nTest+1;  
end;

function TfrmMain.DoFunc : Integer;
begin
 if lNew then
    lNew:=False;
end;

end.

There are no complaints from the compiler.

--
Frederick
Thu, Jul 6 2017 11:04 PMPermanent Link

Raul

Team Elevate Team Elevate

On 7/6/2017 5:47 PM, Frederick Chin wrote:
> I am using version 2.06b4 and my unit is as follows:-
>
> There are no complaints from the compiler.

I just tried it here with your code and seeing this when compiling in
2.06 b4


[Warning] main.wbs (67,24): The result has not been assigned a value

This points to the "function TForm1.DoFunc : Integer;" line

Note that compiler only gives you a warning if it actually needs to
recompile the unit - so first compile after any change results in errors
but subsequent do not (assuming unit has not changed).

add a new empty line in  DoFunc for example, save and compile - does
anything show up in warnings ?

Raul
Fri, Jul 7 2017 12:04 AMPermanent Link

Frederick Chin

Raul,

/*
I just tried it here with your code and seeing this when compiling in
2.06 b4


[Warning] main.wbs (67,24): The result has not been assigned a value

This points to the "function TForm1.DoFunc : Integer;" line

Note that compiler only gives you a warning if it actually needs to
recompile the unit - so first compile after any change results in errors
but subsequent do not (assuming unit has not changed).

add a new empty line in  DoFunc for example, save and compile - does
anything show up in warnings ?
*/

Still no compiler warnings. I double checked the project options and the "Show Hints" and "Show Warnings" options under the Compilation tab are checked.

My unit is now as follows:-

unit main;

interface

uses WebCore, WebUI, WebForms, WebCtrls, WebBtns;

type

  TfrmMain = class(TForm)
     Button1: TButton;
     procedure frmMainShow(Sender: TObject);
     procedure Button1Click(Sender: TObject);
  private
     { Private declarations }
     lNew : Boolean;
     function DoFunc : Integer;
  public
     { Public declarations }
  end;

var
  frmMain: TfrmMain;

implementation

procedure TfrmMain.frmMainShow(Sender: TObject);
var
  nTest : Integer;
begin
    nTest:=dofunc;    // nTest is NaN
    nTest:=nTest+1;  
end;

function TfrmMain.DoFunc : Integer;
begin
 if lNew then begin
    lNew:=False;
 end;
end;

procedure TfrmMain.Button1Click(Sender: TObject);
begin
  close;
end;

end.

--
Frederick
Fri, Jul 7 2017 8:51 AMPermanent Link

Raul

Team Elevate Team Elevate

On 7/7/2017 12:04 AM, Frederick Chin wrote:
> Still no compiler warnings. I double checked the project options and the "Show Hints" and "Show Warnings" options under the Compilation tab are checked.

This is rather weird.

> My unit is now as follows:-

I added the unit exactly as you shown in a new project with all same
names etc and i do get a warning

[Warning] main.wbs (34,26): The result has not been assigned a value

which points to "function TfrmMain.DoFunc : Integer;"


Have you tried this code with a brand new project (that has just this
form and unit ) and see if you get a warning then (vs being part of a
bigger project).

Just for reference here's my unit (should be exactly like one you posted):


unit main;

interface

uses WebCore, WebUI, WebForms, WebCtrls, WebBtns;

type

   TfrmMain = class(TForm)
      Button1: TButton;
      procedure frmMainShow(Sender: TObject);
      procedure Button1Click(Sender: TObject);
   private
      { Private declarations }
      lNew : Boolean;
      function DoFunc : Integer;
   public
      { Public declarations }
   end;

var
   frmMain: TfrmMain;

implementation

procedure TfrmMain.frmMainShow(Sender: TObject);
var
   nTest : Integer;
begin
     nTest:=dofunc;    // nTest is NaN
     nTest:=nTest+1;
end;

function TfrmMain.DoFunc : Integer;
begin
  if lNew then
   begin
     lNew:=False;
  end;
end;

procedure TfrmMain.Button1Click(Sender: TObject);
begin
   close;
end;

end.


Raul
Page 1 of 2Next Page »
Jump to Page:  1 2
Image