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
 Labtalk script behaving differently when called
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

SFackler

Germany
4 Posts

Posted - 01/15/2021 :  09:12:52 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hello,

I have trouble when calling my origin scripts.

I have several scripts that run fine, when I place the code directly in customs.ogs, but when I place the script in a seperate file "MyScript.ogs" and run it with
run MyScript.ogs

I get a different behavior.

For example
customs.ogs
int firstResultColumn = 6;
col($(firstResultColumn))[L]$ = "Cycle";


creates a new colums at index 6 (Column(F)) and changes the longname to "Cycle"

When I change to:
customs.ogs
run MyScript.ogs;


MyScript.ogs
int firstResultColumn = 6;
col($(firstResultColumn))[L]$ = "Cycle";


Everytime I run the script a new column is created with the longname "cycle" and not at index 6. If I enter the column index directly it works everytime, but since I have several instances where I need dynamic column creation and manipulating this is no possibility.

It feels like I'm missing some referencing, or something. Sadly I can not find a description of my problem.

Can somebody guide me in the right direction?

Best regards,
SFackler

--------------------------------------------------------------
Origin Ver. and Service Release (Select Help-->About Origin):
OriginPro 2021 (64-bit)
9.8.0.200 (Lehre)

Operating System: Windows 10 64bit

cpyang

USA
1406 Posts

Posted - 01/15/2021 :  10:12:26 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
If you are using index, better use wcol(firstResultColumn)[L]$, can you try?

CP
Go to Top of Page

SFackler

Germany
4 Posts

Posted - 01/15/2021 :  10:21:40 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
with wcol I'm getting no response, when placed in the script I try to call. I placed a message box in the code, which gets executed. When I place the code in customs.ogs it runs well.

To emphasis my problem: I can get code running in the customs.ogs script when hitting the icon. But if I move the code to another file and run this file from customs.ogs with the icon, the code seems to work somewhat different.

not working
customs.ogs
run MyScript.ogs


MyScript.ogs
int firstResultColumn = 6;
wcol($(firstResultColumn))[L]$ = "Cycle";
type -b "hello";


working:
customs.ogs
int firstResultColumn = 6;
wcol($(firstResultColumn))[L]$ = "Cycle";
type -b "hello";


I tried:
manually creating the columns before executing -> no change
referencing with $() and without -> no change


Edited by - SFackler on 01/15/2021 10:23:50 AM
Go to Top of Page

Chris D

428 Posts

Posted - 01/15/2021 :  10:49:26 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

For whatever reason (not sure at all), the `int` from `int firstResultColumn = 6` is problematic.

Do this.

MyScript.ogs:

int firstResultColumn = 6;
wcol(firstResultColumn)[L]$ = "Cycle";
type -b "hello";


Custom.ogs:

run.file(MyScript.ogs)


I hope this helps.

Thanks,
Chris Drozdowski
Originlab Technical Support
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 01/15/2021 :  5:09:53 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Yes, use run.section, or run.file, don't use "run file", as that will run the file line by line instead of as a whole, so your line that set int value is not visible on the next line.

CP
Go to Top of Page

SFackler

Germany
4 Posts

Posted - 01/18/2021 :  03:21:08 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

the command run.section() does work, the command run.file() does not seem to execute the script. The run.section() command works fine to me. just a short feedback on the toppic.

works:
customs.ogs
run.section(MyScript,test);


MyScript.ogs
[test]
int firstResultColumn = 6;
wcol($(firstResultColumn))[L]$ = "Cycle";
type -b "hello";


does not work
customs.ogs
run.file(MyScript);


MyScript.ogs
[test]
int firstResultColumn = 6;
wcol($(firstResultColumn))[L]$ = "Cycle";
type -b "hello";


I've tried specifying the path, adding the ogs extension with run.file() and changing the section in MyScript to [Main], but with no result.

I'll work with the run.section() command in the future.

Many thanks,
SFackler
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 01/18/2021 :  12:58:01 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The reason run.file didnt work was because you added a redundant [test] on top of your code. run.file does not need it as it will just run the whole file.

Also, you should do
wcol(firstResultColumn)


no need to do
wcol($(firstResultColumn))
when using the wcol function.

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