Wait… WHAT!?

Wait… WHAT!?

Exercise for the reader – how much faster would this be with a hash table or binary search?

unit Data.Db;

function TFields.FindField(const FieldName: string): TField;

var

  I: Integer;

  HashValue: Cardinal;

begin

  if FList.Count > 0 then

  begin

    HashValue := TNamedItem.HashName(FieldName);

    for I := 0 to FList.Count – 1 do

    begin

      Result := FList.Items[I];

      if (Result.FFieldNameHashValue = HashValue) and

         (AnsiCompareText(Result.FFieldName, FieldName) = 0) then

        Exit;

    end;

  end;

  Result := nil;

end;

FireDAC and bi-directional stored procedure parameters in SQL Server.

FireDAC and bi-directional stored procedure parameters in SQL Server.  I am diving into FireDAC, from a ADO starting point, and there are differences.

The SQL Server stored procedure below has two bidirectional parameters Error and Id. Description is input only, and the the procedure returns an int (0 = success, non-0 = check Error)

Error may be set, and Id is either a value > 0 which will be used as key, or if it is 0 or NULL, an auto-incremented value is returned through Id.

My ADO code which so far has translated easily for queries, etc – is barfing on invalid parameters for the stored proc.

How do you properly set up the bidirectional parameters?

How do you retrieve the output parameter values?

How do you retrieve the result value?

A simple code example would be appreciated, as the docs for TFDParams and Stored Procedures are Carefully Refined Awesome Prose.

{code}

CREATE PROCEDURE [dbo].[p_upsert_Description]

   @ErrorMsg varchar(1000) output,

   @Id int output,

   @Description varchar(100)

AS

BEGIN

    DECLARE @aId int;

    SET @ErrorMsg= ”;

    SET @aId= 0;

    BEGIN TRY

        SELECT @aId= Id FROM t_descriptions WHERE Id=@Id;

        IF @aId> 0

        BEGIN

            UPDATE t_descriptions

            SET Description=@Description

            WHERE Id =@aId;

            SELECT @Id=@aId;

        END

        ELSE

        BEGIN

            DECLARE @TmpIdTable table(ID int)

            INSERT INTO t_descriptions (

                CreatedTime,

                Description

            )  OUTPUT inserted.ID into @TmpIdTable

            VALUES (

                SYSDATETIME(),

               @Description

            );

            SELECT TOP 1 @Id= ID  FROM @TmpIdTable

        END

    END TRY

    BEGIN CATCH

        SELECT @ErrorMsg= ERROR_MESSAGE();

        RETURN SELECT ERROR_NUMBER();

    END CATCH

    RETURN 0;

END

{code}

Generics and constructors

Generics and constructors

Fair enough, if you qualify the type to require a constructor

TMyClass = class

private

  property Inner: T;

public;

  procedure InnerCreate;

end;

you must have a parameterless constructor to instantiate T.

TMyClass.InnerCreate;

begin

   Inner := T.Create;

end;

but – If you qualify the type of T with an actual class such as TControl that have a public virtual constructor that takes an argument.

constructor TControl.Create(AOwner: TComponent); override;

You still cannot specify that constructor for T.

TMyClass = class

private

  property Inner: T;

public;

  procedure InnerCreate;

end;

TMyClass.InnerCreate;

begin

   Inner := T.Create(nil); //<– [dcc32 Error] : E2029 ')' expected but 'NIL' found

end;

Why is this not valid?  The method is public, and the actual type of T has been specified.

Hi Friends

Originally shared by Hafiza Lim

Hi Friends, 

We are urgently looking for IOS Development Lead for client. Can you please share your updated profile ASAP with the subject line as “IOS Development Lead” on jobs@intellect-minds.com. 

Thanks  Regards

Hafiza

IOS Development Lead

JOB REQUIREMENTS

Knowledge and skills

• Strong experience in Android & iOS Development platform is essential. 

• Knowledge in Java/MySQL/Oracle is desirable.

• Strong communication and leadership quality

• Strong Experience in mobile solution design and analysis

• Good knowledge of mobile User Experience (UX) is highly desirable

• Experience in mobile framework/SDK APIs and their implementation 

• Experience in designing (Solution + UX) , profiling and tuning it for high-performance

• Good knowledge of security standards (encryption, authentication)

• Good knowledge on UML for design and analysis is desirable

• Domain knowledge of banking/payment systems is desirable

• Knowledge of basic MacOS/Unix/Linux environment is required

Super Simple Documentation in Delphi

Super Simple Documentation in Delphi

Save the pastebin document as xmld_XMLDoc_Summary.xml in 

XE..XE5 – RAD Studiocode_templatesDelphi

XE6… – EmbarcaderoStudiocode_templatesDelphi

… or wherever your standard Delphi directory is.

Create a blank line above a class method or property in the interface declaration, then type xmld and fill in the blanks. If you need more than one line, add a line break and /// at the beginning of next line.

  protected

    ///

Current log line number being

    /// processed

    property LogLineNo: Integer read FLogLineNo write FLogLineNo;

Now, hover your cursor over the method or property anywhere in your code and read what you just filled in 😉

Yes – you can add a lot more XML doc attributes – but for the bare minimum – this is pretty quick and easy.  You can of course change the magic xmld keyword to anything you prefer as well.

A big thanks to Nick Hodges for including this community as “a good place for Delphi folks to be”.

Originally shared by Lars Fosdal

A big thanks to Nick Hodges for including this community as “a good place for Delphi folks to be”.

We could also consider reviving the trusty old Google Groups

groups.google.com/forum/#!forumsearch/borland.public.delphi.*

Has a WebUI, supports NNTP and email digests – allows embedding in web sites.

Best of all – zero maintenance