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
 Origin Forum
 Switch with string data

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
Duff Posted - 09/16/2024 : 1:23:46 PM
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;
}
}

2   L A T E S T    R E P L I E S    (Newest First)
Duff Posted - 09/16/2024 : 4:38:41 PM
Works great, thanks James.
YimingChen Posted - 09/16/2024 : 2:23:48 PM
Change to
Switch (%(aa[ii]$))
or
Switch (%(col(A)[ii]$))


James

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