SHARE
TWEET

Event functions in includable files

a guest Sep 17th, 2018 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #expr RegisterProc('InitializeSetup','InitializeSetup1','',30)
  2. // InitializeSetup - unique id for this type of functions
  3. //                   it used as filter in EmitProcs
  4. // InitializeSetup1 - function name
  5. // 30 - execution order (function executed from low order to high)
  6. procedure InitializeSetup1(var Res:Boolean);
  7. begin
  8.   // do the work
  9. end;
  10.  
  11. #expr RegisterProc('InitializeSetup','InitializeSetup2','',20)
  12. procedure InitializeSetup2(var Res:Boolean);
  13. begin
  14.   // do the work
  15. end;
  16.  
  17. #expr RegisterProc('PrepareToInstall','PrepareToInstall1')
  18. //PrepareToInstall - another type of function
  19. function PrepareToInstall1(var NeedsRestart:Boolean):String;
  20. begin
  21.   Result:='error';
  22. end;
  23.  
  24. #expr RegisterProc('PrepareToInstall','PrepareToInstall2')
  25. function PrepareToInstall2(var NeedsRestart:Boolean):String;
  26. begin
  27.   Result:='';
  28. end;
  29.  
  30. function InitializeSetup: Boolean;
  31. begin
  32.   Result:=True;
  33.   #emit EmitProcs('InitializeSetup','%1(Result);')
  34.   //Emit this code:
  35.   //InitializeSetup2(Result);
  36.   //InitializeSetup1(Result);
  37. end;
  38.  
  39. function PrepareToInstall(var NeedsRestart:Boolean):String;
  40. begin
  41.   Result:=''
  42.   #emit EmitProcs('PrepareToInstall','+%1(NeedsRestart)')
  43.   //Emit this code:
  44.   //+PrepareToInstall1(NeedsRestart)
  45.   //+PrepareToInstall2(Result)
  46. end;
  47.  
  48. //Macro definitions:
  49.  
  50. #dim public _Temp[4]
  51. #sub _RegisterProc
  52.   #ifndef _Procs
  53.     #dim public _Procs[1]
  54.     #dim public _Order[1]
  55.     #dim public _Types[1]
  56.     #dim public _Param[1]
  57.     #expr Local[0]=0
  58.   #else
  59.     #redim public _Procs[DimOf(_Procs)+1]
  60.     #redim public _Order[DimOf(_Order)+1]
  61.     #redim public _Types[DimOf(_Types)+1]
  62.     #redim public _Param[DimOf(_Param)+1]
  63.     #for {Local[0]=DimOf(_Procs)-1; \
  64.       Local[0]>0&&_Temp[1]<_Order[Local[0]-1]; \
  65.       Local[0]--} \
  66.       _Procs[Local[0]]=_Procs[Local[0]-1], \
  67.       _Order[Local[0]]=_Order[Local[0]-1], \
  68.       _Types[Local[0]]=_Types[Local[0]-1], \
  69.       _Param[Local[0]]=_Param[Local[0]-1];
  70.   #endif
  71.   #expr _Procs[Local[0]]=_Temp[0]
  72.   #expr _Order[Local[0]]=_Temp[1]
  73.   #expr _Types[Local[0]]=_Temp[2]
  74.   #expr _Param[Local[0]]=_Temp[3]
  75. #endsub
  76. #define RegisterProc(str Type,str Proc,str Param='',int Order=0) \
  77.   _Temp[0]=Proc,  \
  78.   _Temp[1]=Order, \
  79.   _Temp[2]=Type,  \
  80.   _Temp[3]=Param, \
  81.   _RegisterProc
  82.  
  83. #sub _EmitProc
  84.   #if _Types[_Temp[0]]==_Temp[2]
  85.     #emit StringChange( \
  86.      StringChange(_Temp[1], \
  87.      '%1',_Procs[_Temp[0]]), \
  88.      '%2',_Param[_Temp[0]])
  89.   #endif
  90. #endsub
  91. #sub _EmitProcs
  92.   #ifdef _Procs
  93.     #for {_Temp[0]=0; \
  94.      _Temp[0]<DimOf(_Procs); \
  95.      _Temp[0]++} \
  96.      _EmitProc
  97.   #endif
  98. #endsub
  99. #define EmitProcs(str Type,str Template) \
  100.   _Temp[1]=Template, \
  101.   _Temp[2]=Type, \
  102.   _EmitProcs
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top