[Lazarus] Universal using of mailto:

Graeme Geldenhuys graemeg.lists at gmail.com
Wed Dec 10 14:29:11 CET 2008


2008/12/10 Ireneusz Wyglądała <kornisch at gmail.com>:
>
> So. I should use defines {IFDEF ... and two different methods for both OS?
> I had hopes that exist one universal way to use mailto: ?
> OK. I do it.
> Thanks a lot.

What I have done, is to abstract that those calls, so my application
doesn't need to contain the IFDEF's.  I have one "utilities" unit that
contains any IFDEF and *no* other place.

Something like the following

    -------[ MyCoolUtilitiesUnit.pas ]--------------
    uses
       {ifdef windows}
         MyWindowsUtilities,
       {endif}
       {ifdef unix}
          MyUnixUtilities,
       {endif}
       SysUtils;

     functions SendEmai(....): integer;
     begin
       {ifdef windows}
         WindowsSendEmail(...);  //   <---  located in MyWindowsUtilities unit
       {endif}
       {ifdef unix}
          UnixSendEmail(...);  //  <--- located in MyUnixUtilities unit
       {endif}
     end


So now anywhere in your application you can simply include the
'MyCoolUtilitiesUnit' in the uses clause and call SendEmail() -
without IFDEF. :-)

One can't always avoid ifdef's but you can limit them to a single unit
in your application.


Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/




More information about the Lazarus mailing list