Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation since 06/07/21 in Posts

  1. David Heffernan

    Out parameter is read before set

    Out params in Delphi kinda suck because the compiler does nothing to enforce out semantics. Compare and contrast with C#.
  2. Dalija Prasnikar

    Out parameter is read before set

    It is valid alert. You need to initialize out parameters before they are used. Only managed out types will be automatically initialized. When you mark parameter as out, you are saying I will properly initialize that variable (setting to nil is also proper initialization in this context) If you don't initialize that parameter inside the method, then this is a bug and your method signature is telling a lie. If you want to initialize variables outside the method, then you should use var parameter. The fact that Delphi automatically initializes only managed out types, is just implementation detail of the compiler. In theory it is behavior that may change, most likely it will not, but out parameter is meant for output, compiler is free to discard its value in the function prologue.
  3. Pascal Analyzer is trying to tell you: "Your method misses to initialize aList before entering the loop, because in case the loop is empty or condition is always false you end up with an uninitialized out parameter aList!" So, yes, it is a valid alert and although you may get away with it in most cases, it may fire back sometimes. It should be possible to create a use case where it fails.
  4. Anders Melander

    Stratched image is wrong if bmp dimention >32767 (RAD2007)

    Try Graphics32: Use a TBitmap32 with a memory backend (instead of a GDI backend) and display it with a TImage32/TImgView32 control. That of course requires that the bitmap is 32-bit or that it's feasible to convert it to 32-bit in order to display it.
  5. type TJobflag = (jfstart, jfAdd, jfLoaded, jfDone); Tcompareflag = (cfCaps, cfDupes); Jobs = set of TJobflag; Compares = set of Tcompareflag; function AddItems2(const aArray: array of string; var aList: TStrings; aCompareSet: Compares) : TJobflag; var jobSpecification: Tcompareflag; S: string; RC: Boolean; begin result := jfDone; RC := False; for S in aArray do begin for jobSpecification in aCompareSet do begin RC := (jobSpecification = cfCaps) // and // compare S for Caps; RC := RC or (jobSpecification = cfDupes) //and dupes found If RC then begin if not assigned(aList) then aList := TStringList.create aList.add(S); end; end; result := jfLoaded; end; end; try if AddItems2(['Hello', 'World'],lst, [cfCaps]) = jfLoaded then Writeln('True') else Writeln('False'); if lst <> nil then Writeln(lst.Text); finally { uncommenting this will raise an invalid pointer exception later } // lst.Free; end; Or procedure loadLists aList := TStringList.create result := jfDone; for S in aArray do begin for jobSpecification in aCompareSet do begin RC := (jobSpecification = cfCaps // and // compare S for Caps; RC := RC or (jobSpecification = cfDupes) //and dupes found If RC then aList.add(S); If RC then jobStatus := jfLoaded; end; end; end; // future Procedure processLists Abover my spin on it use enums to determine status testing for list = nil does not tell if list need was ever tested.
  6. sgcWebSockets is a complete package providing access to HTML5 WebSockets API (WebSocket is a web technology providing for bi-directional, full-duplex communications channels, over a single Transmission Control Protocol (TCP) socket) allowing to create WebSocket Servers, and WebSocket clients in VCL, Lazarus and Firemonkey Applications.  What's new - New STUN Server and client components, allows to discover public IP address and can be used for WebRTC applications. STUN Delphi Client and Server - Apple Push Notifications Support using HTTP/2 client component. How Register App Send HTTP/2 Notifications Apple Push Notifications using JWT Apple Push Notifications using a Certificate - Improved OAuth2 Client, now supports Client Credentials, this means that can run as a service or an automated application. OAuth2 Client Credentials - FTX API is now supported allowing to receive real-time market data, place new orders, manage account and more. FTX API Client - Free TradeBar Application for Binance and Coinbase Pro Brokers. Shows how use sgcWebSockets API Clients to send Orders to the Broker. TradeBar for Binance TradeBar for Coinbase Pro Main Features: - WebSocket and HTTP/2 Support: sgcWebSockets includes client and server-side implementations of the WebSocket protocol (RFC 6455). HTTP/s is also full supported. Support for plain TCP is also included. - SSL/TLS for Security: Your messages are secure using our SSL/TLS implementation. Widest compatibility via support for modern TLS 1.3 and TLS 1.2 - Protocols and APIs: Several protocols are supported: MQTT (3.1.1 and 5.0), STOMP, WEBRTC, SIGNALR CORE, WAMP... Built-in protocols support Transactions, Datasets, QoS, big file transfers and more. APIs supported for third-parties like Binance, Coinbase, Kraken, FTX... - Cross-platform: Share your code using our WebSockets library for your Delphi VCL, Firemonkey, Javascript and .NET projects. Includes Server, Clients and several protocols for building and connecting to WebSocket applications. - High Performance WebSocket Server based on Microsoft HTTP Framework and IOCP. Trial Version: https://www.esegece.com/websockets/download Compiled Demos: https://www.esegece.com/download/sgcWebSockets_bin.zip More Info: https://www.esegece.com/websockets
  7. If the error just could be reproduced here in my environment, I would do. Nevertheless, I will add madExcept in the next release.
  8. The stucture relates to the class and its methods as seen in the tree view to the left. F.i. if only the order of methods in a class changes, be it in the interface or the implementation, the structured difference would rate that as equal. Inside each method the diff is the same as a simple line diff.
  9. Lars Fosdal

    Apple XCode Cloud

    https://developer.apple.com/xcode-cloud/ You'll still need a Mac, but you don't need to own every Apple device.
  10. ZRomik

    READ_SMS permission not requested

    Yes! On phone work too Thanks for help Lars Fosdal
  11. VMware users, patch now! https://www.bleepingcomputer.com/news/security/attackers-are-scanning-for-vulnerable-vmware-servers-patch-now/
  12. Lars Fosdal

    READ_SMS permission not requested

    https://google-developer-training.github.io/android-developer-phone-sms-course/Lesson 2/2_p_sending_sms_messages.html Has SMS access been enabled for the app in the Android settings? Also, best practices: https://stackoverflow.com/questions/32814922/why-does-android-ignore-read-sms-permission
  13. I think the problem is a result of inlined function name adjustment with "_", so if removing the inline identifier will make it work then google for this specific problem, i am not a much help in this case, also have a look at this section "C99 inline functions" on this page https://clang.llvm.org/compatibility.html
  14. what happens if you replace MYBOOL with bool and PRICER_DEVEX and PRICER_STEEPSTEDGE with plain integer constants (eg 2 or 3 or 4....) ? If you get the same problem then this would be a more helpful form to post your problem source code (since your quoted code does not include definitions of these block capital items). Or, if it starts working, can you include the definitions we need to get the code to be like yours (in this case it could be that MYBOOL is being defined differently in the debug and release compilations for example....)
  15. We are glad to announce that the 4.85 StyleControls VCL has just been released! http://www.almdev.com StyleControls VCL is a powerful, stable package of components, which uses Classic drawing, system Themes, GDI+ and VCL Styles. This package contains the unique solutions to extend standard VCL controls and also has many unique, advanced controls to create applications with UWP / Fluent UI design. The new version adds new features requested by customers.
  16. Yes and no, I mean "out" is giving back a fresh variable to its caller. The state before should be considered undefined, it can exist, can have values, can be nil. I would say that in the 1. line inside the method, this does not exist, since the out parameter shall give back a new parameter. Whatever it was before shall not matter. From my opinion this is what "out" should originally stands for, even if it maybe can be misused somehow. On the other side, "var" brings in an existing parameter, inside the method, which can be used or changed at will.
  17. And here it is: program Project804; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils, System.Classes; function AddItems(const aArray: array of string; out aList: TStrings): boolean; var S: string; begin { can we really omit this? No! } //aList := nil; for S in aArray do if S.Length > 0 then begin if aList = nil then aList := TStringList.Create; // only create aList if any items gets added aList.Add(S); end; Result := aList <> nil; end; var lst: TStrings; begin try lst := nil; try if AddItems(['Hello', 'World'], lst) then Writeln('True') else Writeln('False'); if lst <> nil then Writeln(lst.Text); finally { uncommenting this will raise an invalid pointer exception later } //lst.Free; end; try { Although being an out parameter, the current lst instance will be used inside AddItems } if AddItems(['Delphi'], lst) then Writeln('True') else Writeln('False'); if lst <> nil then Writeln(lst.Text); finally lst.Free; end; except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; Readln; end.
  18. 1) As long as you don't need input value of Counts, it's better to mark it "out" instead of "var" 2) When you declare a type for counts, you can zero it with "Default": "counts := Default(TCounts)"
  19. Interesting. I implemented like this: type TCounts = array[TDocType] of Cardinal; procedure CountAllItems6(const aDocuments: TDocuments; var counts: TCounts); var i: integer; dt: TDocType; begin for dt := Low(TDocType) to High(TDocType) do counts[dt] := 0; for i := Low(aDocuments) to High(aDocuments) do Inc(counts[aDocuments[i].DocType]); end; And results (changed to 100mio doc lines):
  20. Sounds like bullshit to me. No random crashes that we didn't cause ourselves that I can remember, and I've used every Delphi version there is, on most of the Windows versions there has been.
  21. Rollo62

    Using VMWare: what files remain on host?

    I find it very convenient to have a common _Transfer\ folder, which is available on the host, and shared in all VM's. This helps to easily share files and data between the different VM's. Thos files were stored on the host, and in the VM's they were only virtually binded. Of course this is not intended to be opend for write from several VM's or the host at the same time, but just for manual exchange (e.g. for PAServer files, etc).
  22. Remy Lebeau

    Binary data in String?

    https://en.wikipedia.org/wiki/ISO/IEC_8859-1 there are 65 undefined characters
  23. Remy Lebeau

    Binary data in String?

    Many ANSI charsets DON'T have all 256 bytes mapped.
  24. Lajos Juhász

    Binary data in String?

    Try https://en.wikipedia.org/wiki/Windows-1251 one character is undefined hex 98. https://en.wikipedia.org/wiki/Windows-1250 there 5 undefined characters.
  25. Remy Lebeau

    Binary data in String?

    Most likely, that code predated the shift to Unicode in Delphi 2009. No, it doesn't. It has the potential to corrupt the data. This is exactly why you SHOULD NOT put binary data into a UnicodeString. Doesn't work. It fills only 1/2 of the UnicodeString's memory with the non-textual binary (because SizeOf(WideChar) is 2, so the SetLength() is allocating twice the number of bytes as were read in), then converts the entire UnicodeString (including the unused bytes) from UTF-16 to ANSI producing complete garbage, and then writes that garbage as-is to file. So yes, the same number of bytes MAY be written as were read in (but that is not guaranteed), but those bytes are useless. That code is copying the binary as-is into an AnsiString of equal byte size, converting that AnsiString to a UTF-16 UnicodeString using the user's default locale, then converting that UnicodeString from UTF-16 back to ANSI using the same locale. Depending on the particular locale used, that MAY be a lossy conversion, you MIGHT end up with the same bytes that you started with, or you MIGHT NOT. This has nothing to do with pointers. You are simply performing 2 separate data conversions (binary/ANSI -> UTF-16 -> binary/ANSI ) that just HAPPEN to produce the same results as the input IN YOUR ENVIRONMENT.
×