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 Works in Script Window but not Worksheet Scri
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

jsw

USA
5 Posts

Posted - 10/11/2002 :  3:29:10 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
The following script works in a script window, but not in a worksheet script window. It is a slight modification of a script in the Knowledge Base.

%Z="";
jjmax= %[%F]; ; // Null out resultant string
loop(jj,1,jjmax) { // Loop for each character in %A
if(%[%F,jj:jj]=="\") %Z=%Z\\ // if char=\ replace with \ else %Z=%Z%[%F,jj:jj]; // if char!=\ keep char

};
type %[%F] $(jj) $(jjmax);

In a Script Window I get the following result typed:
54 55 54
Here Origin goes through the loop 54 times.

In a Worksheet Script Window I get the following:
54 1 54
In the Worksheet Script Window the loop only goes through once, even though my minimum and maximum values are 1 and 54.

Any idea how to fix? I am using Origin 6.1 with Patch 4.

Ultimately, I want to copy the label from a worksheet such as, "c:\mydocs\origin\data1.txt" and write it as a label on a graph. When I write the label on the graph it interprets each "\" as a delimiter and formats the text in a funny way. The above routine replaces each "\" by "\\" which then prints as "\" in the graph label.

Thanks,
Joe

Mike Buess

USA
3037 Posts

Posted - 10/11/2002 :  5:21:35 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Joe,

There's an escape sequence that's not well documented but will work for what you want to do. Try this...

%T=c:\mydocs\origin\data1.txt;
label -s \v(%T);

Hope that helps.

...As for your script, if the double semicolon in this line

jjmax= %[%F]; ; // Null out resultant string

is really there (and not just added to your post by mistake), then it might be causing your problems.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 10/11/2002 7:22:55 PM
Go to Top of Page

jsw

USA
5 Posts

Posted - 10/14/2002 :  09:53:51 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I never was able to get the script to work, even with taking out that extra semicolon. I had originally tried using %[%F] directly in the loop command and that did not work either.

\v( ) did do what I need however.

Thanks,
Joe
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 10/15/2002 :  08:57:32 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You should put script into ogs file and call them from your worksheet script, like

run.section(%YmyScript.ogs,main)

or put script into buttons and execute them from the Worksheet Script, like

text.run();

The Worksheet Script dialog executes LabTalk line by line in the old days to avoid ';' and thus will have problem with multi-lined scripts.

CP



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