Advertisement
Guest User

Justin Wright

a guest
Feb 1st, 2010
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.33 KB | None | 0 0
  1. {This script will take all symbols in a file and convert them into a PROCEDURE for use in scripts}
  2. {Edit text at line 215 to adjust the procedure name}
  3. {Edit text at line 215 to adjust the procedure name}
  4. {Orginally written by Justin Wright, Assembly Architecture Ltd. Jan 2009, VW2009}
  5. {If you use this script I ask you share one of your own, open source helps all}
  6. {Cut and paste the pop up list into a pop up of a PIO, The pop up will select which symbol to draw}
  7. {The PROCEDURE PlatformFileName you can alter the exported text file name and location}
  8.  
  9.  
  10.  
  11. PROCEDURE StirpGeometery;
  12.  
  13. VAR
  14. PrefixString: String;
  15. CurrentLetter: string;
  16. ProcedureNameToCreate: String;
  17. TempString: STRING;
  18.  
  19. fileName,FileNameWrite :STRING;
  20. major, minor, maintenance, platform :INTEGER;
  21. hRecord:handle;
  22. result: Boolean;
  23. LnToStart: Array[1..10000] Of Integer;
  24. LnToStop: Array[1..10000] Of Integer;
  25. FileText: Array[1..10000] of String;
  26.  
  27. PopName: Array[1..100] of String;
  28. WriteVar: Array[1..100] of String;
  29. WriteBody: Array[1..100] of String;
  30.  
  31. TellMeMessage:String;
  32. iTemp:Integer;
  33. i,p: Integer;
  34. j: Integer;
  35. n,m,v,b: Integer;
  36.  
  37. LnCount: Integer;
  38. Endclip: Integer;
  39. SybStartCheck:STRING;
  40. SybEndCheck:STRING;
  41. LnStart,LnStop:Integer;
  42. ProcedureName:STRING;
  43.  
  44.  
  45.  
  46.  
  47. Procedure PlatformFileName;
  48. BEGIN
  49. GetVersion(major, minor, maintenance, platform);
  50. IF platform = 1 THEN
  51. BEGIN
  52. fileName := '/StripSyb.txt';
  53. FileNameWrite:='/StripSybConvert.txt'
  54. END
  55. ELSE
  56. BEGIN
  57. fileName := 'C:\StripSyb.txt';
  58. FileNameWrite:='/StripSybConvert.txt'
  59. END;
  60. END;
  61.  
  62. Procedure OpenAndRead;
  63. Begin;
  64. Open(FileName);
  65. For i:= 1 TO 10000 DO
  66. Read(FileText[i]);
  67. Close(FileName);
  68. Rewrite(FileNameWrite);
  69. End;
  70.  
  71.  
  72.  
  73. PROCEDURE CheckForFunctionsAndDelete;
  74. {By including some of these functions you can strip out a lot of lines included in the symbol}
  75. {Include all and you get down to simple polylines.}
  76. Begin;
  77. For i:=1 to 10000 DO
  78. Begin;
  79. TempString:=Copy(FileText[i],1,3);
  80. { IF TempString='Fil' THEN FileText[i]:='';}
  81. { IF TempString='Set' THEN FileText[i]:='';}
  82. { IF TempString='Pen' THEN FileText[i]:='';}
  83. { IF TempString='Nam' THEN FileText[i]:='';}
  84. { IF TempString='FPa' THEN FileText[i]:='';}
  85. { IF TempString='LSB' THEN FileText[i]:='';}
  86. { IF TempString='LWB' THEN FileText[i]:='';}
  87. { IF TempString='Mar' THEN FileText[i]:='';}
  88. { IF TempString='Opa' THEN FileText[i]:='';}
  89. { IF TempString='Fie' THEN FileText[i]:='';}
  90. { IF TempString='obj' THEN FileText[i]:='';}
  91. IF TempString='boo' THEN FileText[i]:='';
  92. End;
  93. End;
  94.  
  95. PROCEDURE WriteProcedureName;
  96. Begin;
  97. WriteLn('PROCEDURE ',ProcedureNameToCreate,Chr(59));
  98. WriteLn('');
  99. END;
  100.  
  101. PROCEDURE WriteProcedureBegin;
  102. Begin;
  103. WriteLn('{---------Main Body Starts------------}');
  104. WriteLn('BEGIN',CHR(59));
  105. WriteLn('ProfileSelect',CHR(59));
  106. END;
  107.  
  108. PROCEDURE WriteProcedureEnds;
  109. Begin;
  110. WriteLn('End',Chr(59));
  111. WriteLn('');
  112. WriteLn('Run(',ProcedureNameToCreate,')',Chr(59));
  113. END;
  114.  
  115. Procedure WritePopUpNames;
  116. Begin;
  117. iTemp:=n;
  118. WriteLn('{PopNames');
  119. For n:= 1 to iTemp DO
  120. WriteLn(PopName[n]);
  121. WriteLn('PopNames List Ends}');
  122. End;
  123.  
  124. PROCEDURE WriteProfileSelect;
  125. Begin;
  126. WriteLn('PROCEDURE ProfileSelect',Chr(59));
  127. WriteLn('BEGIN',Chr(59));
  128. For n:= 1 to iTemp DO
  129. WriteLn(Concat('IF ', 'pSelect=',CHr(39),PopName[n],CHr(39),' THEN ', Popname[n],Chr(59)));
  130. WriteLn('END',Chr(59));
  131. End;
  132.  
  133.  
  134. Function RemoveBungChr(Checkthis:String):String;
  135. Begin;
  136. TempString:='';
  137. iTemp:=Len(Checkthis);
  138. For m:=1 to iTemp DO
  139. BEGIN;
  140. CurrentLetter:=Copy(Checkthis,m,1);
  141. For p:=32 to 47 Do IF CurrentLetter=Chr(p) Then CurrentLetter:='';
  142.  
  143. TempString:=Concat(TempString,CurrentLetter);
  144. ENd;
  145. RemoveBungChr:=TempString;
  146. End;
  147.  
  148. Procedure ConvertSyb2Procedure;
  149. Begin;
  150. For i:=1 to 10000 DO
  151. BEGIN;
  152. SybStartCheck:=Copy(FileText[i],1,8);
  153. IF SybStartCheck='BeginSym' THEN
  154. BEGIN;
  155. ProcedureName:=Copy(FileText[i],11,Len(FileText[i])-13);
  156. ProcedureName:=RemoveBungChr(ProcedureName);
  157. ProcedureName:=Concat('PROCEDURE ',PrefixString,ProcedureName,CHR(59),CHR(13),
  158. 'BEGIN',CHR(59));
  159. {Copy takes out the procedure name of the symbol deffinition line.
  160. 11= the Char length of BeginSym('
  161. 13= the Char Length of BeginSym(' AND ');}
  162. {ProcedureName:=RemoveBungChr(ProcedureName);}
  163. n:=n+1;
  164. LnToStart[n]:=i;
  165. PopName[N]:=Concat(PrefixString,Copy(FileText[i],11,Len(FileText[i])-13));
  166. PopName[N]:=RemoveBungChr(PopName[N]);
  167.  
  168.  
  169. FileText[i]:=ProcedureName;
  170.  
  171.  
  172. END;
  173.  
  174. SybEndCheck:=Copy(FileText[i],1,6);
  175. IF SybEndCheck='EndSym' THEN
  176. BEGIN;
  177. FileText[i]:=Concat('END',CHR(59));
  178. LnToStop[n]:=i;
  179. END;
  180. END;
  181. itemp:=n;
  182. Message(n);
  183. For n:= 1 to iTemp DO
  184. BEGIN;
  185. WriteLn('');
  186. For i:= LntoStart[n] to LnToStop[n] DO IF FileText[i]<> '' THEN WriteLn(FileText[i]);
  187. WriteLn('');
  188. END;
  189.  
  190. End;
  191.  
  192. Procedure SetPopFields;
  193. Begin;
  194. WriteVar[v]:=Concat('bTemp:Boolean',CHR(59)); v:=v+1;
  195. WriteVar[v]:=Concat('ObjectName:String',CHR(59)); v:=v+1;
  196. WriteVar[v]:=Concat('ObjectHandit,RecordHand,WallHand:Handle,',CHR(59)); v:=v+1;
  197.  
  198. WriteBody[b]:=Concat('bTemp:=GetCustomObjectInfo(ObjectName,ObjectHand,RecordHand,WallHand)');b:=b+1;
  199.  
  200. For n:= 1 to iTemp DO
  201. Begin;
  202. WriteBody[b]:=Concat('SetRField(ObjectHand,RecordHand, ',Chr(39),'Select',Chr(39),',',Chr(39),PopName[v],Chr(39),')');
  203. b:=b+1;
  204. End;
  205. End;
  206.  
  207. Procedure WriteBodyFull;
  208. Begin;
  209. iTemp:=b;
  210. For b:=1 to iTemp Do WriteLn(WriteBody[b],Chr(59));
  211. End;
  212.  
  213. Procedure WriteVariables;
  214. Begin;
  215. Writeln('VAR');
  216. WriteLn('');
  217. WriteLn('bTemp:Boolean',CHR(59)); v:=v+1;
  218. WriteLn('ObjectName:String',CHR(59)); v:=v+1;
  219. WriteLn('ObjectHand,RecordHand,WallHand:Handle',CHR(59)); v:=v+1;
  220. End;
  221.  
  222.  
  223. Begin;
  224. ProcedureNameToCreate:='Sybol2Object';
  225. PlatformFileName;
  226. OpenAndRead;
  227.  
  228. CheckForFunctionsAndDelete;
  229.  
  230. WriteProcedureName;
  231. PrefixString:='JD';
  232. WriteVariables;
  233.  
  234. ConvertSyb2Procedure;
  235. WritePopUpNames;
  236.  
  237. WriteProfileSelect;
  238.  
  239.  
  240.  
  241.  
  242. WriteProcedureBegin;
  243.  
  244. WriteProcedureEnds;
  245. Close(FileNameWrite);
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252. END;
  253.  
  254. Run(StirpGeometery);
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement