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
 Origin Forum
 Changing attached files
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

peter.cook

UK
356 Posts

Posted - 08/30/2007 :  2:04:04 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5 SR6
Operating System: Win2000

Hi,

I may have had some discussions about this previously but what I want to ask is : can I amend the attached files (to an OPJ) programmatically in any way. I can open the OPJ and amend the attached files but I then have to open the codebuilder in order to ensure that the amend attached files are saved with the project. It would be really useful if there was any way I could to do this without programmatically. A scenario is to update 100s OPJ files containing data with new code for data analysis. Any bright ideas?

Cheers,

pete

greg

USA
1378 Posts

Posted - 09/25/2007 :  10:22:51 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
When you save an Origin Project file with files stored in Code Builder's Project Folder, these files are placed in a user's temporary folder when the OPJ file is opened. All you need to do is open the OPJ, find that temporary folder, replace the file(s) then update the OPJ.

This OriginC function will replace a file (strFile) in the Project folder of the selected Origin Project file (strOPJ) with a replacement file (strNewFile). The strOPJ and strNewFile must be full path and filenames, while strFile is just the name of the attached file.

// SYNTAX : Update_OPJ(D:\MyProjects\My.OPJ,my.c,D:\MyNew.c)
void Update_OPJ(string strOPJ, string strFile, string strNewFile)
{
// Open the OPJ file
Project.Open(strOPJ);
// Get the TEMP folder used by Origin
char sztemp[MAXFULLPATH];
DWORD aa = GetTempPath(MAXFULLPATH, sztemp);
// Locate the file needing updating
if(FindFile(strFile, sztemp, "", FALSE))
{
string strFullName = sztemp + strFile;
// Delete the file
DeleteFile(strFullName);
// Copy the new file
FileCopy(strNewFile, strFullName);
string strcmd;
// compile and save OPJ
Project.FindFunction(strFile);
Project.Save();
}
else
{
// Problem
out_str("Not found!");
}
}


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