The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 How can I get the OXF path?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

ZanHUNG

20 Posts

Posted - 05/25/2016 :  03:40:43 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): Origin 2016 SR2
Operating System: Windows 7

I put some file and OXF in the same folder. I want to read/write it in X-Function. However, when editing the X-Function,
__FILE__
is actually the path of the corresponding XFC path, NOT OXF path. Hard-coding is not an option for me.

Question: How can I get the OXF path?

Thanks!


Edited by - ZanHUNG on 05/25/2016 03:41:07 AM

Chris D

428 Posts

Posted - 05/26/2016 :  2:50:08 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Zan,

Try this function. Pass it the X-Function name. Just the name- no file extension- and it is case-sensitive!! If it returns true, then the strOxfPath parameter will contain the full path to the folder containing the relevant OXF file.

Note: I have not thoroughly tested it so you should.


int MyXfOxfPath(string StrXfName, string& strOxfPath)
{
	StringArray saNames, saFiles;
	
	okutil_find_xf_files(StrXfName, &saNames, &saFiles); // Defined in oUtils.h, line 728.
	if (1 != saNames.GetSize() || 0 != strcmp(saNames[0], StrXfName))
		return false;
	
	string strFile = saFiles[0];
	if (!strFile.IsFile())
		return false;
	
	strOxfPath = GetFilePath(strFile);
	return true;
}


Thanks,
Chris Drozdowski
Originlab Technical Support

Edited by - Chris D on 05/26/2016 2:52:45 PM
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 06/04/2016 :  4:21:23 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I tried this and just want to document the info here. I created a simple XF in UFF called mytest, and here is the code


void mytest(const double& x)
{
	//begin code to print the XF path
	string strXF = "mytest";// had to hard code the name here
	string strPath;
	if(okutil_find_file_from_composite_name(&strPath, strXF, SUPPORTFILE_XF, ORIGIN_PATH_UNDEF) == ORIGIN_PATH_UNDEF)
		out_str("not found");
	else
	{
		string strOxfPath = GetFilePath(strPath);
		out_str(strOxfPath);
	}
	//end code
}


int mytest_event1(TreeNode& trGetN, int nRow, int nEventID, DWORD& dwEnables, LPCSTR lpcszNodeName, WndContainer& DynaCntrlContainer, string& strAux, string& strErrMsg)
{
	if( xf_is_extended_event(nEventID) )
		return mytest_event1_ex(trGetN, nRow, nEventID, dwEnables, lpcszNodeName, DynaCntrlContainer, strAux, strErrMsg);
	DECLARE_BUTTON_ENABLES
	//begin code to print XF path, you can see this by "mytest -d"
	//in event1, don't need to asssume XF name since it can be obtained from tree
	string strXF, strPath;
	trGetN.GetAttribute(STR_CLASS_OPTION_NAME_ATTRIB, strXF);
	okutil_find_file_from_composite_name(&strPath, strXF, SUPPORTFILE_XF, ORIGIN_PATH_UNDEF);
	out_str("in XF event, path is");
	out_str(GetFilePath(strPath));
	//end code print XF path
	return false;

}

Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000