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
 Reading and writing header info variables
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

PhilTHy

UK
Posts

Posted - 08/31/2006 :  08:42:04 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): OriginPro 7.5
Operating System: Win XP

I have an ASCII text data file type that has a lot of header rows (30). The delimiters are not consistent: most are colons but some are spaces. A few header rows have more than one pair of descriptor - variable values.

The import wizard manages commendably well, but column name and labels for example need some tidying up afterwards, and some of the header variable values I need to use subsequently in numerical analysis.

The datafile is produced by commercial instrument software; modifying the datafile at source isn't a viable option. I could write a pre-parser module to convert the header into a form that the Origin Import Wizard could readily handle, but this seems relatively hard work compared to just tidying up the few variables that matter after import into Origin. Not least because all my previous programming experience is in Fortran & VB. Origin is my first foray into the wonderful world of C :-)

So what I'd like to do, is read the variables using the "L1V1" reference from the header info variables, into C, and then write values back into a worksheet.

The job would be even neater if I could write back to the header info variable, to change the "L1V1" descriptors to more meaningful descriptors.

zachary_origin

China
Posts

Posted - 08/31/2006 :  10:27:02 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
It is hard to know exactly about the structure of the data file just from the description. So if it is possible, can you post the header lines here or send to data file to us thru tech@originlab.com and note what messages you want to get.

Zachary
OriginLab GZ Office
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 08/31/2006 :  10:40:01 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You can use page_get_info_var_value to get the string value of the "LnV1" descriptor, parse that string using string class functions and save your new values using page_set_info_var_value. The code will look something like this...

WorksheetPage wpg("Data1");
string str;
page_get_info_var_value(wpg, "L1V1", str, "User.Variables");
// parse str into (string) varName and (string or double) varValue
page_set_info_var_value(wpg, varName, varValue, "User.Variables");

Mike Buess
Origin WebRing Member
Go to Top of Page

PhilTHy

UK
Posts

Posted - 08/31/2006 :  12:00:49 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks Mike this works beautifully

Phil
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