Virgo
-
Content Count
86 -
Joined
-
Last visited
Posts posted by Virgo
-
-
What SetSockOpt are you using?
In Linux SO_RCVTIMEO parameter is supposed to be a pointer to timeval record. Not Int.
-
2 minutes ago, David Heffernan said:I mean I hope you aren't proposing AnsiString as a place to hold bytes.
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.
-
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.
-
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?
-
3 hours ago, grantful said:procedure SendTestEmail2; var SMTP: TIdSMTP; Message: TIdMessage; SSLHandler: TIdSSLIOHandlerSocketOpenSSL; begin SMTP := TIdSMTP.Create(nil); Message := TIdMessage.Create(nil); //SSLHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil); SSLHandler.SSLOptions.Method := sslvTLSv1_2; // or sslvTLSv1, sslvTLSv1_1, etc.
SSLHandler variable is not initialized... So Access Violation is mandatory.
-
Embedded web server at random port and use http://localhost:port/ as redirect url...
- 2
-
49 minutes ago, Dave Nottage said:The semicolon is optional after an end in some circumstances.
Semicolon is also forbidden before else...
-
9 minutes ago, programmerdelphi2k said:@hoaque my tip is look at https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Installation_Notes
as your Windows is not installed yet, then, can be the "cause" etc..
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.
- 1
-
9 hours ago, Willicious said:t's the idea of instances-of-classes that keeps catching me out. If a class is defined somewhere, it should be callable as that class. Why do I have to redefine/redeclare it in a different unit? Why not this instead:
Unit 1
Class1PropertyA
Unit 2
uses
Class1
if Class1.PropertyA etc...
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.
- 1
-
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.
-
7 hours ago, 357mag said:I don't recall adding those single quotes around x (like ('x')). Don't know what happened there. Mistakes and being human I guess.
Without those quotes the code would not compile...
-
2 hours ago, Remy Lebeau said:If the Owner form assigns itself as the actual Owner (from the RTL's perspective) of the Child form, then the RTL will handle all of that for you automatically. All you would have to do in your own code is have the Owner form override the Notification() method.
However, personally, I would just have the Owner form assign its own handlers to the Child form's OnClose and OnDestroy events instead. That way, the Owner, not the Child, decides whether or not to set Action=caFree in the OnClose event, and the Owner can still react to the Child being destroyed without having to override the Notification() method.
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).
-
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.
- 1
- 1
-
There is always possibility, that it was old internal utility created by some developer.
-
11 minutes ago, Fr0sT.Brutal said:it has: `%10d`
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);
-
7 minutes ago, Lars Fosdal said:Is it unthinkable to simply replace
WriteStr(s2,
withWriteln(
?
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.
-
33 minutes ago, Sherlock said:Hmm almost sounds like a job for TWriter.WriteString which writes to a TStream. If you don't want it to be a file, it could be a TStringStream.
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).
-
9 hours ago, uligerhardt said:That should be just Str.
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.
-
And I managed to miss, that Anders Melander had already posted link to explanation....
-
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.
-
TFDScript is for executing SQL scripts AFAIK.
https://docwiki.embarcadero.com/RADStudio/Sydney/en/Executing_SQL_Scripts_(FireDAC)
-
-
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.
-
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....
- 1
[Need help] Linux recv() timeout
in Indy
Posted
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.