Jump to content

dummzeuch

Members
  • Content Count

    2857
  • Joined

  • Last visited

  • Days Won

    101

Everything posted by dummzeuch

  1. If it's only about blocking Google, why not simply post the password on the site itself?
  2. TJSONObject.Size was deprecated and replaced by .Count in Delphi XE6, so up to Delphi XE5 you have to use .Size (because .Count doesn't exist) and from Delphi XE6 on you either live with the deprecated warnings (.Size is still available in Delphi 10.3) or replace the calls with .Count. But even if you accept those warnings, sooner or later you will have to address them because Embarcadero decided to finally remove the deprecated code. So, what if you want your code to compile on all versions that support JSON without warnings? E.g. in my u_dzGoogleTranslate unit there is the following code: if o.Size <> 3 then raise Exception.CreateFmt(_('Parsing error on JSON answer: Root object size is %d not 3.'), [o.Size]); where o is a TJSONObject. This compiles fine in all Delphi versions that have JSON support but starts throwing deprecated warnings from Delphi XE6 on. So, what are my options? I could IFDEF all those calls: {$IFDEF JSONOBJ_HAS_COUNT} if o.Count <> 3 then raise Exception.CreateFmt(_('Parsing error on JSON answer: Root object size is %d not 3.'), [o.Count]); {$ELSE} if o.Size <> 3 then raise Exception.CreateFmt(_('Parsing error on JSON answer: Root object size is %d not 3.'), [o.Size]); {$ENDIF} Which would be fine for one single line, but there are dozens of similar lines which renders the code unreadable. I could IFDEF complete functions instead but that would mean to fix any bug in all these functions. I could add a class helper for TJSONObject that adds the missing Count function for earlier versions (I think they all support class helpers, so that would be doable.) I could derive TdzJSONObject from TJSONObject and add the missing Count function but that would not work for RTL code that returns a TJSONObject. I could write an inlined wrapper function JSONObject_size that encapsulates that IFDEF. That would improve readability but but would still be ugly. I could drop support for Delphi XE5 or earlier, but I'd rather not. You never know when you're going to need that. Can you think of any other options?
  3. OK, I should have provided some background: This library is a hobby project of mine, there are only a very limited number of people that use it: I myself at work my two coworkers (but only in Delphi 2007, XE2 and lately 10.2) I myself (again) in many of my open source projects that support various versions of Delphi (for GExperts that means Delphi 6 and later), but not all units from that library are important for this Even though this library has been open source (MPL) for at least 15 years, I have never heard of anybody else using it (Which I think is a shame, but hey, they just don't know what they are missing out. 😉 ) So, I don't want to drop compatibility if it can be kept without too much hassle, I'm asking for alternatives. Believe it or not: Maintaining backwards compatibility can be fun if it involves creative (mis-)uses of language features. I am programming in Delphi for fun, not just for the paycheck, otherwise I would have dropped Delphi for Visual Studio more than 10 years ago.
  4. dummzeuch

    Align right in Converts Strings

    Applied. Thanks again.
  5. I wrote my own TThread class descendant which sets the name to the class name. It also automatically sets the name "Main" for the main thread. (Don't the latest Delphi versions already do that?)
  6. While fixing some bugs in the code formatter I came across a functionality that I didn't know about: procedure bla; begin end; The formatter can insert a fixed comment above each procedure like this: { procedure } procdure bla; begin end; It does this only if the configuration option CommentFunction is set to True. It's False by default and there is no GUI way to set it, so I never noticed. I think the way it currently works is pretty pointless, especially since the comment is hard coded as '{ procedure }' and is inserted above each procedure, function constructor and destructor. Even if there is already a different comment: { This is a comment } procdure bla; begin end; becomes { This is a comment } { procedure } procdure bla; begin end; Nobody needs that. Would any other automatically created comment be more useful? I can't think of any, but maybe somebody else has an idea? Currently I'd rather remove that functionality. I don't think a code formatter should add comments, it should simply format the source code that is there.
  7. dummzeuch

    Delphi Licensing

    I have no idea what might cause this, but since support is unable to resolve this, I would expect them to issue a new license just in case there is something wrong with the old one on Embarcadero's side. Since there are two different computers involved on your side it is likely to be a problem on their side. Hm, thinking about it: Has anything changed regarding your internet access? Is it possible that Embarcadero's servers can no longer be contacted? Could you maybe try to move your laptop to a friend and try his internet access to make sure? An option for support to help you could also be to convert your license to a Network Named User license. That would require you to run your own license server, but could prevent anything like this happening again.
  8. That's actually one change I made over Easter: The Formatter does no longer insert a blank line between a comment and the procedure it describes. Are there any other experts in GExperts that do this?
  9. dummzeuch

    Align right in Converts Strings

    Create a diff of all changed files (TortoiseSVN can do that, see TortoiesSVN -> Create Patch) and send it to me via private message or upload it as an attachment to a feature request on sourceforge.
  10. dummzeuch

    Align right in Converts Strings

    Might be a nice addition. Care to submit a patch?
  11. The base Exception class introduces various constructors. If you use ressources strings, there are two options: raise Exception.CreateFmt(MY_RES_STRING, [parameters, go, here]); raise Exception.CreateResFmt(@MY_RES_STRING, [parameters, go, here]); The second form is the one used everywhere in the RTL/VCL. It actually accepts a PResStringRec parameter. Up to now I also used that form in some of my internal libraries. But when I enabled the "Typed @ operator" compiler option today to get the compiler to find some errors in my code, it turned out that this form doesn't compile any more (in Delphi 2007, haven't tried anything else). Given that the first form works fine, why would I want to use the second form anyway?
  12. dummzeuch

    AV in GExperts with Themes

    I have never seen that problem, but I rarely use 10.3 and I don't use DevExpress at all. The call stack suggests that it happens in the drawing code somewhere, but apart from that I have no idea where to look.
  13. dummzeuch

    Which Objects Allow ActiveControl?

    Which doesn't help, since he is using Lazarus, not Delphi: On the other hand, the source code for the LCL is also available, but it's much more convoluted than the VCL, because it's supposed to be cross platform.
  14. Due the the COVID19 pandemic I am currently working from home, using Putty + ssh + Remote Desktop to log into and work on my office PC. For this to work, the office PC must be turned on and booted. So far I have let it running 24h which is really a waste of energy but since sometimes nobody is in the office at all, that was the most fool proof way. Today I have had some time at my hands waiting for an Ubuntu server to finish installing, so I thought about alternatives. ... read on in my blog post.
  15. Apparently not. At least I have not seen any spontaneous awakenings 😉 of our office computers. There are three check boxes on the "Power Management" tab of the network controller properties (on my computer): * Allow the computer to turn off this device to save power * Allow this device to wake the computer * Only allow a magic packet to wake the computer On my computer, all of them are set. On a colleagues' computer the last one was not set. My colleague said that he didn't touch this (but on the other hand I don't remember doing that either on my computer), so I don't know what the default is. I can only assume that it depends on some circumstances during the installation. Maybe different hardware, or maybe whether the computer belongs to a domain or not (mine doesn't, the colleague's does).
  16. Aparently many modern computers are already configured to wake on any LAN activity, not just the WOL magic package. So e.g. trying to RemoteDesktop into a computer might be sufficient to wake it up. I tested this with two of our computers, both of which had a special setting to restrict WOL to the "magic package", which seems to be off by default. But I am not sure from which state this will work. WOL didn't work at the one time I actually shut down the computer rather than hibernating it. Another one didn't wake up from sleep. The only state for which this has always worked for me was hibernate.
  17. No, that's perfectly valid. But why don't you decleare RecPointer as ^TIniRec and save yourself the typecasting? Or are there pointers to different types? If the latter, why do you use records instead of classes? Actually I don't think this should compile: TComparedData = record PointerRecType: TRecType; // this identifies RecPointer as TINIRec RecPointer: Pointer; // Pointer to TINIRec ... function IsSectionHeaderLine: boolean; end; function TComparedData.IsSectionHeaderLine: boolean; begin Result := false; if RecPointer <> nil then Result := TINIRec(RecPointer^).IsSectionHeader; // <-- this should not compile as RecPointer is an untyped pointer and therefore RecPointer^ is undefined. end;
  18. No, that one is sent by the computer which runs the ssh server.
  19. It does, but unfortunately only on a daily basis which would mean that it starts on weekends (and doesn't shut down so it runs all weekend). WOL is probably the easiest option for me (now that I know that it works) since I log on to an ssh server first thing anyway, so I can simply call a script that wakes up my PC. I could even automate via .profile it but that would mean that PC starts every time I log on even if I don't need it.
  20. Only one for ssh (but not the default port). Everything is tunnelled through an ssh connection.
  21. I can't look at my office PC now (it's in the office, I am not and I can't connect to it because it's hibernated 😉 ), but on my home PC there is indeed such a setting: EDIT: Wonders of remote access: Yes, you are right, it's supported. I just ssh'd into the LAN installed etherwake and woke up my PC using the wakeonlan command. Apparently the option just doesn't show up in the BIOS. Thank you very much for this hint!
  22. Recently I came across a problem with INI files: Some editors (including recent versions of Windows Notepad) add a byte order mark (BOM) to the files they save. In particular the BOM for UTF-8 kept appearing in INI files which then were read incorrectly by the Delphi 2007 implementation of TMemIniFile (I guess the same applies to all pre Unicode versions of Delphi). In particular this was a problem with programs that used TJvAppIniStorage for streaming application settings to disk. (TJvAppIniStorage internally uses TMemIniFile.) So I tried to fix this ... read on in my blog post
  23. I just got a very odd error message from a TJvSaveDialog: M.A1R.SigBrightness_2020-03-25 The filename is not valid. As you can see in the screenshot, there are already several files with the same name scheme in that directory: The dialog seems to come from the Windows Dialog itself, at least the call stack doesn't show any JVCL or RTL code after the call to Execute. I admit that the file name is a bit unconventional, but it should still be valid. If I save the file as e.g. 'bla.dat' I can later on simply rename it to the name I originally intended. Also, if the file already exists and I simply select it, I get an overwrite prompt and then can save the file. To be sure that there are'nt any invisible characters there, I type the whole thing. The error occurs anyway. I also tried different directories, on the server and on a local drive, even in the root of drive d:. No difference. WTF is going on here?
  24. OK, found it: The problem was not the file name but the filter (Save as type): If I change it to *.* it works. Seems that Windows for whatever reason doesn't like the filter to contain a * at the end of the extension (in my case "*.SigBrightness*". If I switch to the filter "*.SigBrightness" (without the trailing *), Windows appends ".SigBrightness" to the file name, which I can then manually remove and save the file with the intended name. Now, how do I get Windows to show the selection I want but still let me save the file?
  25. I think that some functionality in GExperts (and some of my other tools) could profit from switching from sorted TStringLists to a dictionary. Unfortunately I can't just use TDictionary<string, [whatever]> because I want to continue supporting Delphi versions that didn't have generics (in particular Delphi 2007). Does anybody know of a free dictionary implementation that stores pointers indexed by strings? I know of THashedStringList but it has too many gotchas to simply use it (e.g. the hashes get recalculated every time a new item was inserted and IndexOf is called, which is exactly what I would need to do). Yes, I could write one myself, but why reinvent the wheel if there already is one?
×