Jump to content

John Kouraklis

Members
  • Content Count

    328
  • Joined

  • Last visited

  • Days Won

    5

Posts posted by John Kouraklis


  1. I use TWebBrowser and trying to login to an email account. After the initial page, I get an error saying that "The browser or app may be insecure. Try using different browser".

     

    Does anyone know how to fix it? I read on the net that I can change the User Agent header to reflect a newer browser but couldn't find how to change the header in the component.

     

    Thanks

     


  2. Hi, 

     

    I want to implement push notifications in a desktop app for GMail. I have read the dev guides and looked it up on the web and I all tutorials talk about how to do it in web apps.

     

    My email client on Android uses push notifications. Can anyone guide me on this? Or, any demo apps, perhaps?

     

    Thanks


  3. 2 hours ago, Anders Melander said:

    On Windows: Yes. Everywhere else: No.

    On Windows it works the exact same way as with VCL; Forms are stored in the EXE resources in DFM format and resourcestrings are stored as string resources.

    Yes, I was sure that other platforms wouldn't be easy to work with. 

     

    Thanks for the tips.


  4. 4 hours ago, dummzeuch said:

    Does it also cover when (which Delphi version) a particular syntax extension was introduced?

    Apart from the additions in 10.3 and 10.4 I found very difficult to track down and verify this information and then to present everything in a concise way. And I am not sure a newcomer would really find this useful.

     

    Perhaps if you write components and need to cover old versions this would be useful but I feel this is a bit out of the scope of the book.


  5. Hi all,

     

    I'd like to share that my new book is almost out. Apress is working hard to put it in the market.

     

    We always discuss how we can bring new people to Delphi so I thought it would be a good idea to ease their way in by providing a quick up-to-date guide on the basics of the language. The book covers new features introduced in 10.4

     

    Of course, a reference book is always useful to experienced coders as well; we all need a refresher every now and then 🙂

     

    I would like to cordially thank Dr. Holger Flick for reviewing the chapters; his experienced view guided me during the writing of the book.

     

     

    Regards,

     

    John

     

     

     

    9781484261118.tif

    • Like 4

  6. Hi @Dan Moore,

     

    I ended up writing my own. It does not provide full cover of the API; I only added the calls I needed.

     

    I can share it with the community but need to clear it up a bit as at the moment it uses some proprietary code. I only used it for simplicity but it can be replaces with open source.

     

    Thanks 

     

    John

     

     

    • Thanks 2

  7. LSP form works...when it works :classic_blush:

     

    What annoys me is that you first need to save a file before LSP is able to locate the changes--and this may not be what you always want. In all the videos EMBA presented and demonstrated LSP, they used units from the libraries. They never played live in the sense to add variables or procedures and then fire up LSP. 

     

    In other versions I had CodeInsightPlus by DevJet which is an amazing product. Maybe they should have considered to buy it.

    • Like 1

  8. I also use for..in all the time.

     

    Don't forget though that in for loops you can not modify the iteration variable. So, if you have a TStringList, this code does not compile:

     

    for item in list do
      item:=item + '123';

    In such cases, iterating through the items via index is the only option

     

        for num := 0 to list.Count - 1 do
          list[num]:=list[num] + '123';

     


  9. Check this code:

     

    var
      forControl: Integer;
      forArrayDyn: array of Integer;
    
    begin
      SetLength(forArrayDyn, 10);
      for forControl := 1 to 10 do
        forArrayDyn[forControl - 1]:=forControl;
    
      for forControl := 0 to Length(forArrayDyn)-1 do
      begin
        SetLength(forArrayDyn, 3);
        Writeln(forArrayDyn[forControl]);
      end;
    end.

     

    In the second for loop, the size of the forArrayDyn changes from 10 to 3 and yet the for loop is able to access the elements above index 2.

    Given that for loops evaluate the initial and final values only once at the beginning of the loop, shouldn't this generate an AV?

    I understand that in memory there are still elements in positions where index >=3 but shouldn't the code break?

    The set length does affect the array because when I set a breakpoint I can see the change.

     

    Thanks!

     

     

     


  10. Hi people,

     

    I'd like some help about user management servers and how they are used in apps.

     

    This is a general question that applies to getting access to users either via Active Directory or FB contacts or Google contacts, etc.

     

    Say I have a connection to FB or to active Directory and people login in my app using FB or AD credentials. Now, all my users exist on FB or on AD

     

    In my app, users do stuff and therefore I need to keep some data as well. So, this means I need to replicate and keep a sunchronised copy of the user database.

     

    Is this how it should work? What's the common practice here?

     

    Thanks 


  11. Remy, thanks for the explanation and for sharing your knowledge 👍. I admit that even if I had gone all the way down to retrieve the enumerators I would never have thought to Invoke them.

     

    I use 10.3.3 and the first instance of TKey in System.Generics.Collections is this:

    ------> This is line 748
      (*$HPPEMIT END OPENNAMESPACE*)
      (*$HPPEMIT END '  template<typename TKey, typename TValue>'*)
      (*$HPPEMIT END '  inline __fastcall TPair__2<TKey, TValue>::TPair__2(const TKey AKey, const TValue AValue) :'*)
      (*$HPPEMIT END '                                            Key(AKey), Value(AValue)'*)
      (*$HPPEMIT END '  {}'*)
      (*$HPPEMIT END CLOSENAMESPACE*)
      [HPPGEN(HPPGenAttribute.mkNonPackage)]
      TPair<TKey,TValue> = record
        Key: TKey;
        Value: TValue;
        constructor Create(const AKey: TKey; const AValue: TValue);
      end;
    
      // Hash table using linear probing
      TDictionary<TKey,TValue> = class(TEnumerable<TPair<TKey,TValue>>)
      private type
        TItem = record
          HashCode: Integer;
          Key: TKey;
          Value: TValue;
        end;
        TItemArray = array of TItem;

     


  12. @Remy Lebeau Wow....Amazing and complicated stuff. So I really need to drill down to the enumerator to get hold of the pairs.

     

    Thanks a lot for this!!!

     

    You mentioned that it might be unreliable to do this with generics. Do you think the app may crash for more complex dictionaries?

     

    22 minutes ago, Remy Lebeau said:
    Quote

    In the code above, I replaced TKey with string because I couldn't find the declaration of TKey.

    Because it doesn't exist.  For a dictionary, TKey and TValue are Generic parameters of the TDictionary class.  They are not standalone concrete types, like you are thinking of.

    And out of curiosity, how does the compiler recognise TKey then? It must be from the HPPEMIT directive, right?


  13. Ok, now the more important problem as stated in the beginning. In this code, genDict throws an exception although propValue is correct

    program Project1;
    
    {$APPTYPE CONSOLE}
    
    {$R *.res}
    
    uses
      System.SysUtils,
      System.Generics.Collections,
      System.Rtti;
    
    type
      TObjDic = TObjectDictionary<string, string>;
    
      TMClass = class
      private
        fMC: TObjDic;
      public
        constructor Create;
        destructor Destroy; override;
        
        property MC: TObjDic read fMC write fMC;
      end;
    
    constructor TMClass.Create;
    begin
      inherited;
      fMC:=TObjDic.create;
    end;
    
    destructor TMClass.Destroy;
    begin
      fMC.Free;
      inherited;
    end;
    
    var
      mc: TMClass;
      ctx: TRttiContext;
      rType: TRttiType;
      rProp: TRttiProperty;
      propValue: TValue;
      genDict: TObjectDictionary<string, TValue>;
    
    begin
      mc:=TMClass.Create;
      rType := ctx.GetType(mc.ClassInfo);
      rProp:=rType.GetProperty('MC');
      // In this code, this may seem redundant but I use this code is part of
      // bigger codebase
      propValue:=rProp.GetValue(mc);
      genDict:=nil;
      genDict:=propvalue.AsObject as TObjectDictionary<string, TValue>;
      if Assigned(genDict) then
      begin
        for var str in genDict.Keys do
        begin
          // For demo
          var f:=str;
        end;
        genDict.Free;
      end;
      mc.Free;
    end.

     

×