Gernash

Prefix/Suffix

Feb 3rd, 2017
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. {
  2. This script will prepend or append supplied value to the EditorID field
  3. of every selected record.
  4. }
  5. unit UserScript;
  6.  
  7. var
  8. DoPrepend: boolean;
  9. s: string;
  10.  
  11. function Initialize: integer;
  12. var
  13. i: integer;
  14. begin
  15. Result := 0;
  16. // ask for prefix or suffix mode
  17. i := MessageDlg('Prepend [YES] or append [NO] to Editor ID?', mtConfirmation, [mbYes, mbNo, mbCancel], 0);
  18. if i = mrYes then DoPrepend := true else
  19. if i = mrNo then DoPrepend := false else begin
  20. Result := 1;
  21. Exit;
  22. end;
  23. // ask for string
  24. if not InputQuery('Enter', 'Prefix/suffix', s) then begin
  25. Result := 2;
  26. Exit;
  27. end;
  28. // empty string - do nothing
  29. if s = '' then
  30. Result := 3;
  31. end;
  32.  
  33. function Process(e: IInterface): integer;
  34. var
  35. elEditorID: IInterface;
  36. begin
  37. Result := 0;
  38. //AddMessage('Processing: ' + Name(e));
  39. elEditorID := ElementByName(e, 'FULL - Name');
  40. if Assigned(elEditorID) then begin
  41. if DoPrepend then
  42. SetEditValue(elEditorID, s + GetEditValue(elEditorID))
  43. else
  44. SetEditValue(elEditorID, GetEditValue(elEditorID) + s);
  45. end;
  46.  
  47. end;
  48.  
  49. end.
Advertisement
Add Comment
Please, Sign In to add comment