Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 8 of 8 total
Thread Why Does TDataset Insert Fail?
Tue, Aug 28 2012 1:45 AMPermanent Link

Frederick Chin

In the code below, the compilation fails at the "insert;" line with an error, among others, of:-

[Error] main.wbs (76,15): Expected ( but instead found ;

  with dsLoanAmounts do begin
       insert;  // Compilation stops here
       columns['loanamt'].asFloat:=1.00;
       save;
  end;

If I prefix all three lines within the "with" block with the dataset's name plus a dot, the compilation proceeds.

It looks OK to me.

Frederick
Tue, Aug 28 2012 10:14 AMPermanent Link

Raul

Team Elevate Team Elevate

This looks to be a bug - that Insert is not accepted inside with block.


with dsLoanAmounts do
begin
  dsLoanAmounts.insert;
  columns['loanamt'].asFloat:=1.00;
  save;
end;

Tim needs to fix this.

Raul


On 8/28/2012 1:45 AM, Frederick Chin wrote:
> In the code below, the compilation fails at the "insert;" line with an error, among others, of:-
>
> [Error] main.wbs (76,15): Expected ( but instead found ;
>
>     with dsLoanAmounts do begin
>          insert;  // Compilation stops here
>          columns['loanamt'].asFloat:=1.00;
>          save;
>     end;
>
> If I prefix all three lines within the "with" block with the dataset's name plus a dot, the compilation proceeds.
>
> It looks OK to me.
>
> Frederick
>
Tue, Aug 28 2012 11:23 AMPermanent Link

Friedrich Westermann

Thats really easy:, never use with......
it looks nice at the first point but after...
you remember the problems with the latest changes in Delphi?

Trect becames width, height etc. propertys


so: NEVER USE WITH!!!!!!!!!!!

Greeting Fritz


Frederick Chin wrote:

>
> [Error] main.wbs (76,15): Expected ( but instead found ;
>
>    with dsLoanAmounts do begin
>         insert;  // Compilation stops here
>         columns['loanamt'].asFloat:=1.00;
>         save;
>    end;
>
Tue, Aug 28 2012 11:51 AMPermanent Link

Frederick Chin

/*
"Friedrich Westermann" wrote:

Thats really easy:, never use with......
*/

I don't think using WITH is a bad thing since it makes code easier to read but can make debugging difficult. If a programmer is fine with it and knows what they are doing, why not?

Besides, Tim knows that it is not bad thing since the online manual for EWB is full of WITH syntax. My code is practically lifted from his online manual.

Frederick
Wed, Sep 5 2012 10:08 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Frederick,

<< In the code below, the compilation fails at the "insert;" line with an
error, among others, of:- >>

Insert() is an internal system function:

http://www.elevatesoft.com/manual?action=viewtopic&id=ewb1&topic=Insert

and the compiler always gives scope preference to internal system functions
*first* before any internal method names.

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Sep 6 2012 12:11 PMPermanent Link

Frederick Chin

Tim,

/*
Insert() is an internal system function:

http://www.elevatesoft.com/manual?action=viewtopic&id=ewb1&topic=Insert

and the compiler always gives scope preference to internal system functions
*first* before any internal method names.
*/

Understood, but the following block:-

with dtaSet do begin
      insert;
end;

is the same as :-

dtaSet.Insert;

Why should the compiler choke when the insert() in the block is dot suffixed to dtaSet.

In fact, in your online manual for "Updating Datasets", you have the very same example of the insert command within the With statement. Would that compile?

Frederick
Thu, Sep 6 2012 3:06 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Frederick,

<< is the same as :-

dtaSet.Insert; >>

No, it's not, as far as the compiler is concerned.  It's a little hard to
explain, but it has to do with the fact that these internal system functions
don't actually exist in Object Pascal code anywhere, only in JavaScript.
Therefore, the compiler can't "select" them properly by declaration, only by
name.  It's something that will be addressed, but requires some fundamental
changes in how such internal system functions are dealt with by the
compiler.

<< In fact, in your online manual for "Updating Datasets", you have the very
same example of the insert command within the With statement. Would that
compile? >>

This as an error in the manual, and has been correct along with an inline
comment about why the Insert method needs to be prefaced with the dataset
name.

BTW, I was able to break out the ShowMessage/MessageDlg calls as separate
procedures for EWB 1.01.  The protected method reference requirement was
actually a remnant of an earlier version of the compiler.  It makes
referencing this procedures more akin to Delphi.

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Sep 6 2012 10:30 PMPermanent Link

Frederick Chin

Tim,

/*
This as an error in the manual, and has been correct along with an inline
comment about why the Insert method needs to be prefaced with the dataset
name.
*/

OK, I guess there is no choice but to type more.

/*
BTW, I was able to break out the ShowMessage/MessageDlg calls as separate
procedures for EWB 1.01.  The protected method reference requirement was
actually a remnant of an earlier version of the compiler.  It makes
referencing this procedures more akin to Delphi.
*/

Great! Thanks.

Frederick
Image