Jump to content

Virgo

Members
  • Content Count

    86
  • Joined

  • Last visited

Everything posted by Virgo

  1. Virgo

    [Need help] Linux recv() timeout

    Unfortunately I do not have Delphi version new enough. But maybe there is an overloaded version, that allows required parameters? Indy own TIdSocketHandle.SetScokOpot also has AOptVal:Integer... But GStack.SetSocketOption seems to have required version.
  2. Virgo

    [Need help] Linux recv() timeout

    What SetSockOpt are you using? In Linux SO_RCVTIMEO parameter is supposed to be a pointer to timeval record. Not Int.
  3. What I ment was, that I got an impression, that SHA1ofStr and Base64Encode functions were originally written for pre-Unicode Delphi. And to make them work on Unicode Delphi version String was just replaced with AnsiString. And on old Delphi versions it was usual to use string as byte buffer. Event Delphi itself did it.
  4. Since hash function results binary hash and not hexencoded one and the function predates Unicodestring Ansistring result makes sense. UnicodeString for binary hash would be the worst type.
  5. Really strange... That output value decodes to hexencoded value 1d29ab734b0c9585240069a6e4e3e91b613f69 Correct value would be 1d29ab734b0c9585240069a6e4e3e91b61da1969 So da19 to 3f or lead surrogate-da19 to question mark? Some sort weird unicode issue?
  6. Virgo

    Send basic email not working for me

    SSLHandler variable is not initialized... So Access Violation is mandatory.
  7. Embedded web server at random port and use http://localhost:port/ as redirect url...
  8. Virgo

    How many end keywords are there?

    Semicolon is also forbidden before else...
  9. Which part of this would apply to sample program in original post? Windows 8.1 is not listed as supported platform, but if Windows 7 is supported, then that should not be an issue. And if it works Windows 10 PE, then that makes it unlikely, that it uses something like AVX. Although, compiling it with all optimizations off would be something to try. Other thing would be to remove SysUtils usage... Just in case, that it is something in SysUtils initialization. As I understand, problem is not with IDE but with statically linked command line program, that only uses System and SysUtils units.
  10. What kind of programming languages have you actually used before? Because you would have same issues in most languages... Event in javascript or python you need an instance to actually use it.
  11. Lets not forgot overcommit . On some platforms allocating memory from OS can succeed, but later writing that memory can fail, because no memory is available.
  12. Without those quotes the code would not compile...
  13. Virgo

    Freeing a non-modal form

    Right... Actually with owner set only overriding notification is needed... And assigning OnClose and OnDestroy from owner form is probably simpler idea.. with assigned OnDestroy clearing handles instead Notification. I mean we actually use OnDestroy to clear global form variables in form units, when form is free (with check, if Self is same as variable).
  14. Virgo

    Freeing a non-modal form

    ChildForm sest Action to caFree on OnClose event handler Owner calls FreeNotification(ChildForm) after creating the childform. Owner overrides Notification() and when it receives notification, that childform is freed, then sets variable to nil (or whatever needs to be done). Owner calls RemoveFreeNotification(ChildForm) when it is going to manually free childform or when owner itself is going to be freed.
  15. There is always possibility, that it was old internal utility created by some developer.
  16. I somehow managed to miss width parameter. With it it is really possible to rewrite WriteStr as format and since Delphi does not have WriteStr, it is best solution. Better than trying to hack around with file. So: s2 := format('x = %10.4f, y = %10d, s = %20s', [x, y, s]); would be same as WriteStr(s2, 'x = ', x:10:4, ', y = ', y:10, ', s = ', s:20);
  17. That only applies, if goal is to write to file or stdout. My example code did writeln to result string just to get, what the value was. Real use can be different. But depending, what WriteStr features were used it should be possible to rewrite it in Delphi.
  18. No it is not. TWriter.WriteString writes strings. example: program writeStrTest; {$mode objfpc} {$H+} var x: extended; y: Int64; s, s2: string; begin x := 193.17; y := 123746214; s := 'Some tekst'; WriteStr(s2, 'x = ', x:10:4, ', y = ', y:10, ', s = ', s:20); WriteLn(s2); end. will output x = 193.1700, y = 123746214, s = Some tekst format is closest thing in Delphi, but format does not have ability to pad values with spaces (if user requires it).
  19. Str just converts number to string.... As David Schwartz writes, format is functionally similar, but it has different syntax (format is more like C printf than Pascal Write). But unlike fpc Delphi does not seem to have WriteStr.
  20. Virgo

    FileOpen dialog not showing all files

    And I managed to miss, that Anders Melander had already posted link to explanation....
  21. Virgo

    FileOpen dialog not showing all files

    32 bit programs show contents of C:\Windows\SYSWOW64, when looking at C:\Windows\SYSTEM32. 64 bit programs show contents of C:\Windows\SYSTEM32, when looking at C:\Windows\SYSTEM32. Basic 64 bit Windows thing.
  22. TFDScript is for executing SQL scripts AFAIK. https://docwiki.embarcadero.com/RADStudio/Sydney/en/Executing_SQL_Scripts_(FireDAC)
  23. I would suggest actually reading original post you are responding to...:) Posted with keyboard without "Context Menu key"
  24. Virgo

    C to Delphi pascal

    Indeed. And it is quite likely, that actual problem is invalid JSON. Besides strings with quotes in them additional possible problem is, if decimal separator is not dot.
  25. Virgo

    C to Delphi pascal

    Sample for doing same thing with Synapse THTTPSend: procedure TestPost; var H: THTTPSend; S: UTF8String; Res: Boolean; begin H := THTTPSend.Create; try S := '{"recipient":"testing@checkbook.io","name":"Widgets Inc.","amount":5,"description":"Test Payment"}'; H.MimeType := 'application/json'; //synapse has separate propery for content-type header H.Headers.Add('accept: application/json'); H.Headers.Add('Authorization: XXXXX'); H.Document.Write(S[1], Length(S)); Res := H.HTTPMethod('POST', 'https://demo.checkbook.io/v3/check/digital'); if Res then begin SetLength(S, H.Document.Size); if H.Document.Size > 0 then H.Document.Read(S[1], H.Document.Size); ShowMessage(format('%d: %s', [H.ResultCode, S])); end else ShowMessage(H.Sock.LastErrorDesc); finally H.Free; end; end; ends with 400: {"error":"Invalid authorization header"} Because sample XXXXX authorization header is not correct obviously....
×