Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- Hello G,
- 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.
- HTH,
- }
- PROCEDURE Paste_Reassign;
- VAR
- ClassNames :DYNARRAY[] of STRING;
- NewClassNames :DYNARRAY[] of STRING;
- ExtraClassNames :DYNARRAY[] of STRING;
- countClasses, NewcountClasses :INTEGER;
- diff, StartClass,w,y,x :INTEGER;
- index :INTEGER;
- DidCancel :BOOLEAN;
- StringMatch :BOOLEAN;
- OldClass :STRING;
- NewClass :STRING;
- VerifyValuesAFTER :STRING;
- VerifyValuesBEFORE :STRING;
- PROCEDURE Populate_Array1;
- VAR
- x :INTEGER;
- y :INTEGER;
- w :INTEGER;
- BEGIN
- countClasses:=CLASSNUM;
- ALLOCATE ClassNames [1..countClasses];
- FOR x:= 1 TO countClasses DO BEGIN
- y:=x;
- CLassnames[y] := ClassList(x);
- END;
- END;
- PROCEDURE Populate_Array2;
- VAR
- x :INTEGER;
- y :INTEGER;
- w :INTEGER;
- BEGIN
- ALLOCATE NewClassNames [1..NewcountClasses];
- FOR x:= 1 TO NewcountClasses DO BEGIN
- y:=x;
- NewClassNames[y] := ClassList(x);
- END;
- END;
- PROCEDURE Populate_Array_Extra;
- VAR
- x :INTEGER;
- y :INTEGER;
- w :INTEGER;
- BEGIN
- diff:=(NewcountClasses - countClasses);
- StartClass:=(NewcountClasses - diff)+1;
- ALLOCATE ExtraClassNames [1..diff];
- y:=1;
- FOR x:=(StartClass) TO (NewcountClasses) DO BEGIN
- IF y<=diff THEN BEGIN
- ExtraClassNames[y] := NewClassNames[x];
- y:=y+1;
- END;
- END;
- VerifyValuesBEFORE := 'Macintosh HD:VerifyValuesBEFORE.txt';
- Append(VerifyValuesBEFORE);
- WRITE(diff);
- WRITELN(' New classes are being copied');
- WRITE('The Index of the first new class is: ');
- WRITELN(StartClass);
- WRITE('The Index of the last class is: ');
- WRITELN(Newcountclasses);
- FOR w:=1 TO NewcountClasses DO BEGIN
- WRITE('The Class Name of index: ');
- WRITE(w);
- WRITE(' is: ');
- WRITELN(NewClassNames[w]);
- END;
- close (VerifyValuesBEFORE);
- END;
- PROCEDURE AutomaticDlog;
- CONST
- kDlgID=1;
- kItem1bName='Ok';
- kItem2bName='Cancel';
- kItem3fName='Assign this Class:';
- kItem5fName='To this:';
- kItem4cName='OldClassPop';
- kItem6cName='NewClassPop';
- Procedure SetupDialog;
- Var
- i:INTEGER;
- major, minor, maint, platform:INTEGER;
- Begin
- GetVersion(major, minor, maint, platform);
- BeginDialog(kDlgID, 1, 0, 0,300,320);
- if (platform = 1) then
- begin { macintosh }
- AddButton(kItem1bName,1,1,200,280,285,320);
- AddButton(kItem2bName,2,1,105,280,185,320);
- end
- else { windows }
- begin
- AddButton(kItem1bName,1,1,200,280,285,320);
- AddButton(kItem2bName,2,1,105,280,185,320);
- end;
- AddField(kItem3fName,3,1,12,12,188,28);
- AddField(kItem5fName,5,1,12,67,188,83);
- {
- AddChoiceItem(kItem4cName,4,1,12,37,283,57);
- }
- AddField('',4,1,12,37,283,57);
- AddChoiceItem(kItem6cName,6,1,12,92,283,112);
- EndDialog;
- End; {of SetupDialog}
- Procedure HandleDialog;
- Var
- i, item, Count :INTEGER;
- done, canceled :BOOLEAN;
- error :BOOLEAN;
- Begin
- GetDialog(kDlgID);
- {
- FOR Count := 1 TO diff
- DO BEGIN
- InsertChoice(4,Count, ExtraClassNames[Count]);
- END;
- }
- SetField(4, ExtraClassNames[index]);
- FOR Count := 1 TO countClasses
- DO BEGIN
- InsertChoice(6,Count, ClassNames[Count]);
- END;
- SetTitle('Class Reassign-Delete');
- error := false;
- canceled := false;
- done := false;
- while (not canceled) and (not done) do
- begin
- DialogEvent(item);
- Case item OF
- 1: if (not error) then
- done:= true
- else Sysbeep;
- 2: canceled:= true;
- end; {of case}
- end;
- if (done) then
- begin
- { this would be a good place to retrieve the data }
- DidCancel := canceled;
- {
- GetSelChoice(4, 0, i, NewClass);
- }
- NewClass := GetField(4);
- GetSelChoice(6, 0, i, OldClass);
- end;
- ClrDialog;
- if (canceled) Then
- Begin
- DidCancel := canceled;
- DoMenuTextByName('Undo',0);
- End;
- End; {of HandleDialog}
- BEGIN {of AutomaticDlog}
- SetupDialog;
- HandleDialog;
- END;
- PROCEDURE reassignclass(h:handle);
- BEGIN
- IF GetClass(h) = Newclass THEN SetClass(h, Oldclass);
- END;
- BEGIN {of Paste_Reassign}
- Populate_Array1;
- DoMenuTextByName('Paste',0);
- NewcountClasses:=CLASSNUM;
- IF (NewcountClasses=countClasses) THEN BEGIN
- Message('No New Classes Pasted');
- END ELSE BEGIN
- Populate_Array2;
- Populate_Array_Extra;
- index := 1;
- AlrtDialog( Concat( countClasses ) );
- WHILE NOT ( index > diff ) DO BEGIN
- AutomaticDlog;
- IF NOT DidCancel
- THEN BEGIN
- foreachobject(reassignclass,InSymbol);
- DelClass(NewClass);
- index := index + 1;
- {
- ALLOCATE ExtraClassNames [index..diff];
- }
- AlrtDialog( Concat( countClasses ) );
- END;
- END;
- END;
- END;
- RUN(Paste_Reassign);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement