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
 Entering Data to Text Box
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

YiDog21

USA
Posts

Posted - 10/21/2005 :  5:54:01 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 6.0
Operating System: XP

My question is similar to http://www.originlab.com/forum/topic.asp?TOPIC_ID=2748

which is, is there any way of taking the data from either the results log or script window (which i obtain after running a script using internal variables i.e. lr.b integ.area/integ.dx etc) and putting these values or the variable equivalent into a text box on a graph through labtalk?

Mike Buess

USA
3037 Posts

Posted - 10/22/2005 :  4:11:42 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
If you have OriginPro you could save the script window as a text file and then read the file into a string variable (%Z) with the File Utilities Module (FUM). Then use label -s %Z to create your label. Otherwise you have to create %Z separately with the same info that's in the script window.

Mike Buess
Origin WebRing Member
Go to Top of Page

YiDog21

USA
Posts

Posted - 10/25/2005 :  3:39:01 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I dont believe i have origin pro, I got very close when i tried to use the label tool but came up short, i used;


label -s -sa "From X = $(_xpos[1]) to $(_xpos[2]) \n <I> = $(INTEG.AREA/INTEG.dx*1*10^9) nA \n \g(d) = $(lr.b) Hz/sec";

which was located at the bottom of the whole script;

def EndToolBox //User Defined Macro
{
mks1=_indx[1]; //Sets internal variable mks1 to _index[1]
mks2=_indx[2]; //Sets internal variable mks2 to _index[2]
integrate %C; //Integrates data on layer2 between selected data points
type -a "From X = $(_xpos[1]) to $(_xpos[2])";
type "<I> = $(INTEG.AREA/INTEG.dx*1*10^9) nA";
layer -s 1; //Switches to layer1 (FreqDiff)
lr -n %C -b _indx[1] -e _indx[2]; //Fit Linear between selected data points
type "\g(d) = $(lr.b) Hz/sec"; //Outputs the slope
}

getpts 2; //Allows user to input two data points (beginning and end) values


label -s -sa "From X = $(_xpos[1]) to $(_xpos[2]) \n <I> = $(INTEG.AREA/INTEG.dx*1*10^9) nA \n \g(d) = $(lr.b) Hz/sec";

so what happened when i ran the script is that the text box spitted out the data of the PREVIOUSLY recorded data pts using those values assigned to the variables, but not the ones from the CURRENT run.

Im just using origin 6.0 and i was unable to find the file utilities module for the alternative method that you gave.
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 10/25/2005 :  4:48:27 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I don't know why you got values from the previous run but the easiest approach is to merge all text into a single string and type/create label simultaneously. The following version of your macro creates a string variable %Z which spans 3 lines. (Notice the semicolon is missing in first two lines.)

def EndToolBox {
mks1=_indx[1];
mks2=_indx[2];
integrate %C;
layer -s 1;
lr -n %C -b _indx[1] -e _indx[2];
%Z="From X = $(_xpos[1]) to $(_xpos[2])
<I> = $(INTEG.AREA/INTEG.dx*1*10^9) nA
\g(d) = $(lr.b) Hz/sec";
type -a %Z;
label -s -sa %Z;
};
quote:
Im just using origin 6.0 and i was unable to find the file utilities module
FUM comes with OriginPro.

Mike Buess
Origin WebRing Member
Go to Top of Page

YiDog21

USA
Posts

Posted - 10/25/2005 :  6:48:40 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
To change the text box properties I changed the line reading
label -s -sa %Z; to
label -s -sa -n data %Z; assigning a name to the text object so that I can add something to the properties like
data.color=color(olive);

but assigning a name to change the text box properties, when i want to repeat this for different user defined intervals (using getpts 2;)
obviously what happens is that if i run this in a script, the previous data gets overwritten by the new data that and replaced in the text box. So how can I extend my script to account for multiple trials? I was thinking about a if else or for loop? am i on the right track?
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 10/25/2005 :  9:26:33 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
It's possible to come up with an elaborate scheme for naming text labels, but much easier to let Origin give them names and then find out what those names are. The document -e G {script} command loops through all objects in the active layer, assigns each name to the string variable %B and runs the script in brackets. When the label command creates a text label its name goes to the top of the object list, so something like this will work...

label -s -sa %Z; // create text label
doc -e G {break};
%B.color=color(olive); // color it olive

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 10/25/2005 9:28:57 PM
Go to Top of Page

YiDog21

USA
Posts

Posted - 10/27/2005 :  01:05:54 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I tried that method and was unsuccessful, was i supposed to incorporate those last lines into the previous script that i wrote? and lets say i named the script mydata.OGS, so in the line doc -e G {break}; would i replace break with mydata? when i tried incorporating that into the script the color did not change, then i tried using just the lines you gave;
label -s -sa %Z; // create text label
doc -e G {break};
%B.color=color(olive); // color it olive
I still came up without any changes in properties... plz help
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 10/27/2005 :  07:43:47 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The script works as it is written. The break command in brackets stops doc -e after it has assigned the name of the new text label to the string variable %B. The following gives you an olive text label saying "This is a test". The %B=; inside the brackets merely tells you the label name (Text, Text1, Text2, ...) and is not necessary for the script to work.

%Z="This is a test";
label -s -sa %Z;
doc -e G {%B=; break};
%B.color=color(olive);

Mike Buess
Origin WebRing Member
Go to Top of Page

YiDog21

USA
Posts

Posted - 10/27/2005 :  11:52:34 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Alright so I gave that a try, and the result was after running the doc -e G {%B=; break}; command the value "L1" popped up in the script window, im not sure what variable that iS but the text box reading "This is a test" is not L1, in fact it does not have an object name at all, so what i dont understand is when you stated:
quote:
When the label command creates a text label its name goes to the top of the object list
,
and just using label -s -sa %Z does not give a text box object a [bold]name[/bold]

again i want to do is to have one script (mydata) that outputs the results of an interval of data and put that in a text box, and in the same script change the properties of the text box, but allowing this one script to run multiple times in the same graph window but just with different x intervals

Also from what i have found now the doc -e G {%B=; break}; will ONLY take the last text label, assign it to %B and change the properties of that label, if the text box was given an object name}, and does not carry it to all text boxes most likely from the break command, but then if the break command is not there it takes all of the objects in that layer which is not what i want. All i want is to have the script be able to run multiple times, and through just this one script and create a text box each time after getting a user input to select the data intervals, but be able to adjust the properties of the text box for each instance running the script
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 10/27/2005 :  8:30:15 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The script I gave you acts as I just described in Origin 6.0 SR4 and higher. I also have Origin 5.0 on my PC and it acts as you describe in that version. I suggest you update your Origin to 6.0 SR4...

http://www.originlab.com/www/support/querytech.aspx?keywords=&boolean=and&scope=all&category=Patches&type=Patches&version=All&language=all

...If you can't update your Origin you'll be forced to name your text labels yourself. In that case you can use something like the following to generate unique label names such as Text1, Text2, etc.

for(i=1;i>0;i++) {
%B=Text$(i);
if(%B.show==0/0) break;
};
label -s -sa -n %B %Z;
%B.color=color(olive);

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 10/28/2005 1:05:03 PM
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