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
 Origin Forum
 Switch with string data
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Duff

Argentina
42 Posts

Posted - 09/16/2024 :  1:23:46 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 2021
Operating System: Windows 10

Hi everyone,
I'm trying to create a script with the Switch command,
In column A I have text data and I want to assign a category to it with the Switch command. I don't know why doesn't work.
Thanks for your help!

get Col(A) -e numpoints;
range aa=Col(A);
for (ii=1; ii<=numpoints; ii++)
{
Switch (aa[ii])
{ 
     case "aa": 
         Col(B)[ii]$="Case aa";
         break;
     case "bb": 
         Col(B)[ii]$="Case ab";
         break;  
     Default: 
         Col(C)[ii]$="Case Default";
         break;
}
}

YimingChen

1613 Posts

Posted - 09/16/2024 :  2:23:48 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Change to
Switch (%(aa[ii]$))
or
Switch (%(col(A)[ii]$))


James
Go to Top of Page

Duff

Argentina
42 Posts

Posted - 09/16/2024 :  4:38:41 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Works great, thanks James.
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