Mator

[Pascal] [xEdit] Example script executing on a file

Jul 17th, 2015
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.92 KB | None | 0 0
  1. {
  2.   Example script demonstrating how to make a new file and
  3.   execute a method on it.
  4. }
  5. unit userscript;
  6.  
  7. uses mteFunctions;
  8.  
  9. var
  10.   aPlugin: IInterface;
  11.   // if you need to use a variable in two or more of the three
  12.   // available entry points (Initialize, Process, Finalize),
  13.   // declare it globally.
  14.  
  15. // you can declare helper methods above Initialize/Process/Finalize
  16. // they are accessible to all methods below them
  17. procedure SomeMethod(var f: IInterface);
  18. var
  19.   i: integer;
  20. begin
  21.   // as a sample, we'll print out the filename
  22.   AddMessage(GetFileName(f));
  23.   // and then loop through the child elements in the file
  24.   // printing out their names
  25.   for i := 0 to ElementCount(f) - 1 do begin
  26.     AddMessage(Name(ElementByIndex(f, i)));
  27.   end;
  28. end;
  29.  
  30. function Initialize: integer;
  31. begin
  32.   aPlugin := FileSelect('Select the file you wish to use below: ');
  33.   SomeMethod(aPlugin);
  34.   Result := 0;
  35. end;
  36.  
  37. end.
Advertisement
Add Comment
Please, Sign In to add comment