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
 loop over text objects in a graph
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Clairekun

Germany
175 Posts

Posted - 05/04/2022 :  10:07:37 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 2018b
Operating System: Windows 10

Hello,

I need to replace a letter in several text objects in multiple graphs. All labels I'm interested in share a partial name, which is Temp (Temp1, Temp2, etc.).

This would be the script for 4 labels:
loop (i,1,4)
{

string name$ = Temp$(i);
string lab$ = %(name$).text$;
lab2$ = Substitute(lab$,°,º,1)$;
%(name$).text$=lab2$;

}
}

Which works. My problem is, the number of TempX labels is variable, so I would need a way to count how many there are to tailor the loop command.

I think it should be relatively obvious, but I have been unable to find out how.

Thank you.

YimingChen

1666 Posts

Posted - 05/05/2022 :  2:20:51 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Please refer to this page to loop over all graph objects:
https://www.originlab.com/doc/LabTalk/guide/Looping-Over-objs#Looping_Over_Graphic_Objects

And your code can be:

doc -e P
{
    doc -e LW
    {
        doc -e G
        {   
            if(left("%B", 4)$ == "Temp")
            {
		%B.text$ = Substitute(%B.text$,°,º,1)$;
            }            
        }
    }
}


James

Edited by - YimingChen on 05/05/2022 2:22:21 PM
Go to Top of Page

Clairekun

Germany
175 Posts

Posted - 05/05/2022 :  5:03:14 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Sorry, my mistake. I did look into doc -e command (several times, actually) but totally missed G option.

Thank you, this works flawlessly.

Edited by - Clairekun on 05/05/2022 5:30:07 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