cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
%3CLINGO-SUB%20id%3D%22lingo-sub-46411%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ES%C3%A9lectionnez%20les%20lignes%20qui%20correspondent%20%C3%A0%20n'importe%20quelle%20valeur%20dans%20une%20liste%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-46411%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CDIV%20class%3D%22lia-message-template-problem-zone%22%3E%0A%3CH2%20id%3D%22toc-hId--1330392654%22%20id%3D%22toc-hId-1619651981%22%20id%3D%22toc-hId-1619651981%22%3EProbl%C3%A8me%3C%2FH2%3E%0A%3CP%3ESupposons%20que%20vous%20invitiez%20un%20utilisateur%20%C3%A0%20effectuer%20une%20s%C3%A9lection.%20Lorsque%20vous%20r%C3%A9cup%C3%A9rez%20les%20valeurs%20de%20l'utilisateur%2C%20elles%20sont%20g%C3%A9n%C3%A9ralement%20stock%C3%A9es%20dans%20une%20liste.Vous%20devez%20maintenant%20s%C3%A9lectionner%20les%20donn%C3%A9es%20qui%20correspondent%20aux%20valeurs%20de%20la%20liste.%3C%2FP%3E%0A%3C%2FDIV%3E%0A%3CDIV%20class%3D%22lia-message-template-diagnosis-zone%22%3E%0A%3CH2%20id%3D%22toc-hId--442888973%22%20id%3D%22toc-hId--932504980%22%20id%3D%22toc-hId--932504980%22%3ESolution%3C%2FH2%3E%0A%3CP%3E%3CSPAN%3EL'exemple%20suivant%20montre%20comment%20s%C3%A9lectionner%20des%20lignes%20dans%20une%20table%20de%20donn%C3%A9es%20contenant%20n'importe%20quelle%20valeur%20stock%C3%A9e%20dans%20une%20liste%20JSL.%20Des%20listes%20contenant%20soit%20des%20valeurs%20num%C3%A9riques%2C%20soit%20des%20cha%C3%AEnes%20de%20caract%C3%A8res%20peuvent%20%C3%AAtre%20utilis%C3%A9es%20et%20sont%20pr%C3%A9sent%C3%A9es%20ci-dessous.Voir%20les%20commentaires%20int%C3%A9gr%C3%A9s%20pour%20plus%20de%20d%C3%A9tails.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3E%2F*%20Open%20a%20sample%20data%20table.%20*%2F%0Adt%20%3D%20Open(%20%22%24SAMPLE_DATA%5CBig%20Class.jmp%22%20)%3B%0A%0A%2F*%20Create%20a%20list%20of%20ages.%20*%2F%0AmyList%20%3D%20%7B9%2C%2012%2C%2015%2C%2017%2C%2018%7D%3B%0A%0A%2F*%20Select%20all%20rows%20which%20have%20an%20age%20that%20is%20in%20the%20list.%20*%2F%0Adt%20%26lt%3B%26lt%3B%20Select%20Where(%20Contains(%20myList%2C%20%3Aage%20)%20)%3B%0A%0AWait(%202%20)%3B%20%20%20%20%20%20%20%20%20%20%20%2F%2F%20For%20demonstration%20purposes%0A%0A%2F*%20Create%20a%20list%20of%20student%20names.%20*%2F%0AmyStudents%20%3D%20%7B%22HENRY%22%2C%20%22ROBERT%22%2C%20%22BARBARA%22%2C%20%22SALLY%22%2C%20%22MARION%22%7D%3B%0A%0A%2F*%20Select%20all%20rows%20which%20have%20any%20of%20the%20names%20in%20the%20list.%20*%2F%0Adt%20%26lt%3B%26lt%3B%20Select%20Where(%20Contains(%20myStudents%2C%20%3Aname%20)%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3C%2FDIV%3E%0A%3CDIV%20class%3D%22lia-message-template-solution-zone%22%3E%0A%3CH2%20id%3D%22toc-hId-444614708%22%20id%3D%22toc-hId-810305355%22%20id%3D%22toc-hId-810305355%22%3EDiscussion%3C%2FH2%3E%0A%3CP%3EDans%20ces%20exemples%2C%20la%20fonction%20Contains()%20est%20utilis%C3%A9e%20pour%20comparer%20chaque%20ligne%20%C3%A0%20la%20liste%20de%20valeurs.%3C%2FP%3E%3CSPAN%3EDe%20nombreux%20autres%20exemples%20d'utilisation%20de%20Select%20Where()%20peuvent%20%C3%AAtre%20trouv%C3%A9s%20dans%20le%3C%2FSPAN%3E%3CA%20href%3D%22http%3A%2F%2Fwww.jmp.com%2Fsupport%2Fhelp%2F13-2%2FSelect_Rows_2.shtml%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3E%20S%C3%A9lectionner%20des%20lignes%3C%2FA%3E%3CSPAN%3E%20du%20Guide%20de%20script%20JMP.%3C%2FSPAN%3E%3CBR%20%2F%3E%3CH2%20id%3D%22toc-hId-1332118389%22%20id%3D%22toc-hId--1741851606%22%20id%3D%22toc-hId--1741851606%22%3EVoir%20%C3%A9galement%3C%2FH2%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2FJSL-Cookbook%2FSelect-rows-from-the-currently-selected-rows%2Fta-p%2F46409%22%20target%3D%22_blank%22%3ES%C3%A9lectionnez%20des%20lignes%20parmi%20les%20lignes%20actuellement%20s%C3%A9lectionn%C3%A9es%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2FJSL-Cookbook%2FSelect-rows-based-upon-multiple-conditions%2Fta-p%2F46404%22%20target%3D%22_blank%22%3ES%C3%A9lectionnez%20des%20lignes%20en%20fonction%20de%20plusieurs%20conditions%3C%2FA%3E%3C%2FP%3E%0A%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-709889%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%20%3A%20S%C3%A9lectionner%20les%20lignes%20qui%20correspondent%20%C3%A0%20n'importe%20quelle%20valeur%20dans%20une%20liste%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-709889%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EAh%2C%20sympa%20%3CLI-EMOJI%20id%3D%22lia_slightly-smiling-face%22%20title%3D%22%3Acara_con_una_leve_sonrisa%3A%22%3E%3C%2FLI-EMOJI%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%20Je%20craignais%20que%20le%20contenu%20soit%20plus%20lent.%20mais%20en%20fait%20...%3CBR%20%2F%3E%20note%20pour%20moi%20%3A%20utiliser%3CSTRONG%3E%20contient%3C%2FSTRONG%3E%20%3CLI-EMOJI%20id%3D%22lia_slightly-smiling-face%22%20title%3D%22%3Acara_con_una_leve_sonrisa%3A%22%3E%3C%2FLI-EMOJI%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22hogi_0-1702737609134.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22hogi_0-1702737609134.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22hogi_0-1702737609134.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F59757i76E3893397E24BF0%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22hogi_0-1702737609134.png%22%20alt%3D%22hogi_0-1702737609134.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%20class%3D%22lia-spoiler-container%22%3E%3CA%20class%3D%22lia-spoiler-link%22%20href%3D%22%23%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%20target%3D%22_blank%22%3EVoir%20plus...%3C%2FA%3E%3CNOSCRIPT%3E%3CDIV%20class%3D%22lia-spoiler-content%22%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0ATry(close(dt%2C%20noSave))%3B%0Adt%20%3D%20Open(%20%22%24SAMPLE_DATA%2FBig%20Class.jmp%22%20)%3B%0A%0Aresults%20%3D%20New%20Table(%20%22Untitled%22%2C%0A%20Add%20Rows(%200%20)%2C%0A%20New%20Column(%20%22rows%22%20)%2C%0A%20New%20Column(%20%22t_contains_string%22%20)%2C%0A%20New%20Column(%20%22t_any_loc_string%22%20)%2C%0A%20New%20Column(%20%22t_contains_number%22%20)%2C%0A%20New%20Column(%20%22t_any_loc_number%22%20)%2C%0A%20New%20Column(%20%22t_any_number%22%20)%0A)%3B%0A%0Adt%20%26lt%3B%26lt%3B%20New%20Column(%20%22nameID%22%2C%20Formula(%20Row()%20)%20)%3B%0Adt%3AnameID%20%26lt%3B%26lt%3B%20delete%20formula%3B%0A%0AFor(%20i%20%3D%201%2C%20i%20%26lt%3B%3D%2020%2C%20i%2B%2B%2C%0A%0A%20t0%20%3D%20HP%20Time()%3B%0A%20dt%20%26lt%3B%26lt%3B%20Select%20Where(%20Contains(%20%7B%22JANE%22%2C%20%22DAVID%22%2C%20%22PATTY%22%7D%2C%20%3Aname%20)%20)%3B%0A%20t1%20%3D%20((HP%20Time()%20-%20t0)%20%2F%201000000)%3B%0A%0A%20t0%20%3D%20HP%20Time()%3B%0A%20dt%20%26lt%3B%26lt%3B%20Select%20Where(%20Any(%20Loc(%20%7B%22JANE%22%2C%20%22DAVID%22%2C%20%22PATTY%22%7D%2C%20%3Aname%20)%20)%20)%3B%0A%20t2%20%3D%20((HP%20Time()%20-%20t0)%20%2F%201000000)%3B%0A%0A%20t0%20%3D%20HP%20Time()%3B%0A%20dt%20%26lt%3B%26lt%3B%20Select%20Where(%20Contains(%20%7B3%2C%2015%2C%2020%7D%2C%20%3AnameID%20)%20)%3B%0A%20t3%20%3D%20((HP%20Time()%20-%20t0)%20%2F%201000000)%3B%0A%20%0A%20t0%20%3D%20HP%20Time()%3B%0A%20dt%20%26lt%3B%26lt%3B%20Select%20Where(%20Any(%20Loc(%20%5B3%2015%2020%5D%2C%20%3AnameID%20)%20)%20)%3B%0A%20t4%20%3D%20((HP%20Time()%20-%20t0)%20%2F%201000000)%3B%0A%0A%20t0%20%3D%20HP%20Time()%3B%0A%20dt%20%26lt%3B%26lt%3B%20Select%20Where(%20Any(%20%3AnameID%20%3D%3D%20%5B3%2015%2020%5D%20)%20)%3B%0A%20t5%20%3D%20((HP%20Time()%20-%20t0)%20%2F%201000000)%3B%0A%0A%20results%20%26lt%3B%26lt%3B%20add%20rows(%20%7B%3Arows%20%3D%20N%20Rows(%20dt%20)%2C%3At_contains_string%20%3D%20t1%2C%20%3At_any_loc_string%20%3D%20t2%2C%20%3At_contains_number%20%3D%20t3%2C%20%3At_any_loc_number%20%3D%20t4%2C%20%3At_any_number%20%3D%20t5%7D%20)%3B%0A%20dt%20%3D%20dt%20%26lt%3B%26lt%3B%20concatenate(%20%7Bdt%7D%2C%20Append%20to%20first%20table%20)%3B%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FDIV%3E%3CNOSCRIPT%3E%3CDIV%20class%3D%22lia-spoiler-noscript-content%22%3ENoms%20par%20d%C3%A9faut%20ici%20(%201%20)%3B%20Essayez(close(dt%2C%20noSave))%3B%20dt%20%3D%20Open(%20%22%24SAMPLE_DATA%2FBig%20Class.jmp%22%20)%3B%20r%C3%A9sultats%20%3D%20Nouvelle%20table%20(%20%22Sans%20titre%22%2C%20Ajouter%20des%20lignes%20(%200%20)%2C%20Nouvelle%20colonne%20(%20%22%20lignes%20%22%20)%2C%20Nouvelle%20colonne%20(%20%22%20t_contains_string%20%22%20)%2C%20Nouvelle%20colonne%20(%20%22%20t_any_loc_string%20%22%20)%2C%20Nouvelle%20colonne%20(%20%22%20t_contains_number%20%22%20)%2C%20Nouvelle%20colonne%20(%20%22t_any_loc_number%22%20)%2C%20Nouvelle%20colonne(%20%22t_any_number%22%20)%20)%3B%20dt%20%26lt%3B%26lt%3B%20Nouvelle%20colonne(%20%22nameID%22%2C%20Formule(%20Row()%20)%20)%3B%20dt%3AnameID%20%26lt%3B%26lt%3B%20supprimer%20la%20formule%26nbsp%3B%3B%20Pour(%20i%20%3D%201%2C%20i%20%26lt%3B%3D%2020%2C%20i%2B%2B%2C%20t0%20%3D%20HP%20Time()%3B%20dt%20%26lt%3B%26lt%3B%20Select%20Where(%20Contains(%20%7B%22JANE%22%2C%20%22DAVID%22%2C%20%22PATTY%22%7D%2C%20%3Aname%20)%20)%3B%20t1%20%3D%20(%20(HP%20Time()%20-%20t0)%20%2F%201000000)%3B%20t0%20%3D%20HP%20Time()%3B%20dt%20%26lt%3B%26lt%3B%20S%C3%A9lectionner%20O%C3%B9(%20Any(%20Loc(%20%7B%22JANE%22%2C%20%22DAVID%22%2C%20%22PATTY%22%7D%2C%20%3Aname%20)%20)%20)%3B%20t2%20%3D%20((HP%20Time()%20-%20t0)%20%2F%201000000)%3B%20t0%20%3D%20HP%20Time()%3B%20dt%20%26lt%3B%26lt%3B%20Select%20Where(%20Contains(%20%7B3%2C%2015%2C%2020%7D%2C%20%3AnameID%20)%20)%3B%20t3%20%3D%20((HP%20Time()%20-%20t0)%20%2F%201000000)%3B%20t0%20%3D%20HP%20Time()%3B%20dt%20%26lt%3B%26lt%3B%20S%C3%A9lectionner%20O%C3%B9(%20Any(%20Loc(%20%5B3%2015%2020%5D%2C%20%3AnameID%20)%20)%20)%3B%20t4%20%3D%20((HP%20Time()%20-%20t0)%20%2F%201000000)%20%3B%20t0%20%3D%20HP%20Time()%3B%20dt%20%26lt%3B%26lt%3B%20Select%20Where(%20Any(%20%3AnameID%20%3D%3D%20%5B3%2015%2020%5D%20)%20)%3B%20t5%20%3D%20((HP%20Time()%20-%20t0)%20%2F%201000000)%3B%20r%C3%A9sultats%20%26lt%3B%26lt%3B%20ajouter%20des%20lignes%20(%20%7B%20%3Arows%20%3D%20N%20Lignes(%20dt%20)%2C%3At_contains_string%20%3D%20t1%2C%20%3At_any_loc_string%20%3D%20t2%2C%20%3At_contains_number%20%3D%20t3%2C%20%3At_any_loc_number%20%3D%20t4%2C%20%3At_any_number%20%3D%20t5%7D%20)%3B%20dt%20%3D%20dt%20%26lt%3B%26lt%3B%20concatenate(%20%7Bdt%7D%2C%20Ajouter%20au%20premier%20tableau%20)%3B%20)%3B%3C%2FDIV%3E%3C%2FNOSCRIPT%3E%3C%2FNOSCRIPT%3E%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-709882%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%20%3A%20S%C3%A9lectionner%20les%20lignes%20qui%20correspondent%20%C3%A0%20n'importe%20quelle%20valeur%20dans%20une%20liste%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-709882%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EExiste-t-il%20un%20besoin%20sp%C3%A9cifique%20d%E2%80%99utiliser%20une%20syntaxe%20plus%20complexe%26nbsp%3B%3F%20Vous%20pouvez%20utiliser%20Loc%20avec%20Any%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(1)%3B%0A%0Adt%20%3D%20Open(%22%24SAMPLE_DATA%5CBig%20Class.jmp%22)%3B%0Adt%20%26lt%3B%26lt%3B%20Select%20Where(Any(Loc(%7B%22JANE%22%2C%20%22DAVID%22%2C%20%22PATTY%22%7D%2C%20%3Aname)))%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-709870%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%20%3A%20S%C3%A9lectionner%20les%20lignes%20qui%20correspondent%20%C3%A0%20n'importe%20quelle%20valeur%20dans%20une%20liste%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-709870%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3Em%C3%AAme%20r%C3%A9sultat%2C%20oui.%3CBR%20%2F%3E%20mais%20une%20syntaxe%20diff%C3%A9rente.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-709869%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%20%3A%20S%C3%A9lectionner%20les%20lignes%20qui%20correspondent%20%C3%A0%20n'importe%20quelle%20valeur%20dans%20une%20liste%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-709869%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EN'est-ce%20pas%20pour%20cela%20que%20vous%20utiliseriez%20Contains()%26nbsp%3B%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-709532%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%20%3A%20S%C3%A9lectionner%20les%20lignes%20qui%20correspondent%20%C3%A0%20n'importe%20quelle%20valeur%20dans%20une%20liste%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-709532%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt%20%26lt%3B%26lt%3B%20Select%20Where(%20Any(%20Row()%20%3D%3D%20Index(%203%2C%205%20)%20)%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3Ec'est%20cool%20%3CLI-EMOJI%20id%3D%22lia_slightly-smiling-face%22%20title%3D%22%3Acara_con_una_leve_sonrisa%3A%22%3E%3C%2FLI-EMOJI%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ey%20a-t-il%20quelque%20chose%20de%20similaire%20pour%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt%20%26lt%3B%26lt%3B%20Select%20Where(%20Any(%20%3Aname%20%3D%3D%20%7B%22JANE%22%2C%20%22DAVID%22%2C%22PATTY%22%7D)%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
Select rows that match any value in a list

Problem

Suppose you prompt a user to make a selection. When you retrieve the values from the user, typically they are stored in a list.  Now you need to select the data that matches the values in the list.

Solution

The following example demonstrates how you can select rows in a data table that contain any value stored in a JSL list. Lists containing either numeric values or character strings can be used and are shown below.  See the embedded comments for details.

/* Open a sample data table. */
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );

/* Create a list of ages. */
myList = {9, 12, 15, 17, 18};

/* Select all rows which have an age that is in the list. */
dt << Select Where( Contains( myList, :age ) );

Wait( 2 );           // For demonstration purposes

/* Create a list of student names. */
myStudents = {"HENRY", "ROBERT", "BARBARA", "SALLY", "MARION"};

/* Select all rows which have any of the names in the list. */
dt << Select Where( Contains( myStudents, :name ) );

Discussion

In these examples, the Contains() function is used to compare each row to the list of values.

Many more examples of using Select Where() can be found in the Select Rows section of the JMP Scripting Guide.

See Also

Select rows from the currently selected rows

Select rows based upon multiple conditions

Comments
hogi
dt << Select Where( Any( Row() == Index( 3, 5 ) ) );

is cool

 

is there something similar for

dt << Select Where( Any( :name == {"JANE", "DAVID","PATTY"}) );

?

 

jthi

Isn't that what you would use Contains() for?

hogi

same result, yes.
but different syntax.

jthi

Is there some specific need to use more complex syntax? You could use Loc with Any

Names Default To Here(1);

dt = Open("$SAMPLE_DATA\Big Class.jmp");
dt << Select Where(Any(Loc({"JANE", "DAVID", "PATTY"}, :name)));

 

hogi

Ah, nice

I feared that contains is slower. but actually ...
note to myself: use contains 

hogi_0-1702737609134.png

 

 

View more...
Names Default To Here( 1 );
Try(close(dt, noSave));
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

results = New Table( "Untitled",
	Add Rows( 0 ),
	New Column( "rows" ),
	New Column( "t_contains_string" ),
	New Column( "t_any_loc_string" ),
	New Column( "t_contains_number" ),
	New Column( "t_any_loc_number" ),
	New Column( "t_any_number" )
);

dt << New Column( "nameID", Formula( Row() ) );
dt:nameID << delete formula;

For( i = 1, i <= 20, i++,

	t0 = HP Time();
	dt << Select Where( Contains( {"JANE", "DAVID", "PATTY"}, :name ) );
	t1 = ((HP Time() - t0) / 1000000);

	t0 = HP Time();
	dt << Select Where( Any( Loc( {"JANE", "DAVID", "PATTY"}, :name ) ) );
	t2 = ((HP Time() - t0) / 1000000);

	t0 = HP Time();
	dt << Select Where( Contains( {3, 15, 20}, :nameID ) );
	t3 = ((HP Time() - t0) / 1000000);
	
	t0 = HP Time();
	dt << Select Where( Any( Loc( [3 15 20], :nameID ) ) );
	t4 = ((HP Time() - t0) / 1000000);

	t0 = HP Time();
	dt << Select Where( Any( :nameID == [3 15 20] ) );
	t5 = ((HP Time() - t0) / 1000000);

	results << add rows( {:rows = N Rows( dt ),:t_contains_string = t1, :t_any_loc_string = t2, :t_contains_number = t3, :t_any_loc_number = t4, :t_any_number = t5} );
	dt = dt << concatenate( {dt}, Append to first table );
);

 

JSL Cookbook

If you’re looking for a code snippet or design pattern that performs a common task for your JSL project, the JSL Cookbook is for you.

This knowledge base contains building blocks of JSL code that you can use to reduce the amount of coding you have to do yourself.

It's also a great place to learn from the experts how to use JSL in new ways, with best practices.