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
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Labtalk script behaving differently when called

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
SFackler Posted - 01/15/2021 : 09:12:52 AM
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

6   L A T E S T    R E P L I E S    (Newest First)
cpyang Posted - 01/18/2021 : 12:58:01 PM
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
SFackler Posted - 01/18/2021 : 03:21:08 AM
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
cpyang Posted - 01/15/2021 : 5:09:53 PM
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
Chris D Posted - 01/15/2021 : 10:49:26 AM
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
SFackler Posted - 01/15/2021 : 10:21:40 AM
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

cpyang Posted - 01/15/2021 : 10:12:26 AM
If you are using index, better use wcol(firstResultColumn)[L]$, can you try?

CP

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000