// Filename:	Origin.ogs
// Creation:	by CP Yang, 8/14/95
// Purpose:	Basic Origin internal scripts
/// ML 9/14/2009 QA70-3313 CONTINUOUS_DATAPOINT_REMOVAL

//////////////////////////////////////////////////////////////////////
//
// GetPts: backward compatible scripts
//
///////////////////////////////////////////////////////////////////////
[GetPtsOldNames]
	// for backward compatible names
	getpts.xData$=_xpos;
	getpts.indexData$=_indx;
	///

[GetPtsMakeData]
///////////////////////////////////
// %B will be modified by this section
//////////////////////////////////

	// create the appropriate dataset
	%B=getpts.indexData$;
	if(exist(%B)==0) 
		create %B -temp getpts.max;
	%B=getpts.xData$;
	if(exist(%B)==0) 
		create %B -temp getpts.max;
	 	

[GetPtsNoDraw]
///////////////////////////////////
// %B will be modified by this section
//////////////////////////////////	

	//first set up all names with backward compatible considerations
	run.section(,GetPtsOldNames);
	getpts.data$=%C;
	run.section(,GetPtsMakeData);

	def PointProc
	{
		#!type click;
		%B=getpts.xData$;
		%B[getpts.count]=x;
		%B=getpts.indexData$;
		%B[getpts.count]=index;
		if (getpts.count>=getpts.max)
		{
			#!type end toolbox;
			{EndToolbox};
			doTool 0;
		}
		else 
			doTool -next;
	};
	
/// ML 9/14/2009 QA70-3313 CONTINUOUS_DATAPOINT_REMOVAL
[GetPtsNoDrawContinue]
///////////////////////////////////
// %B will be modified by this section
//	Like to [GetPtsNoDraw], except that doTool 0 is not called. 
//////////////////////////////////	

	//first set up all names with backward compatible considerations
	run.section(,GetPtsOldNames);
	getpts.data$=%C;
	run.section(,GetPtsMakeData);

	def PointProc
	{
		#!type click;
		%B=getpts.xData$;
		%B[getpts.count]=x;
		%B=getpts.indexData$;
		%B[getpts.count]=index;
		if (getpts.count>=getpts.max)
		{
			#!type end toolbox;
			{EndToolbox};
		}
		else 
			doTool -next;
	};
/// end CONTINUOUS_DATAPOINT_REMOVAL
 

[GetPtsDraw]
///////////////////////////////////
// %B will be modified by this section
//////////////////////////////////	

	run.section(,GetPtsOldNames);
	run.section(,GetPtsMakeData);

	def PointProc
	{
		%B=getpts.data$;
		/// RVD 10/16/2007 QA70-4022 v8.0726 UNDO_DRAW_DATA_POINT
		//plot -n %B x y;
		plot -nu %B x y;
		/// end UNDO_DRAW_DATA_POINT
		if (getpts.count >= getpts.max)
		{
			{EndToolbox};
			doTool 0;
		}
		else
			doTool -next;
	};

//////////////////////////////////////////////////////
//                                          
// UserTool, this used to be a macro in v3.x versions
//
//////////////////////////////////////////////////////
[UserTool]
	doTool 0;/* return to the PointerTool first */
	create.wksName$="Draw";
	create.wksLabel$="";
	create.enumwks=1;		//Enumerate wks; create a new one each time the Usertool is used
	create.template$="CREATE";
	create.npts=50;				
	create.enumerate=0;
	create.numtypes=2;			
	create.type1=4;				//Only explicitly specify 1st type as X
	create.type2=1;				//Set TypeN=Y column type
	create.wks(A B);
	%A=create.wksName$;
	%A!wks.labels();
	%A!wks.colwidth=8;

	%A=create.data1$;			//X data (Series)
	%B=create.data2$;			//Y data (Values)
	
	layer -ix202 %B;	 //RB 5/25/99 t6499 KEEP_SAME_X_AXIS_TICK_LABEL_TYPE
	//set %B -m 1;				//Set data as movable
	set %B -m0 1;				// ML 3/20/2002 QA70-1174 NO_FRAME_DRAWING_BUFFER_REMOVAL_FOR_DRAW_DATA_TOOL Set data as movable without dataset update
	getpts -new %B 50
	(Double-click to add new pt,click any tool to quit);
	%B=create.data2$;/// YuI 1/22/02 
	//set %B -tb 3;
	set %B -tb0 3;				// ML 3/20/2002 QA70-1174 NO_FRAME_DRAWING_BUFFER_REMOVAL_FOR_DRAW_DATA_TOOL Set data as no object buffer without dataset update
	def QuitToolBox
	{
		%B=create.wksname$;
		if(getpts.count == 0) win -o %B {page.closebits=2;win -ca;} //Remove Draw worksheet if no points were drawn
		%B=create.data2$;/// YuI 1/22/02 
		set %B -tb 0;
	};
	return 0;
	
	
//////////////////////////////////////////////////////
//                                          
// ImportAskSkip: During spreadsheet import, ask
// user to skip x number of lines
//
//////////////////////////////////////////////////////
[ImportAskSkip]
	Getn -s $EXEmessage.SkipLine x;
	return 0;
	/// x is set internally in Origin to contain the number
	/// of lines the import routine determins. When this 
	/// commend is finished, Origin get from x the user
	/// sepcified values to skip

	
[SetWksLabel]
////////////////////////////////////////////////////////////////////////////////
// Set a label for a particulat dataset
// Agument List: Dataset, Label Text
////////////////////////////////////////////////////////////////////////////////

	win -o %[%1,'_'] 
	{
		wks.col=colnum(%1);		//Use full dataset name in case of Excel Workbook with multisheets
		wks.col.label$=%2;		//Do not use quotes around 2nd argument, incase we are using OMG Label
	}
	return 0;


[DocEnd]
////////////////////////////////////////////////////////////////////////////////
// Define DocEnd macro to run this section.  Can be used by developers of tools
// or applications to unload Dialog Builder DLLs when a new project file is opened. 
////////////////////////////////////////////////////////////////////////////////

	// Developers of tools/applications add code here
	
	// GJL 9/5/01: Close all dialogs in OStat.DLL
	dialog.unload(OStat.DLL); 	
	
	return 0;
	
	
///Sophy 3/29/2010 QA80-15245 CONTEXT_MENU_GO_TO_ORIGINAL_FOLDER_FOR_SHORTCUT_WIN	
[GoOriginal]
	
	pesp_gotofolder();
	
///end CONTEXT_MENU_GO_TO_ORIGINAL_FOLDER_FOR_SHORTCUT_WIN
	
	