Ignore:
Timestamp:
Mar 4, 2022, 10:57:08 PM (3 years ago)
Author:
chronos
Message:
  • Added: Compile multiple action for compilation of code with mutliple compilers at once.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/UCommon.pas

    r129 r133  
    88  {$IFDEF WINDOWS}Windows,{$ENDIF}
    99  {$IFDEF UNIX}baseunix,{$ENDIF}
    10   Classes, SysUtils, StrUtils, Dialogs, Process, LCLIntf,
     10  Classes, SysUtils, StrUtils, Dialogs, Process, LCLIntf, Graphics,
    1111  FileUtil; //, ShFolder, ShellAPI;
    1212
    1313type
    1414  TArrayOfByte = array of Byte;
    15   TArrayOfString = array of string;
    1615  TExceptionEvent = procedure(Sender: TObject; E: Exception) of object;
    1716
     
    3534  DLLHandle1: HModule;
    3635
     36const
     37  clLightBlue = TColor($FF8080);
     38  clLightGreen = TColor($80FF80);
     39  clLightRed = TColor($8080FF);
     40
    3741{$IFDEF WINDOWS}
    3842  GetUserNameEx: procedure (NameFormat: DWORD;
     
    5155function ComputerName: string;
    5256procedure DeleteFiles(APath, AFileSpec: string);
     57function Explode(Separator: Char; Data: string): TStringArray;
    5358procedure ExecuteProgram(Executable: string; Parameters: array of string);
    5459procedure FileDialogUpdateFilterFileType(FileDialog: TOpenDialog);
     
    6570function LoadFileToStr(const FileName: TFileName): AnsiString;
    6671function LoggedOnUserNameEx(Format: TUserNameFormat): string;
    67 function MergeArray(A, B: array of string): TArrayOfString;
     72function MergeArray(A, B: array of string): TStringArray;
    6873function OccurenceOfChar(What: Char; Where: string): Integer;
    6974procedure OpenWebPage(URL: string);
     75procedure OpenEmail(Email: string);
    7076procedure OpenFileInShell(FileName: string);
    7177function PosFromIndex(SubStr: string; Text: string;
     
    8389function SplitString(var Text: string; Count: Word): string;
    8490function StripTags(const S: string): string;
    85 function TryHexToInt(Data: string; var Value: Integer): Boolean;
    86 function TryBinToInt(Data: string; var Value: Integer): Boolean;
     91function TryHexToInt(Data: string; out Value: Integer): Boolean;
     92function TryBinToInt(Data: string; out Value: Integer): Boolean;
    8793procedure SortStrings(Strings: TStrings);
    8894
     
    246252end;
    247253
    248 function TryHexToInt(Data: string; var Value: Integer): Boolean;
     254function TryHexToInt(Data: string; out Value: Integer): Boolean;
    249255var
    250256  I: Integer;
     
    262268end;
    263269
    264 function TryBinToInt(Data: string; var Value: Integer): Boolean;
     270function TryBinToInt(Data: string; out Value: Integer): Boolean;
    265271var
    266272  I: Integer;
     
    290296end;
    291297
    292 function Explode(Separator: char; Data: string): TArrayOfString;
    293 begin
    294   Result := nil;
    295   SetLength(Result, 0);
    296   while Pos(Separator, Data) > 0 do begin
     298function Explode(Separator: Char; Data: string): TStringArray;
     299var
     300  Index: Integer;
     301begin
     302  Result := Default(TStringArray);
     303  repeat
     304    Index := Pos(Separator, Data);
     305    if Index > 0 then begin
     306      SetLength(Result, Length(Result) + 1);
     307      Result[High(Result)] := Copy(Data, 1, Index - 1);
     308      Delete(Data, 1, Index);
     309    end else Break;
     310  until False;
     311  if Data <> '' then begin
    297312    SetLength(Result, Length(Result) + 1);
    298     Result[High(Result)] := Copy(Data, 1, Pos(Separator, Data) - 1);
    299     Delete(Data, 1, Pos(Separator, Data));
    300   end;
    301   SetLength(Result, Length(Result) + 1);
    302   Result[High(Result)] := Data;
    303 end;
    304 
    305 {$IFDEF Windows}
     313    Result[High(Result)] := Data;
     314  end;
     315end;
     316
     317{$IFDEF WINDOWS}
    306318function GetUserName: string;
    307319const
     
    311323begin
    312324  L := MAX_USERNAME_LENGTH + 2;
     325  Result := Default(string);
    313326  SetLength(Result, L);
    314327  if Windows.GetUserName(PChar(Result), L) and (L > 0) then begin
     
    324337  end;
    325338end;
    326 {$endif}
     339{$ENDIF}
    327340
    328341function ComputerName: string;
    329 {$ifdef mswindows}
     342{$IFDEF WINDOWS}
    330343const
    331344 INFO_BUFFER_SIZE = 32767;
     
    342355  end;
    343356end;
    344 {$endif}
    345 {$ifdef unix}
     357{$ENDIF}
     358{$IFDEF UNIX}
    346359var
    347360  Name: UtsName;
     
    351364  Result := Name.Nodename;
    352365end;
    353 {$endif}
    354 
    355 {$ifdef windows}
     366{$ENDIF}
     367
     368{$IFDEF WINDOWS}
    356369function LoggedOnUserNameEx(Format: TUserNameFormat): string;
    357370const
     
    431444procedure LoadLibraries;
    432445begin
    433   {$IFDEF Windows}
     446  {$IFDEF WINDOWS}
    434447  DLLHandle1 := LoadLibrary('secur32.dll');
    435448  if DLLHandle1 <> 0 then
     
    442455procedure FreeLibraries;
    443456begin
    444   {$IFDEF Windows}
     457  {$IFDEF WINDOWS}
    445458  if DLLHandle1 <> 0 then FreeLibrary(DLLHandle1);
    446459  {$ENDIF}
     
    475488end;
    476489
     490procedure OpenEmail(Email: string);
     491begin
     492  OpenURL('mailto:' + Email);
     493end;
     494
    477495procedure OpenFileInShell(FileName: string);
    478496begin
     
    503521end;
    504522
    505 function MergeArray(A, B: array of string): TArrayOfString;
    506 var
    507   I: Integer;
    508 begin
    509   Result := Default(TArrayOfString);
     523function MergeArray(A, B: array of string): TStringArray;
     524var
     525  I: Integer;
     526begin
     527  Result := Default(TStringArray);
    510528  SetLength(Result, Length(A) + Length(B));
    511529  for I := 0 to Length(A) - 1 do
Note: See TracChangeset for help on using the changeset viewer.