[MAIN]
// Entry point for Menu and Tool
if(run.section(, Init) == 0)
{
	if(run.section(,GetFile) == 0)
	{
		run.section(,Import);
	}
}


[GetFile]
// Let the user pick a file
run.section(file,init);
FDLOG.UseGroup(MiniTab);
FDLOG.Message$="";
FDLOG.DlgName$=$OMRDMNTB.Shell.Dialog;
if (FDLOG.open(A)==0/0) return 1;
FDLOG.DlgName$="";
return 0;


[Import]
%M=%A;
nn=system.path.findtemp(L,mini,*.min);
%B=%Lmini\;
cdf.inputfilename$=%A;
cdf.outputpath$=%B;
cdf.outputbasefilename$=TEMP;
cdf.outputfileext$=min;
mntbwkscount=cdf.extractstreams(Worksheet);
for(ii=1;ii<=mntbwkscount;ii++) {
	%A=cdf.outputfilenames$(ii)$;
	if(readminitab(%A,%H)) type %M;
	page.label$=%M;
	page.title=3;
	if(ii!=mntbwkscount) win -t data origin;
}
return 0;


[Init]
dll -a cdf odcfl;
if(run.LoadOC("OriginLab\minitab.ocw",4))	
{
	type -b $OMRDMNTB.Errors.Load;
	return 1;
}
return 0;


[OnDrop]
// Entry point for Drag-and-Drop (if enabled in DOFILE.OGS)
if(run.section(, Init) == 0)
{
	win -t data origin;
	run.section(,import);
}

