[WayBack] Dear diary, today I learned that it is better to use ifndef rather than ifdef if I want the IDE to keep working properly. I had a uses clause with an i… – Stefan Glienke – Google+
I promised to remind myself, so here it is (:
–jeroen
Posted by jpluimers on 2017/12/28
[WayBack] Dear diary, today I learned that it is better to use ifndef rather than ifdef if I want the IDE to keep working properly. I had a uses clause with an i… – Stefan Glienke – Google+
I promised to remind myself, so here it is (:
–jeroen
Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | Leave a Comment »
Posted by jpluimers on 2017/12/27
It’s too bad that you need workarounds to get ByteStrings working on mobile devices as there are APIs there (like shaders) that work best with them.
There was a nice discussion on this last year at [WayBack] I miss AnsiString on Mobile…not only for Internet but for Shaders also.// FMX.Context.GLES.pasconstGLESHeaderHigh: array [0..24] of byte =(Byte(‘p), … – Paul TOTH – Google+ based in this code example in the FMX library undocumented unit FMX.Context.GLES:
// FMX.Context.GLES.pas
const
GLESHeaderHigh: array [0..24] of byte =
(Byte('p'), Byte('r'), Byte('e'), Byte('c'), Byte('i'), Byte('s'), Byte('i'), Byte('o'), Byte('n'), Byte(' '),
Byte('h'), Byte('i'), Byte('g'), Byte('h'), Byte('p'), Byte(' '), Byte(' '), Byte(' '), Byte('f'), Byte('l'),
Byte('o'), Byte('a'), Byte('t'), Byte(';'), Byte(#13));
There are more than 500 places in the Delphi library sources that uses this construct and even more that do other fiddling (like [WayBack] TEncoding.GetBytes) to get from strings to bytes.
I wonder if by now we still need the workarounds that Andreas Hausladen provides:
–jeroen
Posted in Conference Topics, Conferences, Delphi, Development, Encoding, Event, Software Development | 6 Comments »
Posted by jpluimers on 2017/12/21
I started this post as “A case against FreeAndNil” but soon found out about [WayBack/Archive.is] A case against FreeAndNil – Community Blogs – Embarcadero Community.
Recently I was refactoring a bunch of code that was classed based to become interface based.
The old code had a lot of references to classes like this:
FMyField: TMyClass;
The compiler had detected those as compiler errors so now they were like this:
FMyField: IMyInterface;
But the compiler would still happily compile code (for instance in destructors) containing:
FreeAndNil(FMyField);
The only way that FreeAndNil can be implemented is with an untyped var parameter:
Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | 14 Comments »
Posted by jpluimers on 2017/10/31
A few tricks to write long strings to files when the Delphi debugger cuts them off (just because they like using 4k buffers internally);
TStringStream.Create(lRequestMessage).SaveToFile('c:\temp\temp.txt')TIniFile.Create('c:\a.txt').WriteString('a','a',BigStringVar)TFileStream.Create('c:\a.txt', fmCreate or fmShareDenyNone).WriteBuffer(Pointer(TEncoding.UTF8.GetBytes(BigStringVar))^,Length(TEncoding.UTF8.GetBytes(BigStringVar)))They all work form the debug inspector, but they do leak memory. See comments below.
Via:
–jeroen
Posted in About, Conference Topics, Conferences, Delphi, Development, Encoding, Event, Software Development | 6 Comments »
Posted by jpluimers on 2017/09/14
Some inspiration for writing a proper bookmarklet that finds or saves a WayBack machine page:
On the last link, I was hoping that the https://web.archive.org/liveweb/https://www.example.org would work but it doesn’t work for many URLs and I’m not sure yet why that is.
It has a nice tip that works though:
Posted in Bookmarklet, Conference Topics, Conferences, Development, Event, JavaScript/ECMAScript, Power User, Scripting, Software Development, Web Browsers | Leave a Comment »
Posted by jpluimers on 2017/09/11
I was debugging an issue where a Delphi SOAP implementation was shoe-horned into an Indy server and came across the [WayBack] TWebRequest.UpdateMethodType Method.
The further you get down the if/then/else tree, the more often the indexed property Method is accessed, same for the conversion/comparison code.
property Method: string index 0 read GetStringVariable;
So if the HTTP method is POST (very common), then the calls are being made 3 times:
procedure TWebRequest.UpdateMethodType;
begin
{$IFDEF NEXTGEN}
if Method = 'GET' then { do not localize }
FMethodType := mtGet
else if Method = 'PUT' then { do not localize }
FMethodType := mtPut
else if Method = 'POST' then { do not localize }
FMethodType := mtPost
else if Method = 'HEAD' then { do not localize }
FMethodType := mtHead
else if Method = 'DELETE' then { do not localize }
FMethodType := mtDelete
else if Method = 'PATCH' then { do not localize }
FMethodType := mtPatch;
{$ELSE !NEXTGEN}
if System.AnsiStrings.AnsiStrComp(PAnsiChar(Method), 'GET') = 0 then { do not localize }
FMethodType := mtGet
else if System.AnsiStrings.AnsiStrComp(PAnsiChar(Method), 'PUT') = 0 then { do not localize }
FMethodType := mtPut
else if System.AnsiStrings.AnsiStrComp(PAnsiChar(Method), 'POST') = 0 then { do not localize }
FMethodType := mtPost
else if System.AnsiStrings.AnsiStrComp(PAnsiChar(Method), 'HEAD') = 0 then { do not localize }
FMethodType := mtHead
else if System.AnsiStrings.AnsiStrComp(PAnsiChar(Method), 'DELETE') = 0 then { do not localize }
FMethodType := mtDelete
else if System.AnsiStrings.AnsiStrComp(PAnsiChar(Method), 'PATCH') = 0 then { do not localize }
FMethodType := mtPatch;
{$ENDIF NEXTGEN}
end;
–jeroen
Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | 4 Comments »
Posted by jpluimers on 2017/09/05
Interesting stuff:
via:
In more detail:
Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | 3 Comments »
Posted by jpluimers on 2017/04/20
You think you know Unicode? Think again, then read [Wayback] Dark corners of Unicode / fuzzy notepad.
On basics, sorting, comparison, decomposition, composition, width, whitespace, encoding, emoji, interesting code planes and dark corners. Lots of dark corners.
The examples are in Python, but hold for almost any programming language
–jeroen
via: Kristian Köhntopp
Posted in Conference Topics, Conferences, Development, Encoding, Event, Software Development, Unicode | Leave a Comment »
Posted by jpluimers on 2017/04/18
One of the reasons I favour using RTL based functionality over Delphi Intrinsic Routines like Length, Abs and others is that you cannot use compiler intrinsics in Generics. For instance Length is not compatible with TFunc<string, Integer> unless you declare it yourself like function StringLength(value: string): Integer; as otherwise you get en E2029 error (in this case the cryptic '(' expected but ';' found).
It’s one of the many areas where the Delphi compiler developers took a shortcut, but in this case I think the results are somewhat good.
Other reasons for using the RTL over compiler intrinsics have to do with scoping: the intrinsics are in the global scope which can clutter what you’re trying to work on.
So I much rather use the file and stream related functions when I’m actually working with a file or stream. For instance Assign for me has nothing to do with a file outside of a file context (it’s the reason AssignFile exists in the first place).
–jeroen
via: I cant use “Length” as a TFunc (tested in XE and XE6), but if…
Posted in Conference Topics, Conferences, Delphi, Delphi 10 Seattle, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Event, Software Development | 1 Comment »