Recent

Author Topic: Only you guys can understand the beauty of this  (Read 4456 times)

esvignolo

  • Full Member
  • ***
  • Posts: 159
  • Using FPC in Windows, Linux, Macos
Only you guys can understand the beauty of this
« on: July 30, 2016, 11:28:49 pm »
Only you guys can understand the beauty of this, Thank you all for this!

Code: Pascal  [Select][+][-]
  1.  
  2. function OSVersion: String;
  3. var sCPU, sOs, sWidgetSet: string;
  4. begin
  5.   sOs:='OTHER';
  6.   sCPU:='???';
  7.   sWidgetSet:='';
  8.   {$IFDEF UNIX              }    // --UNIX--
  9.     {$IFDEF LINUX           }
  10.        sOs:='LINUX';
  11.     {$ENDIF}
  12.     {$IFDEF BSD             }    // --BSD--
  13.       {$IFDEF FREEBSD       }    // FREEBSD
  14.         sOs:='FREEBSD';
  15.       {$ENDIF}
  16.       {$IFDEF NETBSD        }    // NETBSD
  17.         sOs:='NETBSD';
  18.       {$ENDIF}
  19.       {$IFDEF DARWIN        }    // Macintosh
  20.         sOs:='MAC';
  21.       {$ENDIF}
  22.     {$ENDIF}
  23.   {$ENDIF}
  24.   {$IFDEF WINDOWS       }        // --WINDOWS--
  25.     sOs:='WIN';
  26.   {$ENDIF}
  27.  
  28.    //CPU
  29.   {$IFDEF CPUI386}
  30.     sCPU:='x86';
  31.   {$ENDIF}
  32.   {$IFDEF CPUX86_64}
  33.     sCPU:='x64';
  34.   {$ENDIF}
  35.   {$IFDEF CPUARM}
  36.     sCPU:='-ARM';
  37.   {$ENDIF}
  38.  
  39.   //WIDGETSET
  40.   {$IFDEF LCLQt}
  41.    sWidgetSet:='Qt';
  42.   {$ENDIF}
  43.   {$IFDEF LCLGTK}
  44.    sWidgetSet:='Gtk2';
  45.   {$ENDIF}
  46.   {$IFDEF LCLGTK2}
  47.    sWidgetSet:='Gtk2';
  48.   {$ENDIF}
  49.   {$IFDEF LCLGTK3}
  50.    sWidgetSet:='Gtk3';
  51.   {$ENDIF}
  52.   {$IFDEF LCLWin32}
  53.    sWidgetSet:='Win';
  54.   {$ENDIF}
  55.   {$IFDEF LCLCocoa}
  56.   sWidgetSet:='Cocoa';
  57.   {$ENDIF}
  58.   {$IFDEF LCLCarbon}
  59.    sWidgetSet:='Carbon';
  60.   {$ENDIF}
  61.   Result:=sOS+sCPU+' ('+sWidgetSet+')';
  62. end;    
  63.  

shobits1

  • Sr. Member
  • ****
  • Posts: 271
  • .
Re: Only you guys can understand the beauty of this
« Reply #1 on: July 30, 2016, 11:40:16 pm »
and???

esvignolo

  • Full Member
  • ***
  • Posts: 159
  • Using FPC in Windows, Linux, Macos
Re: Only you guys can understand the beauty of this
« Reply #2 on: July 30, 2016, 11:53:03 pm »
cross-platform, multiwidgetset and multiarchitecture. Write once, compile everywhere. That u can see in the code.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Only you guys can understand the beauty of this
« Reply #3 on: July 31, 2016, 01:08:51 am »
well, if you don't like it, make it slightly shorter:
Code: [Select]
uses
  .. InterfaceBase...

function OSVersion: String;
begin
  Result:={$I %FPCTARGETOS%}+'-'+{$I %FPCTARGETCPU%}+' ('+WidgetSet.ClassName+')';
end;
« Last Edit: July 31, 2016, 01:10:34 am by skalogryz »

esvignolo

  • Full Member
  • ***
  • Posts: 159
  • Using FPC in Windows, Linux, Macos
Re: Only you guys can understand the beauty of this
« Reply #4 on: July 31, 2016, 01:11:11 am »
Great change!!, thanks! :D :D

I love the possibilities in FPC :)

shobits1

  • Sr. Member
  • ****
  • Posts: 271
  • .
Re: Only you guys can understand the beauty of this
« Reply #5 on: July 31, 2016, 10:55:44 am »
cross-platform, multiwidgetset and multiarchitecture. Write once, compile everywhere. That u can see in the code.
ohh,,, I thought you asking a question  :-[.

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: Only you guys can understand the beauty of this
« Reply #6 on: July 31, 2016, 11:47:46 am »
i like skalogryz's solution better as that at least supports all supported processors, operating systems and widgetsets  :P

 

TinyPortal © 2005-2018