AppendStrToVisibleClasses

From Vectorlab
Jump to: navigation, search


This Procedure appends all visible classes with a user provided string. It does not modify the standard classes None or Dimension. It displays the total number of renamed classes or beeps if it fails. By Frank Brault.


Procedure AppendStrToVisibleClasses;
{
©2006, VectorExpress,Inc.
Developed by Frank Brault
Last modified: 05/20/06

This Procedure appends all visible classes with a user provided string.
It does not modify the standard classes None or Dimension.
It displays the total number of renamed classes or beeps if it fails.
}
VAR
	numberOfclassesLInt, classIndexLInt, counterLInt : LongInt;
	classNameStr, prefixStr : String;

Begin
	prefixStr := StrDialog('This command will append the string entered below to the beginning of the name of each visible class. Does not rename standard classes: None or Dimension.', 'Import-');
	If Not(DidCancel) Then
	Begin
		numberofclassesLInt := ClassNum;
		counterLInt := 0;
	{** Index of class None is 1 and index of class Dimension is 2, so start at 3.}
		For classIndexLInt := 3 To numberofclassesLInt Do
		Begin
			classNameStr := ClassList(classIndexLInt);
		{** This conditional determines if the class loaded into classNameStr is visible.} 
			If (GetCVis(classNameStr) = 0) Then
			Begin
				RenameClass(classNameStr, Concat(prefixStr, classNameStr));
				counterLInt := counterLInt + 1;
			End;
		End;
	End;
	If counterLInt > 0 Then AlrtDialog(Concat(counterLInt, ' classes renamed.')) Else Sysbeep;
End;
Run(AppendStrToVisibleClasses);