Advertisement
TLama

Untitled

Nov 5th, 2013
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.44 KB | None | 0 0
  1. function GetMainConjunction(const Expression: string): string;
  2. var
  3.   P: PChar;
  4.   BraceCnt: Integer;
  5. begin
  6.   Result := '';
  7.   BraceCnt := 0;
  8.   P := PChar(Expression);
  9.  
  10.   while P^ <> #0 do
  11.   begin
  12.     case P^ of
  13.       '(': Inc(BraceCnt);
  14.       ')': Dec(BraceCnt);
  15.     end;
  16.     Inc(P);
  17.  
  18.     if BraceCnt = 0 then
  19.     begin
  20.       while (P^ = ' ') do
  21.         Inc(P);
  22.       SetString(Result, P, 2);
  23.       Exit;
  24.     end;
  25.   end;
  26. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement