
/*****************************************************************
 * 
 * 
 The following section contains a number of user-definable macros.
 * 
 * 
 *****************************************************************/




/* Autoexec
 *
 * this is executed if new document is not open
 * from a disk file. Otherwise the macro EndOpen
 * is executed.
 */
/// CPY v4.988 5/21/97 t2247 NEW_PROJ_START_UP
/// no autoexec to allow internal default, define
/// this function to override 
//def autoexec {
//	window -T Wks;
//	/* create a new data worksheet */
//	queue (doc -saved);
//	/* turn off the ask to save flag */
//}


def NotReady {
	ty -b $General.UnderDev;
}


/* if a document is specified in the command line
 * it is open automatically, after that document
 * is open, the following macro is executed.
 *
 def EndOpen { }
 *
 */

/* before a document is deleted from memory */
/* DocEnd */
def DocEnd { } /* do nothing */


/* executed after opening a project */
/////////////////////////////////////
// this is how it is defined internally
//
//def DocAfter {
//	//type -b "macro DocAfter";
//	doc -ln; // localize notes
//}
////////////////////////////////////

/* JMP 4/3/1995 			*/
/* macro used for some toolbars	*/
def IconizeNamedWks {

	if (exist(%1)==2) 
	{
		win -o %1 {win -i};
	}
	else
	{
		win -n data %1;
		win -i;
	};
}

///RKM 4/9/99 Moved here from matrix3d.cnf (which has been removed)
/*********** workSheet (XYZ) --> matrix  ***********/
def CheckWksSelection {
	///CPY v3.85 10/24/95 RANDOM_CVT_REMOVE_MAT_LINK
	if(wks.c1!=wks.c2 || wks.c1==0 || wks.col$(wks.c2).type!=6) {
		/* type = 6 for Z column */
		type -b $General.Only1ZColumn;
		break 1;
	};
	nZCol=wks.c2;
	nYCol=%(%H,@Y-,wks.c2);
	nXCol=%(%H,@X,nYCol);
}

///////////////////////////////////////////
//
///////////////////////////////////////////
/* The macro below test whether the user
 * had selected a worksheet column
 */
def TestColSel {
	if (exist(%C)!=1 || SelC2 > SelC1)
	{	/* exist return 1 if %C is a data set name */
		type -b $general.Only1YColumn;
		break 1;
 	}
}


def FilterImport {
	GetFileName *.%1;
	open -WF %A
}

def FormatFilterImport {
	GetFileName *.%2;
	open -WE %1 %A
}

def CheckMargins {
	CheckVar Top 10;
	CheckVar Left 15;
	CheckVar Right 10;
	CheckVar Bottom 15;
	CheckVar xGap 5;
	CheckVar yGap 5;
}

/* This macro is needed in the QC chart
 * script in the QC.OTW template
 */

/* Usage 
 * QClines Ave
 * Assumption: variables UCL and LCL
 */
def QCLines {
	Ave = %1;
	OneQCLine Ave;
	OneQCLine UCL;
	OneQCLine LCL;
}

/* Usage 
 * OneQCLine Ave value
 */
def OneQCLine {
draw -Name QC.%1 -L %1;
		/* generate the Ave line
		 * QC.Ave is the name of that line
		 * %1 (assumed to be the mean) is the Y value
		 * to put that line.
		 * The -L switch generate a line which by default
		 * is horizontal.
		 */
	if(%1=="Ave")
		label -Offset 2 (-10) -Coor X2 %1 -s -n TQC.%1 (CL = $(%1,*4*));
	else
		label -Offset 2 (-10) -Coor X2 %1 -s -n TQC.%1 (%1 = $(%1,*4*));
		/* Put a label at the given
		 * X Y coordinates
		 * and name the label as TQC.name
		 * the -s switch enable string
		 * substitution for the text 
		 */
}

def GetEnumTempWks {
	/* Argument List: TemplateName WindowName */
	doc -cw %2;
	%A=%2$(count+1);	//Set %A to be the name of the new window
	win -th Wks %1 %A;
}

// Run code for automatic updates of OPK's
// SY 05-20-2004 QA70-6346 v7.5876 AUTOMATIC_OPK_UPDATES
/// EJP 06-28-2004 QA70-6346 AUTOMATIC_OPK_UPDATES, remove 'DLL -A'. OPack mapped at startup.
///dll -a opack opack.dll;
opack.checkupdates();