Archive for the ‘Delphi’ Category
Posted by jpluimers on 2016/12/14
Back in the .NET days, Delphi had an FINITEFLOAT compile option that came without a single-character shortcut.
It was about the handling of infinite float and other special float values in cases like overflow and underflow (including +Inf, -Inf and [Wayback] NaN).
At first – in the [Wayback] Delphi 8 (Octane) era of which few people want to be reminded off – it was the [Wayback] undocumented counterpart of the [Wayback] 8087 exception mask in x86 mode. Hallvard Vassbotn wrote an article about it and Chee Wee Chua documented it before it got documented in Delphi 2009 (that coincidentally dropped .NET support in the compiler – go figure):
Whereas the native Delphi compilers had exceptions turned on, Microsoft compilers (including .NET) had them turned off, hence the compiler option.
Like most new Delphi features in this century, FINITEFLOAT didn’t come without quirks. Often these are fleshed out in 2-3 product releases, but this one wasn’t:
The FINITEFLOAT compile option didn’t have a single-character shortcut. This made it impossible to use the {$IFOPT ...} construct as IFOPT only works for single-character compiler options.
Which means you get questions like [Wayback] Why doesn’t {$ifopt FINITEFLOAT ON} compile? – Stack Overflow (I actually got into writing this article because I found a {$DEFINE FINFINITEFLOAT_ENABLED} in some pretty old code) and compiler enhancement requests like [WayBack] QualityCentral – Please enhance the IFOPT directive for long switch names. It’s easier to read (which will likely never bee fixed).
For completeness some more information about exception masks in the native compiler:
- In the past you could only set the exception mask as part of the full control word using [Wayback] Set8087CW, nowadays you can use [Wayback] SetExceptionMask.
- Next to a precision mask, there are five exception masks you can set, see for instance this table from the [Wayback] Simply FPU Chap.1 Control Word section:
PM (bit 5) or Precision Mask
UM (bit 4) or Underflow Mask
OM (bit 3) or Overflow Mask
ZM (bit 2) or Zero divide Mask
DM (bit 1) or Denormalized operand Mask
IM (bit 0) or Invalid operation Mask
–jeroen
Posted in 8087, Algorithms, Delphi, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 8, Development, Floating point handling, History, QC, Software Development | 1 Comment »
Posted by jpluimers on 2016/12/14
Some links; hopefully I can fill in more details later:
–jeroen
Posted in Delphi, Delphi 2007, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2016/12/07
Formy snippet archive (thanks Walter Prins for answering and Oliver Funcke for asking and elaborating on the answer):
in the case of error, you can get what would’ve normally been in the contentstream from the ExceptionObj.ErrorMessage property. So you can use something like the following if you want to get the content response regardless of http response code (untested):
var
FResponseStream: TStringStream;
FRequestURL, Content : String;
begin
//.... etc etc
try
FIdHTTP.Get(FRequestURL, FResponseStream);
Content := FResponseStream.DataString;
except
on E:EIdHTTPProtocolException do
Content := E.ErrorMessage;
end;
// At this point, "Content" contains the response body, both for
// successful (200) as well as other response codes.
//.... etc etc
end;
….
You can even do it simpler:
Response := IdHTTP.Get('http://host/path', [404]);
Source: delphi – Indy and REST – Can I prevent exceptions? – Stack Overflow
–jeroen
via:
Posted in Delphi, Delphi 10 Seattle, Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development | 2 Comments »
Posted by jpluimers on 2016/12/01
In a quest to perform SFTP in Delphi next to FTP, I first researched what I was up against. A tiny voice in the back of my head said “SFTP is totally unlike FTP” and it was right: SFTP means SSH File Transfer Protocol, not Simple File Transfer Protocol nor FTP over SSH nor FTP over SSL aka FTPS – the latter is supported by Indy but the former isn’t.
I decided against SecureBlackBox (providing SFTPBlackbox) and IPWorks (SSH) as I tried both a while ago for S/MIME support and was disappointed about both the lack of features and documentation; in the end I went for wrapping OpenSSL for the “encrypt-then-sign” process and Indy for the SSMTP part. The merger of the SecureBlackBox and IPWorks made me even less happy.
The Chilkat alternative for SFTP isn’t too compelling either: ActiveX or DLL black-box without a lot of insight on how many people do use it.
So when I had to do SFTP and knew there are no free or open source SFTP components for Delphi available I opted for thinking outside the Delphi realm.
My basic idea was to embed either of these:
- Filezilla (as Filezilla on Windows is waaaay faster than WinSCP)
- WinSCP (a Windows SCP and SFTP client written in C++ Builder)
- PSFTP (the Putty SFTP client)
FileZilla
FileZilla internally uses FzSFtp.exe which is based on PSFTP code (but with some buffers making it faster than PSFTP or WinSCP).
According to the author, neither FzSFtp.exe nor FileZilla can be automated:
FileZilla cannot make any automated transfers at all. Neither FileZilla.exe nor fzsftp.exe (is for SFTP) can be used for any batch processing.
Source: run filezilla tzsftp from batch command line – FileZilla Forums
The WinSCP author commented in a similar fashion:
FileZilla does not have any command line arguments (nor any other way) that allow automatic transfer.
Source: windows – Command line option to download file in FileZilla – Stack Overflow
In addition, FileZilla is always a GUI program, so running it as a console app (which I’d prefer) would be impossible.
WinSCP
WinSCP can be automated in two ways:
- The WinSCP.exe command-line allows for a
/console and /script switch enabling scripting mode that you can use for Scripting and Task Automation :: WinSCP
- A wrapper around WinSCP.exe is availble as WinSCP .NET Assembly and COM Library :: WinSCP which requires both .NET to be installed and (from Delphi) calling through COM which I don’t like much
Since I already had good Delphi wrapping code round starting/waiting-for running processes, I’d opt for using WinSCP.com scripting.
There used to be wrapping code around: Use with Delphi :: Support Forum :: WinSCP
PSFTP
These Using PSFTP to transfer files securely links should get me going:
Chapter 6: Using PSFTP to transfer files securely
Practical examples:
Source locations
For my own reference, the open source locations:
Some semi-random Delphi SSL related postss
During the search above I found the below links that will be useful to me one day:
–jeroen
Posted in .NET, Delphi, Development, Software Development, SSH, TCP | 5 Comments »
Posted by jpluimers on 2016/12/01
Posted in Delphi, Delphi 10 Seattle, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 7, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development, Uncategorized | Leave a Comment »
Posted by jpluimers on 2016/11/30
Since Uwe Schuster only published a screenshot, I NewOCR-ed it and created the accompanying .dproj file (only because it’s an easy way for the DLL to require the designide package so you can use the DesignIntf and ToolsAPI units.
Uwe only posted these:
Anyway, the sources are at gist.github.com/881d4eacbcec2a9e1e6b0181f900fd7a, but the main source is this:
library DisableAlignPropertyEditor;
{
Originally only as jpg image by Uwe Schuster.
https://web.archive.org/web/20161117154454/https://pbs.twimg.com/media/Cxaoi-DXEAAMF03.jpg:large
https://web.archive.org/web/20161117154450/https:/twitter.com/UScLE/status/799011392703647744
https://web.archive.org/web/20161117154501/https://plus.google.com/107811538224738992137/posts/hTXUwkCe1TV
}
uses
System.SysUtils,
System.TypInfo,
DesignIntf,
ToolsAPI;
var
LastRegisterPropertyEditorProc: TRegisterPropertyEditorProc = nil;
procedure NewRegisterPropertyEditor(PropertyType: PTypeInfo; ComponentClass: TClass; const PropertyName: string; EditorClass: TPropertyEditorClass);
begin
if Assigned(EditorClass) then
begin
if SameText('TAlignProperty', EditorClass.ClassName) then
Exit;
end;
LastRegisterPropertyEditorProc(PropertyType, ComponentClass, PropertyName, EditorClass);
end;
procedure wizardTerminate;
begin
RegisterPropertyEditorProc := LastRegisterPropertyEditorProc;
end;
function wizardInit(const BorlandIDEServices: IBorlandIDEServices; RegisterProc: TWizardRegisterProc; var Terminate: TWizardTerminateProc): Boolean; stdcall;
begin
LastRegisterPropertyEditorProc := RegisterPropertyEditorProc;
RegisterPropertyEditorProc := NewRegisterPropertyEditor;
Terminate := wizardTerminate;
Result := True;
end;
exports
wizardInit name WizardEntryPoint;
begin
end.
–jeroen
Read the rest of this entry »
Posted in Delphi, Delphi 10.1 Berlin (BigBen), Development, Software Development | 2 Comments »
Posted by jpluimers on 2016/11/30
For my G+ Link archive:
Can some recommend a good tool to build MSI package?I use Inno Setup but only to build EXE file.Thanks, – Chris Z. – Google+
Source: Can some recommend a good tool to build MSI package? I use Inno Setup but only…
Related:
Posted in Delphi, Development, Installer-Development, Software Development | Leave a Comment »
Posted by jpluimers on 2016/11/29
A long time ago, Lars Fosdal wrote this on the Delphi G+ group:
It really is beyond me why there is no Project.rc file which includes
- Project.version.rc
- Project.icon.rc
- Project.themes.rc
- Project.manifest.xml
- and so forth.
That way, the .res file would be a compile-time thing (or even a thing of the past) – and the resource linker would assemble the various bits from their individual sources.
It has been an issue forever. Vincent Parrett correctly commented that if you clean out too much out of the Project.res file, the IDE gets confused:
The only thing it is used for is version info and the mainicon (the IDE gets confused if don’t do that).
In my own experience, this isn’t the case for all Delphi versions, but I forgot which versions suffer and which don’t. I think the IDE theming issue omitting the Application word in the .dpr is related.
Like many of the G+ commenters, I’ve switched to script based resources for my own projects a long time ago. That’s also the reason why I forgot: this approach just works for any Delphi version.
This post is a reminder to self to see if the IDE has finally refrained from doing Project.res handling itself.
–jeroen
Source: The curse of the Project.res file…
Some related posts:
Posted in Delphi, Delphi 1, Delphi 10 Seattle, Delphi 2, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 3, Delphi 4, Delphi 5, Delphi 6, Delphi 7, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development | 5 Comments »
Posted by jpluimers on 2016/11/28
Yes. Yes. Yeesssss!
It solves [WayBack] debugging – F12 not working in Delphi debugger on Windows 7/8 – Stack Overflow
Due to robots.txt the site cannot be archived in the WayBack machine, so I’m keeping a local copy of any http://andy.jgknet.de/blog/wp-content/plugins/download-monitor/download.php?id=* files.
This is how I installed the extracted DelphiF12HotKeySupport.dll:
Read the rest of this entry »
Posted in Delphi, Development, Software Development | Leave a Comment »