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
 LabTalk Forum
 Get file name and userparameter as variable
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Leffop

Germany
8 Posts

Posted - 04/03/2012 :  06:45:54 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 8
Operating System: Win7
Hi,
i have two questions regarding labtalk.
1. Is it possible to read the Origin file name and use it as a variable? Because my files have the format YYMMDD and i want two extract the measurement date from the file name.

2. is it possible two excess the so called USerParameter ? Normally i use something like
"RangeName[U]$="(unit)";"



thx for your help in advance

greg

USA
1379 Posts

Posted - 04/03/2012 :  09:32:38 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
(1) If by Origin file name you mean the name of the file you imported, then yes, that is in the page storage and can be accessed from script:

string str$ = Book1!page.info.system.import.filename$;
str$ = str.mid(n,6)$; // extract 6 characters starting at position 'n'

If the files were real-time generated, you can also get their date-time stamp:

jdn = page.info.system.import.filedate;
ty $(jdn,D10);

(2) You can use the Row Header text to access any parameter value:

string strP0$ = col(B)[UserParameter0]$;

Edited by - greg on 04/03/2012 09:33:45 AM
Go to Top of Page

Leffop

Germany
8 Posts

Posted - 04/03/2012 :  1:02:40 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
thanks,

1) I need to get the name of the opj-file. This has nothing to do with import of files.

another question:
Is it possible to add new row headers like UserParameterXY?

king regards
Go to Top of Page

greg

USA
1379 Posts

Posted - 04/03/2012 :  3:52:55 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
If you are talking about the name of the current OPJ file, then that is available (without the .OPJ) in the G String Register variable:

string strProjectName$ = %G;

For custom headers ...

wks.userparam# = 1; // Turn ON the # user parameter row
wks.userparam# = 0; // Turn OFF the # user parameter row
string str$ = wks.userparam#$; // Read the # user parameter row header
wks.userparam#$ = "Some text"; // Write the # user parameter row header

where # starts at 1 and can go up to 127.

E.g.
wks.userparam1$ = Temperature;
wks.userparam1 = 1;
col(2)[Temperature]$ = 16.5K;
Go to Top of Page

Leffop

Germany
8 Posts

Posted - 04/03/2012 :  5:13:42 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you, this works great.

But i have a new questions:
Is it possible to check if a variable already excists? Or is it possible to give a default value a variable test$

Something like: only if test$ does not excist --> test$=default


Kind regards

Edited by - Leffop on 04/03/2012 5:15:26 PM
Go to Top of Page

Laurie

USA
404 Posts

Posted - 04/03/2012 :  6:38:02 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You can use the string functions like:

IsEmpty or GetLength

For example:

test$="default";
test.getlength()=;
test.getlength()=7
test.isempty()=;
test.isempty()=0

If the values returned are missing then you know the string variable does not exist. For example:

if(test.isempty() == NANUM) test$ = "default";

OriginLab Technical Support
Go to Top of Page

Leffop

Germany
8 Posts

Posted - 04/12/2012 :  07:04:47 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you, this works fine for string objects, but don't work anymore for integers:
if(Temperature.isempty() == NANUM) Temperature = 5;

Is there another way for integer objects?
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