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
 Trying to change column order with Labtalk
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

OriginUser9

Latvia
8 Posts

Posted - 04/11/2022 :  04:14:42 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Here is the code:
doc -ef W {
 doc -e LW {
 if(%H == "wks1" || %H == "wks2" || %H == "wks3")

{ 
colmove rng:=col(3):col(4) operation:=first;
}
}};


But I get an error:
Command Error!
. What's the problem?

Edited by - OriginUser9 on 04/11/2022 06:52:18 AM

aplotnikov

Germany
169 Posts

Posted - 04/11/2022 :  06:23:09 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
%H contains the window name, not the worksheet name. You can use the page.active value instead.
Go to Top of Page

OriginUser9

Latvia
8 Posts

Posted - 04/11/2022 :  06:51:43 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Sorry, I wanted to say that I use windows name.
doc -ef W {
 doc -e LW {
 if(%H == "window1" || %H == "window2")

 {
       
	colmove rng:=col(3):col(4) operation:=first;
	  

   }
}};

But even when I change the code like you said, I get the same error.
doc -ef W {
 doc -e LW {
 if(%page.active == "wks1" || %page.active == "wks2")

 {
       
	colmove rng:=col(3):col(4) operation:=first;
	  

   }
}};

I tried to remove % from the code, but I still get the error.

Edited by - OriginUser9 on 04/11/2022 06:52:47 AM
Go to Top of Page

aplotnikov

Germany
169 Posts

Posted - 04/11/2022 :  07:31:33 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
page.active is an integer value:
if (page.active == 1 || ...) {...}


Use page.active$ if you need to compare strings:
if (CompareNoCase(page.active$,"Sheet1") == 0 || ...) {...}


PS. If you need to run the script only for selected workbooks ("windows") it may be reasonable to check the condition within the corresponding loop to avoid unnecessary checks and to improve the readability of your code:
doc -ef W {
  if ("%H"=="Book1" || ...) {
    doc -e LW {...}
  }
}


Edited by - aplotnikov on 04/11/2022 07:47:33 AM
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