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
 Indexing 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

tib

Switzerland
105 Posts

Posted - 06/22/2007 :  06:18:24 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi there,

I have several variables:
Substrate0$, Substrate1$, Substrate2$, Substrate3$ etc....

Furthermore, I have several text objects in a Graph:
Graph!Substrate0, Graph!Substrate1, Graph!Substrate2, Graph!Substrate3, etc...

Now in a simple loop I want to read the values from the Graph into the variables.

loop (iii,0,aaa) {
Substrate$(iii)$=Graph!Substrate$(iii).text$;
};

Why does this loop not work? What is wrong?
I tried brackets and $ almost everywhere... also with %A as intermediate variable... Without success.

Thanks for help,
Tilman.

Mike Buess

USA
3037 Posts

Posted - 06/22/2007 :  08:54:49 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Tilman,

Your script works fine for me in O75 SR6 as long as aaa is defined and the window containing the text objects is named Graph. If you've been working in the same Origin session for a long time I recommend a restart.

Mike Buess
Origin WebRing Member
Go to Top of Page

tib

Switzerland
105 Posts

Posted - 06/22/2007 :  09:23:06 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks Mike,
for some strange reason one of the text objects in Graph has disappeared. Of course, assigning a value to a non-existing object does not work well.
But as you said, a restart from time to time might not be bad.
Now, it works!

Now, I believe to know why the text object disappeared:
You assign a zero string "" to a text object and save your project and close Origin. Next time you open the project the text object will be disappeared. Is this the way how it should be???
A workaround would be that you check the length of the text object beforehand and in case of zero length assign e.g. a space " ".

Edited by - tib on 06/26/2007 03:39:56 AM
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 06/26/2007 :  07:52:09 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
You assign a zero string "" to a text object and save your project and close Origin. Next time you open the project the text object will be disappeared. Is this the way how it should be???
You don't have to wait until the next time you open the project for the text object to disappear. You simply cannot create an empty text label in the first place. Try this...

%Z="";
label -s -sa -n Substrate1 %Z;
list o; // list all objects

Substrate1 will not appear on the object list. Setting the label to white space (space or tab) does not help. (If you start with %Z=" " the label will still not be created.) As far as I know, this has been the way text objects have always worked. Attempting to find the text of a missing object will only result in a command error so you can check for its existence first. One way to check for an objects existence is with the object.show property...

object.show = 1 (visible), 0 (hidden), -- (doesn't exist)

loop(iii,1,aaa) {
if( Substrate$(iii).show ) Substrate$(iii)$=Substrate$(iii).text$;
else Substrate$(iii)$="";
};


Mike Buess
Origin WebRing Member
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