// Global Script Sample - Homam Bahnassi - In|Framez 2006
// This script is a sample used to invoke JScript code found in any annotation property with the "script" keyword in its name attached to the selected objects.

// Searching for Annotation properties with the "Script" keyword in its name...
oGSSSelection = Application.Selection;
for (iGSSSel=0; iGSSSel<oGSSSelection.count; iGSSSel++)
{
	oGSSProps = oGSSSelection(iGSSSel).Properties;
	for (iGSSProp=0; iGSSProp<oGSSProps.count; iGSSProp++)
	{
		bGSSSearch = oGSSProps(iGSSProp).name.search("Script");
		if (bGSSSearch == 0)
		{
			// Flag1 is used to mute the script, Check if it's muted...
			bGSSScript = GetValue(oGSSProps(iGSSProp) + ".flag1");
			if (bGSSScript == true)
				continue
			sGSSScript = GetValue(oGSSProps(iGSSProp) + ".text");
			
			// Parsing the current object name to the attached script...
			sGSSObjScript = sGSSScript.replace("sGSSObjName",oGSSSelection(iGSSSel));
			
			LogMessage ("Running Attached Script on: "+oGSSSelection(iGSSSel));
			// Executing the attached script...
			eval(sGSSObjScript);
			LogMessage ("Attached Script Completed --------------------------");
		}
	}
}
