Advertisement
Guest User

Matt Panzer

a guest
Jan 27th, 2010
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 5.86 KB | None | 0 0
  1. {
  2. Hello G,
  3.  
  4. I reworked it a bit and it's working.  While I didn't examine the entire script, I simplified parts of it.  Part of the simplifying was to not use a popup for the class to reassign.  At this point, the script requires the user to reassign all of the new classes anyway, so now they just have to do them in order.  So the dialog now shows the new (offending) class as static text.  This makes it easy to simply cycle through the new classes without dealing with reallocating the array.  There were a couple of other fixes.  If you have a text editor that can compare this with yours, you'll see what was changed.
  5.  
  6. HTH,
  7. }
  8.  
  9. PROCEDURE Paste_Reassign;
  10.  
  11.  
  12.  
  13. VAR
  14.    
  15.     ClassNames      :DYNARRAY[] of STRING;
  16.     NewClassNames   :DYNARRAY[] of STRING;
  17.     ExtraClassNames :DYNARRAY[] of STRING;
  18.    
  19.     countClasses, NewcountClasses   :INTEGER;
  20.     diff, StartClass,w,y,x          :INTEGER;
  21.     index                           :INTEGER;
  22.    
  23.     DidCancel   :BOOLEAN;
  24.     StringMatch  :BOOLEAN;
  25.    
  26.     OldClass            :STRING;
  27.     NewClass            :STRING;
  28.     VerifyValuesAFTER       :STRING;
  29.     VerifyValuesBEFORE      :STRING;
  30.    
  31.     PROCEDURE Populate_Array1;
  32.     VAR
  33.         x   :INTEGER;
  34.         y   :INTEGER;
  35.         w   :INTEGER;
  36.        
  37.         BEGIN
  38.             countClasses:=CLASSNUM;
  39.             ALLOCATE ClassNames [1..countClasses];
  40.  
  41.                 FOR x:= 1 TO countClasses DO BEGIN
  42.                     y:=x;
  43.                     CLassnames[y] := ClassList(x);                  
  44.                 END;
  45.         END;
  46.        
  47.     PROCEDURE Populate_Array2; 
  48.     VAR
  49.                 x   :INTEGER;
  50.                 y   :INTEGER;
  51.                 w   :INTEGER;
  52.     BEGIN
  53.                    
  54.                     ALLOCATE NewClassNames [1..NewcountClasses];
  55.                    
  56.                         FOR x:= 1 TO NewcountClasses DO BEGIN
  57.                             y:=x;
  58.                             NewClassNames[y] := ClassList(x);  
  59.                         END;       
  60.     END;
  61.        
  62.    
  63.     PROCEDURE Populate_Array_Extra;
  64.     VAR
  65.         x   :INTEGER;
  66.         y   :INTEGER;
  67.         w   :INTEGER;
  68.        
  69.         BEGIN
  70.            
  71.             diff:=(NewcountClasses - countClasses);
  72.             StartClass:=(NewcountClasses - diff)+1;
  73.            
  74.             ALLOCATE ExtraClassNames [1..diff];    
  75.                        
  76.                    
  77.             y:=1;          
  78.                 FOR x:=(StartClass) TO (NewcountClasses) DO BEGIN
  79.                     IF  y<=diff THEN BEGIN
  80.                     ExtraClassNames[y] := NewClassNames[x];                    
  81.                     y:=y+1;
  82.                 END;
  83.                 END;
  84.                    
  85.             VerifyValuesBEFORE := 'Macintosh HD:VerifyValuesBEFORE.txt';
  86.             Append(VerifyValuesBEFORE);
  87.             WRITE(diff);  
  88.             WRITELN(' New classes are being copied');
  89.             WRITE('The Index of the first new class is: ');
  90.             WRITELN(StartClass);
  91.             WRITE('The Index of the last class is: ');
  92.             WRITELN(Newcountclasses);
  93.                 FOR w:=1 TO NewcountClasses DO BEGIN
  94.                         WRITE('The Class Name of index: ');
  95.                         WRITE(w);
  96.                         WRITE(' is: ');
  97.                         WRITELN(NewClassNames[w]);
  98.                 END;
  99.             close (VerifyValuesBEFORE);
  100.     END;
  101.  
  102.  
  103.    
  104.  
  105.  
  106.  
  107.     PROCEDURE AutomaticDlog;
  108.        
  109.     CONST
  110.    
  111.         kDlgID=1;
  112.         kItem1bName='Ok';
  113.         kItem2bName='Cancel';
  114.         kItem3fName='Assign this Class:';
  115.         kItem5fName='To this:';
  116.         kItem4cName='OldClassPop';
  117.         kItem6cName='NewClassPop';
  118.    
  119.         Procedure SetupDialog;
  120.         Var
  121.             i:INTEGER;
  122.             major, minor, maint, platform:INTEGER;
  123.         Begin
  124.             GetVersion(major, minor, maint, platform);
  125.             BeginDialog(kDlgID, 1, 0, 0,300,320);
  126.                 if (platform = 1) then
  127.                 begin { macintosh }
  128.                     AddButton(kItem1bName,1,1,200,280,285,320);
  129.                     AddButton(kItem2bName,2,1,105,280,185,320);
  130.                 end
  131.                 else { windows }
  132.                 begin
  133.                     AddButton(kItem1bName,1,1,200,280,285,320);
  134.                     AddButton(kItem2bName,2,1,105,280,185,320);
  135.                 end;
  136.                 AddField(kItem3fName,3,1,12,12,188,28);
  137.                 AddField(kItem5fName,5,1,12,67,188,83);
  138.                 {
  139.                 AddChoiceItem(kItem4cName,4,1,12,37,283,57);
  140.                 }
  141.                 AddField('',4,1,12,37,283,57);
  142.                 AddChoiceItem(kItem6cName,6,1,12,92,283,112);
  143.            EndDialog;
  144.         End; {of SetupDialog}
  145.    
  146.     Procedure HandleDialog;
  147.         Var
  148.             i, item, Count      :INTEGER;
  149.             done, canceled  :BOOLEAN;
  150.             error           :BOOLEAN;
  151.  
  152.         Begin
  153.             GetDialog(kDlgID);
  154.             {
  155.             FOR Count := 1 TO diff
  156.             DO BEGIN
  157.                 InsertChoice(4,Count, ExtraClassNames[Count]);
  158.             END;
  159. }
  160.            
  161.             SetField(4, ExtraClassNames[index]);
  162.            
  163.             FOR Count := 1 TO countClasses
  164.             DO BEGIN
  165.                 InsertChoice(6,Count, ClassNames[Count]);
  166.             END;
  167.            
  168.             SetTitle('Class Reassign-Delete');
  169.             error := false;
  170.             canceled := false;
  171.             done := false;
  172.             while (not canceled) and (not done) do
  173.             begin
  174.                 DialogEvent(item);
  175.                 Case item OF
  176.                     1: if (not error) then
  177.                             done:= true
  178.                        else Sysbeep;
  179.                     2: canceled:= true;
  180.                 end; {of case}
  181.  
  182.             end;
  183.             if (done) then
  184.             begin
  185.                 { this would be a good place to retrieve the data     }
  186.                 DidCancel := canceled;
  187.                 {
  188.                 GetSelChoice(4, 0, i, NewClass);
  189.                 }
  190.                 NewClass := GetField(4);
  191.                 GetSelChoice(6, 0, i, OldClass);
  192.             end;
  193.             ClrDialog;
  194.            
  195.             if (canceled) Then
  196.             Begin
  197.                 DidCancel := canceled;
  198.                 DoMenuTextByName('Undo',0);
  199.             End;
  200.        
  201.         End; {of HandleDialog}
  202.     BEGIN    {of AutomaticDlog}
  203.         SetupDialog;
  204.         HandleDialog;
  205.     END;
  206.  
  207.  
  208.     PROCEDURE reassignclass(h:handle);
  209.         BEGIN
  210.         IF GetClass(h) = Newclass THEN SetClass(h, Oldclass);
  211.     END;  
  212.    
  213. BEGIN  {of Paste_Reassign}
  214.        
  215.         Populate_Array1;
  216.         DoMenuTextByName('Paste',0);
  217.         NewcountClasses:=CLASSNUM;
  218.         IF (NewcountClasses=countClasses) THEN BEGIN
  219.        
  220.             Message('No New Classes Pasted');
  221.             END ELSE BEGIN
  222.            
  223.             Populate_Array2;
  224.             Populate_Array_Extra;
  225.            
  226.             index := 1;
  227.            
  228.             AlrtDialog( Concat( countClasses ) );
  229.            
  230.             WHILE NOT ( index > diff ) DO BEGIN
  231.                 AutomaticDlog;
  232.                        
  233.                 IF NOT DidCancel
  234.                     THEN BEGIN
  235.                     foreachobject(reassignclass,InSymbol);
  236.                     DelClass(NewClass);
  237.                     index := index + 1;
  238.                     {
  239.                     ALLOCATE ExtraClassNames [index..diff];
  240.                     }
  241.                     AlrtDialog( Concat( countClasses ) );
  242.                    
  243.                     END;
  244.             END;
  245.         END;
  246. END;               
  247. RUN(Paste_Reassign);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement