Recent

Recent Posts

Pages: 1 2 3 [4] 5 6 ... 10
31
Beginners / Re: Does anyone know why these code cannot be compiled by the fpc?
« Last post by Laksen on April 19, 2024, 03:04:14 pm »
The proper way to initialize a record is to name each field:
Code: Pascal  [Select][+][-]
  1. const efi_loaded_image_protocol_guid:efi_guid=(data1: $5B1B31A1; data2:$9562; data3: $11D2; data4: ($8E,$3F,$00,$A0,$C9,$69,$72,$3B));

A nice shortcut if you use instead the inbuilt TGuid is that you can write:
Code: Pascal  [Select][+][-]
  1. const efi_loaded_image_protocol_guid: TGuid = '{5B1B31A1-9562-11D2-8E3F-00A0C969723B}';
32
Networking and Web Programming / Re: Who is Indy mattias?
« Last post by jollytall on April 19, 2024, 02:54:16 pm »
I have just checked the executable (under Linux I am). It was 3.5MB, now it is 13.2MB and I changed nothing. Can it be because of the Interfaces added?
33
Databases / Re: Database standards OR Am I doing this right?
« Last post by gidesa on April 19, 2024, 02:37:56 pm »
Hello, Ms Sql Server, as many dbms, has different types of lock: at row level, at page level, at table level, etc.
The isolation level defines the extension of lock.
For example, with "Serializable" level the db engine locks entirely all tables involved in the logic transaction, so that a second user cannot never change data managed by the first user, until the end of first transaction.
See detailed (and long) description: https://learn.microsoft.com/en-us/sql/relational-databases/sql-server-transaction-locking-and-row-versioning-guide?view=sql-server-ver16
And you have to understand the concept of logic transaction. Simplifying, a transaction contains all db (Zeos) instructions comprised between the  Begin transaction and Commiy (or Rollback if you want to cancel all updates).
In short, the TZConnection component has a property TransactionIsolationLevel that you can set to the 4 possible values, as descripted in previous link.
From another discussion: https://zeoslib.sourceforge.io/viewtopic.php?t=2644 a possible sequence of Zeos instructions:
//At connection:
TransactionIsolationLevel := tiNone;

//At StartTransaction:
TransactionIsolationLevel := tiReadCommited;

// do all select, update, delete, .... on various tables

//At Commit, that is when confirming the updates
Commit;
TransactionIsolationLevel := tiNone;

//Or, at Rollback, that is when you want to cancel the updates,
// for example in case of exception
RollBack;
TransactionIsolationLevel := tiNone;

34
Beginners / Does anyone know why these code cannot be compiled by the fpc?
« Last post by TYDQ on April 19, 2024, 02:36:08 pm »
Code: Pascal  [Select][+][-]
  1. type efi_guid=record
  2.               data1:dword;
  3.               data2:word;
  4.               data3:word;
  5.               data4:array[1..8] of byte;
  6.               end;
  7. const efi_loaded_image_protocol_guid:efi_guid=($5B1B31A1,$9562,$11D2,($8E,$3F,$00,$A0,$C9,$69,$72,$3B));
It seems have no problem in pascal,why these pascal code cannot be compiled and show the error that Syntax error, "identifier" expected but "ordinal const" found?
35
Networking and Web Programming / Re: Who is Indy mattias?
« Last post by jollytall on April 19, 2024, 02:27:19 pm »
Thanks, it is like magic. It works.

However, I still do not understand:
- How mattias is hardcoded in so many places?
- How could it work in the past with - I guess the same - Indy10 without adding Interfaces?
What is Interfaces, anyway? Why I never met it before?

Thanks.

36
General / Re: How to: create DLL file for Windows 10 64-Bit Pro
« Last post by TRon on April 19, 2024, 02:26:53 pm »
Is the point the "definition" ?
Yes.

And as a consequence how your code calls that routine (e.g. what parameters (types) you pass it).
37
General / Re: How to: create DLL file for Windows 10 64-Bit Pro
« Last post by paule32 on April 19, 2024, 02:15:29 pm »
it is a little bit hard to follow the postings from 440bx.
Is the point the "definition" ?
38
General / Re: How to: create DLL file for Windows 10 64-Bit Pro
« Last post by KodeZwerg on April 19, 2024, 02:08:54 pm »
You're missing the whole point.
After reading I do agree you.
39
Unix / Re: A fairly simple sound solution?
« Last post by paweld on April 19, 2024, 01:46:11 pm »
40
Graphics / Re: Demoscene The Champs Cracktro
« Last post by KodeZwerg on April 19, 2024, 01:45:18 pm »
Here are some copperbars :D
Code: Pascal  [Select][+][-]
  1. unit uMain;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls,
  9.   BGLVirtualScreen, BGRAOpenGL, BGRABitmap,
  10.   BGRABitmapTypes, BGRAGradientScanner;
  11.  
  12. type
  13.   TCopperBar = packed record
  14.     Gradient: TBGRACustomGradient;
  15.     Y: Integer;
  16.     Size: Integer;
  17.     IsAdd: Boolean;
  18.   end;
  19.   TCopperBars = array of TCopperBar;
  20.  
  21. type
  22.  
  23.   { TForm1 }
  24.  
  25.   TForm1 = class(TForm)
  26.     BGLVirtualScreen1: TBGLVirtualScreen;
  27.     Panel1: TPanel;
  28.     Timer1: TTimer;
  29.     procedure BGLVirtualScreen1Redraw(Sender: TObject; BGLContext: TBGLContext);
  30.     procedure BGLVirtualScreen1Resize(Sender: TObject);
  31.     procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
  32.     procedure FormShow(Sender: TObject);
  33.     procedure Timer1Timer(Sender: TObject);
  34.   strict private
  35.     FCB: TCopperBars;
  36.     FMaxBars: Integer;
  37.   private
  38.     procedure ReleaseCB;
  39.     procedure GenerateCB(const AMaxBars: Integer);
  40.   public
  41.   end;
  42.  
  43. var
  44.   Form1: TForm1;
  45.  
  46. implementation
  47.  
  48. {$R *.lfm}
  49.  
  50. { TForm1 }
  51.  
  52. procedure TForm1.BGLVirtualScreen1Redraw(Sender: TObject;
  53.   BGLContext: TBGLContext);
  54. var
  55.   i: Integer;
  56.   sy: Integer;
  57. begin
  58.   for i := High(FCB) downto Low(FCB) do
  59.     for sy := 0 to FCB[i].Size do
  60.       begin
  61.         if FCB[i].IsAdd then
  62.           Inc(FCB[i].Y)
  63.         else
  64.           Dec(FCB[i].Y);
  65.         if FCB[i].Y < BGLContext.Canvas.ClipRect.Top then
  66.           FCB[i].IsAdd := True;
  67.         if FCB[i].Y > BGLContext.Canvas.ClipRect.Height then
  68.           FCB[i].IsAdd := False;
  69.         BGLContext.Canvas.FillRect(0, FCB[i].Y, BGLContext.Canvas.ClipRect.Width, Succ(FCB[i].Y), FCB[i].Gradient.GetColorAtF(sy));
  70.         if FCB[i].IsAdd then
  71.           BGLContext.Canvas.FillRect(0, FCB[i].Y - FCB[i].Size, BGLContext.Canvas.ClipRect.Width, Succ(FCB[i].Y - FCB[i].Size), FCB[i].Gradient.GetColorAtF(FCB[i].Size - sy))
  72.         else
  73.           BGLContext.Canvas.FillRect(0, FCB[i].Y + FCB[i].Size, BGLContext.Canvas.ClipRect.Width, Succ(FCB[i].Y + FCB[i].Size), FCB[i].Gradient.GetColorAtF(FCB[i].Size - sy));
  74.       end;
  75. end;
  76.  
  77. procedure TForm1.BGLVirtualScreen1Resize(Sender: TObject);
  78. begin
  79.   ReleaseCB;
  80.   GenerateCB(FMaxBars);
  81. end;
  82.  
  83. procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);
  84. begin
  85.   ReleaseCB;
  86.   CloseAction := caFree;
  87. end;
  88.  
  89. procedure TForm1.FormShow(Sender: TObject);
  90. begin
  91.   Randomize;
  92.   GenerateCB(10);
  93.   Timer1.Interval := 50;
  94.   Timer1.Enabled := True;
  95. end;
  96.  
  97. procedure TForm1.Timer1Timer(Sender: TObject);
  98. begin
  99.   BGLVirtualScreen1.Repaint;
  100. end;
  101.  
  102. procedure TForm1.ReleaseCB;
  103. var
  104.   i: Integer;
  105. begin
  106.   for i := High(FCB) downto Low(FCB) do
  107.     begin
  108.       FCB[i].Size := 0;
  109.       FCB[i].Y := 0;
  110.       FCB[i].IsAdd := False;
  111.       FCB[i].Gradient.Free;
  112.       FCB[i].Gradient := nil;
  113.     end;
  114. end;
  115.  
  116. procedure TForm1.GenerateCB(const AMaxBars: Integer);
  117. var
  118.   i: Integer;
  119.   Y: Integer;
  120. begin
  121.   FMaxBars := AMaxBars;
  122.   SetLength(FCB, FMaxBars);
  123.   Y := BGLVirtualScreen1.Height;
  124.   for i := Low(FCB) to High(FCB) do
  125.     begin
  126.       FCB[i].Size := 10;
  127.       Y := Y - (FCB[i].Size);
  128.       FCB[i].Y := Y;
  129.       FCB[i].Gradient := TBGRAMultiGradient.Create([RGBToColor(Random(High(Byte)), Random(High(Byte)), Random(High(Byte))), clBlackOpaque], [0, FCB[i].Size], True, False);
  130.       FCB[i].IsAdd := True;
  131.     end;
  132. end;
  133.  
  134. end.
Pages: 1 2 3 [4] 5 6 ... 10

TinyPortal © 2005-2018