Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PROCEDURE Smart_Paste;
- VAR
- ClassNames :DYNARRAY[] of STRING;
- NewClassNames :DYNARRAY[] of STRING;
- ExtraClassNames :DYNARRAY[] of STRING;
- countClasses, NewcountClasses :INTEGER;
- diff, StartClass :INTEGER;
- DidCancel :BOOLEAN;
- OldClass :STRING;
- NewClass :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;
- END;
- PROCEDURE AutomaticDlog;
- CONST
- { note: the constants are of this format: kItem[1,2,3...n][b,f,c,g]Name }
- { [1,2,3...n] is a number from 1 up to the maximum # of items allowed }
- { [b, f, c, g] indicates if it is a button (b), field (f), choice }
- { item (c), or group box (g). )
- { For example, a button with an ID of 3 would be kItem3bName, whereas }
- { a field with an ID of 13 would be kItem13fName. }
- 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);
- AddChoiceItem(kItem6cName,6,1,12,92,283,112);
- EndDialog;
- End; {of SetupDialog}
- Procedure HandleDialog;
- Var
- item, Count :INTEGER;
- done, canceled :BOOLEAN;
- error :BOOLEAN;
- Begin
- GetDialog(kDlgID);
- FOR Count := 1 TO diff
- DO BEGIN
- InsertChoice(4,Count, ExtraClassNames[Count]);
- END;
- 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, NewcountClasses, NewClass);
- GetSelChoice(6, 0, countClasses, 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;
- AutomaticDlog;
- IF NOT DidCancel
- THEN BEGIN
- foreachobject(reassignclass,InSymbol);
- DelClass(NewClass);
- END;
- END;
- END;
- RUN(Smart_Paste);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement