Janilabo

Janilabo | Before() [SCAR Divi]

Apr 28th, 2013
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.65 KB | None | 0 0
  1. {==============================================================================]  
  2.   Explanation: Returns the string before s in str.                    
  3. [==============================================================================}
  4. function Before(s, str: string): string;
  5. var
  6.   p: Integer;
  7. begin
  8.   if (Length(s) < Length(str)) then
  9.   begin
  10.     p := Pos(s, str);
  11.     if (p > 1) then
  12.       Result := Copy(str, 1, (p - 1))
  13.     else
  14.       Result := '';
  15.   end else
  16.     Result := '';
  17. end;
  18.  
  19. var
  20.   str: string;
  21.  
  22. begin
  23.   ClearDebug;
  24.   str := 'Before() WORKS! Test to see if Before() works correctly.';
  25.   WriteLn(Before(' Test', str));
  26. end.
Advertisement
Add Comment
Please, Sign In to add comment