-
Content Count
1090 -
Joined
-
Last visited
-
Days Won
23
Everything posted by aehimself
-
What is the correct approach to "phone home"?
aehimself replied to Der schöne Günther's topic in Project Planning and -Management
#3. You might also want to look into WebDav. That way you simply can copy the file without any additional code (what you have to maintain) on the webserver. -
Binary data in String?
aehimself replied to aehimself's topic in Algorithms, Data Structures and Class Design
Thank you for the explanation, it all makes sense now. I don't really need workarounds; if this area will be touched it will be properly changed instead to use a hack-of-a-hack... Don't get me wrong - I know this should not be done because it won't work; this is why I was this surprised that it does in our case. The sole purpose of this topic was for me to understand why it does, when it should not 🙂 -
Binary data in String?
aehimself replied to aehimself's topic in Algorithms, Data Structures and Class Design
Update: wrong. #0s are not present. Var ss: TStringStream; s: TStream; tb: TBytes; begin ss := TStringStream.Create('Árvíztűrő tükörfúrógép'); Try s := ss; SetLength(tb, s.Size); s.Read(tb, Length(tb)); ShowMessage(TEncoding.Default.GetString(tb)); Finally FreeAndNil(ss); End; Lossy conversion as you mentioned, though. -
Binary data in String?
aehimself replied to aehimself's topic in Algorithms, Data Structures and Class Design
Not most likely, it does. Was Delphi 6 or 7, way before I joined the company. I know, this is why I was really surprised that it actually works like this. We are just lucky with our locale it seems 🙂 First one was only a demonstration; I knew it won't work. I found it strange that the output byte count is the same as the input (because of the double size as you pointed out) though. Guess I was lucky with the random choice of exe. So if I get it right... we read the binary data, doubling it's size as we pad each character with a #0 during AnsiString -> String conversion? The real code is creating a TStringStream out of this and passing it as a parameter of a method, which is expecting a stream. That method will access the contents with .Seek and .Read I suppose. I didn't test this, but am I safe to assume that this would include the extra #0s, causing the binary data to be corrupted? -
A long time ago I found this document, which shows the power of the .Filter property of DataSets. However it is Zeos-referenced I doubt that majority (or all) will not work on a regular dataset component. Feel free to take a look: ZeosLib - Browse /documentation at SourceForge.net and download zExpression.pdf.
-
Are you sure CONTAINING and STARTS are valid filter keywords? I'd try UPPER(ITEMNAME) LIKE ''' + SearchText + '''' instead.
-
Good quality Random number generator implementation
aehimself replied to Tommi Prami's topic in Algorithms, Data Structures and Class Design
Holy crap this is awesome! Imagine shrinking this to a hardware key 😄 -
Read-write protected, but read-only public property?
aehimself posted a topic in Algorithms, Data Structures and Class Design
Hello, I'm wondering how it is possible to achieve. Let's say I have an object: TMyObject = Class(TObject) strict private _status: String; strict protected Property Status: String Read _status Write _status; End; All fine, but how can I publish the same, Status property as public, read-only? In theory I could do (untested, only theory)... TMyObject2 = Class(TMyObject) strict private Function GetStatus: String; public Property Status: String Read GetStatus; End; Function TMyObject2.GetStatus: String; Begin Result := inherited Status; End; and from within TMyObject2's descendants I could say inherited Status := 'MyStatus'; to set the status. Now, can it be achieved that from within the thread I simply say Status := 'MyStatus' and everyone else can access this as a read-only property from the outside? -
Read-write protected, but read-only public property?
aehimself replied to aehimself's topic in Algorithms, Data Structures and Class Design
I'm aware of workarounds. I'm interested if the original one can be achieved. -
Read-write protected, but read-only public property?
aehimself replied to aehimself's topic in Algorithms, Data Structures and Class Design
If it would be, it would be a pretty weak attempt, wouldn't it? 😉 -
Read-write protected, but read-only public property?
aehimself replied to aehimself's topic in Algorithms, Data Structures and Class Design
This is exactly how I made my workaround. I'm just curious if it's possible to use the same name. -
Good quality Random number generator implementation
aehimself replied to Tommi Prami's topic in Algorithms, Data Structures and Class Design
program Project2; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils; Const MAX_NUMBER = 1000; CYCLECOUNT = Integer.MaxValue; Var numbers: Array[0.. MAX_NUMBER - 1] Of Integer; a, min, max: Integer; begin Randomize; For a := Low(numbers) to High(numbers) Do numbers[a] := 0; For a := 1 To CYCLECOUNT Do Inc(numbers[Random(MAX_NUMBER)]); min := CYCLECOUNT; max := 0; For a := Low(numbers) To High(numbers) Do Begin If numbers[a] < min Then min := numbers[a] Else If numbers[a] > max Then max := numbers[a]; End; WriteLn('After ' + CYCLECOUNT.ToString + ' cycle(s), minimum amount of occurrences of the same number is ' + min.ToString + ', maximum is ' + max.ToString); ReadLn; end. After 2147483647 cycle(s), minimum amount of occurrences of the same number is 2144157, maximum is 2150811 That means, the luckiest random number was hit 6654 times more than the least lucky one (from more than 2 billion attempts!). Delphi's internal random number generator has a healthy dispersion. It's not perfect, but it is more than enough for average use. -
Good quality Random number generator implementation
aehimself replied to Tommi Prami's topic in Algorithms, Data Structures and Class Design
Both XOrShift and ISAAC has nice Delphi implementations. They are both PRNGs but it you initialize them with the Random function, they will work quite well. -
Is it possible to dynamically generate an editor GUI based on a data type class?
aehimself replied to wuwuxin's topic in VCL
Joke: In today's world you are better suited with a string type. -
Is (s)he a freelancer / available? 😄
-
Display Componant like Gauges Led and Graphic for Delphi FMX
aehimself replied to Remi1945's topic in I made this
May I ask which site is giving an overview about licenses like this? -
Is a "bare-minimum" EurekaLog possible?
aehimself replied to aehimself's topic in Delphi Third-Party
My main home project atm is ~500k LOC if I'm not mistaken. Linking speed won't be an issue I presume. If I'd be able to encrypt and patch the executable with the .MAP file I think it would be possible to disable all hooks and magic of MadExcept and use it only to fill the .StackTrace of exceptions (unit can be seen here). That'd be an acceptable solution too. -
Also, you can define if LOBs should be cached on load or on access - where supported of course 🙂
-
Is a "bare-minimum" EurekaLog possible?
aehimself replied to aehimself's topic in Delphi Third-Party
You don't have to. I just brought a minimum reproduceable code snipplet to show what built-in language feature is not supported by MadExcept. -
Is a "bare-minimum" EurekaLog possible?
aehimself replied to aehimself's topic in Delphi Third-Party
Which response you mean? To create a bug report and parse it's text from code? -
Is a "bare-minimum" EurekaLog possible?
aehimself replied to aehimself's topic in Delphi Third-Party
http://forum.madshi.net/viewtopic.php?f=4&t=28723 I have the same symptoms. This simple code: procedure TForm1.FormCreate(Sender: TObject); Function RecExDump(E:Exception): String; Begin If Not Assigned(E) Then Exit(''); Result := E.ClassName + ' - ' + E.Message + sLineBreak + E.StackTrace + sLineBreak + sLineBreak + RecExDump(E.InnerException); End; begin Try Try Raise Exception.Create('Original'); Except Exception.RaiseOuterException(EListError.Create('Outer')); End; Except On E:Exception Do ShowMessage(RecExDump(E)); End; End; Shows both exceptions without MadExcept enabled and with EurekaLog. If MadExcept is enabled, EecExDump only sees the outer exception, -
I never said it was the fault of Application.ProcessMessages; it was mine for using it 🙂 Tbh I don't see a difference between running in a cycle of While thread.Terminated Do and dataset.Next millions of iterations. It just depends how much data you have. Sleep was originally uncommented, I think I could go down to 5 ms sleep before starting to eat up the CPU. But since I took a deep breath and started to get rid of this - I don't want to experiment to try to patch-the-patch to make it look better. This time I want to do it right 🙂
-
This is the exact thing I experienced. I took the shortcut when I converted my app to use background threads for operations. Instead of Connection.Connect; DoSomeStuff; I started a thread and did... StartConnectionInBackgroundThread; While Not thread.Finished Do Begin // Sleep(10); Application.ProcessMessages; End; DoSomeStuff; All was fine until only one code like this ran. In the moment two tried to connect simultaneously (not mentioning a couple of occasional deadlocks) connections took 5-10 times more than they normally would, if they connect by themselves. Also, UI was responsive, but sluggish. For 20+ builds now I'm in the process to get rid of this shortcut I thought was a good idea before. And while it did what I wanted to achieve on the surface - it did backfire on the long run. For 2+ weeks I'm making changes what the end user might not even realize, and these changes affect 20-30 source files per piece. I completely agree with @Dalija Prasnikar and some others on this matter - I wish I didn't know Application.ProcessMessages exists in the first place 🙂
-
I think that whenever you change the datasource / dataset on the DBGrid it reinitializes everything, including the column captions you set in design time. To change the column caption, you can change the field's DisplayLabel property: dataset.FieldByName('FNAME').DisplayLabel := 'Medlemsnr'; This will cause the DBGrid to display that as a caption automatically when it creates the column. You'll still have to manually change the caption to bold every time, that is.
-
On a memo it indeed has the rectangle. I guess it'll have to do with TLabel being a TGraphicControl instead of a TWinControl. I don't know how to fix it but I can offer an alternative. I have similar loading indicators but just dropping it in front of everything will not catch the user's attention immediately. You can try to put it on a DimPanel, that way the background "issue" will disappear too: