Jump to content

Virgo

Members
  • Content Count

    86
  • Joined

  • Last visited

Posts posted by Virgo


  1. The reason I asked about how the program is started, that when it is started with Task Scheduler (sometimes programs use Task Scheduler to start program at user login) then there is check mark at trigger properties "Stop task if it runs longer than:" which defaults to 3 days. Maybe it is accidentally checked (it is not checked by default).


  2. 12 minutes ago, Remy Lebeau said:

    I checked, and overload was added to TFileStream in Delphi 6, when the 3-parameter constructor for passing in Rights was introduced.

    Right. And fpc allows in objfpc mode multiple constructors without overload, which explains why  TFileStream in fpc has two constructors (2 parameters and 3 parameters), but does not allow creating TFileStream with THandleStream constructor.

     


  3. Quote

    A method can be redeclared using the overload directive. In this case, if the redeclared method has a different parameter signature from its ancestor, it overloads the inherited method without hiding it. Calling the method in a descendent class activates whichever implementation matches the parameters in the call.

    So it appears, that calling TFileStream.Create with handle parameter works because, TFIleStream has constructors with overload;

    That is something, that I newer knew.

     

    Works in all Delphi ja FPC versions. Just in FPC TFileStream constructors are not with overload;

     


  4. Strange. Passing handle to TFIleStream.Create does not work in Delphi 5, but works in Delphi XE. It also does not compile in FPC 3.2.0. And I do not understand, why it compiles with Delphi XE.

    After all, TComponent.Create; does not compile....


  5. libvlc_media_tracks_release( LTracksPtr, LCount );
    

    should be correct

    In get function tracks is var parameter.  Which is pointer. So that LTracksPtr itself is required parameter for release.

    You can also always add types
     

    Plibvlc_media_track_t = ^libvlc_media_track_t;
    
    PPlibvlc_media_track_t = ^Plibvlc_media_track_t;

    and then functions would be
     

    function libvlc_media_tracks_get(p_md : libvlc_media_t_ptr; var tracks : PPlibvlc_media_track_t ) : LongWord; cdecl;
    procedure libvlc_media_tracks_release(tracks : PPlibvlc_media_track_t ; i_count : LongWord ); cdecl;

     


  6. 1 hour ago, bazzer747 said:

    I'm aware that you can use a macro substitution in a select statement when you don't know some value until runtime (like a fieldname). If there a similar function that can be used in a Locate?

     

    What is the actual question? That is what locate function does. You pass fieldname and search value at runtime and it searches.


  7. Bpl is basically just dll file with different extension (Borland Pascal Library). You cannot edit those in notepad. If SQL is in resources, then you might be able to change that resource with resource editor (if bpl is not digitally signed). But then your query will only ever return first 100 records.


  8. 4 hours ago, Attila Kovacs said:

    System.SysUtils.StringReplace:  "FoundPos := Pos(xOldPattern, Str, FoundPos);"

     

    Fail.

    So it is different in different Delphi versions.... In Delphi XE StringReplace does not use Pos... Instead it uses SysUtils.AnsiPos.

    But on possible reasons why on negative cases (search string is not found) StringReplace is slower to return then checking with Post before (just in case sensitive version and on Delphi XE):

    Multiple functions calls to find position of search string (StringReplace->AnsiPos->StrPosLen->StrLComp

    String concatenation always.

     

    • Like 1

  9. There is not alias I on assignment... So the error is correct. Replace I.CURRATE with select to get correct value..

    Maybe?

    SELECT I.CURRATE FROM INVOICE I WHERE I.RNO = ID.RNO

     


  10. 23 minutes ago, Uwe Raabe said:

    According to the docwiki, InternalCalc fields are only supported in TClientDataSets:

     

    Ok, so it is dependant of actual TDataSet descendant.

    Anyway, did some reading and for Interbase/Firebirdsql fields declared in server as COMPUTED BY fields are also InternalCalc fields in Delphi (with IBX and components forked from it). Basically very specific usage.


  11. I just managed to get InternalCalc field in my older version of Delphi and there it still behaves as normal calculated field in filters and sorting (not working). Maybe it depends on particular TDataSet descendant having support for this. 


  12. You could try adding somethin like following to select (example is for Firebirdsql, mod is different in MSSQL

    CASE
    WHEN EXTRACT(MONTH FROM DATEFIELD) < 4 THEN CAST(EXTRACT(YEAR FROM DATEFIELD) - 1 AS CHAR(4)) || '-' || CAST(MOD((EXTRACT(YEAR FROM DATEFIELD)), 100) AS CHAR(2))
    WHEN EXTRACT(MONTH FROM DATEFIELD) > 4 THEN CAST(EXTRACT(YEAR FROM DATEFIELD) AS CHAR(4)) || '-' || CAST(MOD((EXTRACT(YEAR FROM DATEFIELD)+1), 100) AS CHAR(2))
    WHEN EXTRACT(MONTH FROM DATEFIELD) = 4 THEN
        CASE
        WHEN EXTRACT(DAY FROM DATEFIELD) < 7 THEN CAST(EXTRACT(YEAR FROM DATEFIELD) - 1 AS CHAR(4)) || '-' || CAST(MOD((EXTRACT(YEAR FROM DATEFIELD)), 100) AS CHAR(2))
        WHEN EXTRACT(DAY FROM DATEFIELD) >= 7 THEN CAST(EXTRACT(YEAR FROM DATEFIELD) AS CHAR(4)) || '-' || CAST(MOD((EXTRACT(YEAR FROM DATEFIELD)+1), 100) AS CHAR(2))
        END
    ELSE
    NULL
    END cTaxYear

     

    But that does gives 2006-7 instead of 2006-07....


  13. But also, from

    if (P = nil) or (PyBytes_AsStringAndSize(presult, P, Len) < 0) then begin

     

    "(p = nil) or" should be removed, because P is uninitialized, which only means, that it causes error, when P happens coincidentally initialize to nil.


  14. After reading Python documentation I do not understand, how it can work in Delphi.

    Move

              _stream := TMemoryStream.Create();
              try
                _stream.Write(P^, Len);
                _stream.Position := 0;
                Image1.Picture.Graphic.LoadFromStream(_stream);
              finally
                _stream.Free;
              end;


    before

            finally
              Py_XDECREF(pResult);
            end;

     

    P will be reference to internal buffer in pResult and Py_XDECREF(pResult); frees that memory.

    • Like 1
×