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
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Get file name and userparameter as variable

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Leffop Posted - 04/03/2012 : 06:45:54 AM
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
6   L A T E S T    R E P L I E S    (Newest First)
Leffop Posted - 04/12/2012 : 07:04:47 AM
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?
Laurie Posted - 04/03/2012 : 6:38:02 PM
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
Leffop Posted - 04/03/2012 : 5:13:42 PM
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
greg Posted - 04/03/2012 : 3:52:55 PM
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;
Leffop Posted - 04/03/2012 : 1:02:40 PM
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
greg Posted - 04/03/2012 : 09:32:38 AM
(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]$;

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000