cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
%3CLINGO-SUB%20id%3D%22lingo-sub-236892%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E9%80%A3%E6%83%B3%E9%85%8D%E5%88%97%E3%81%AE%E8%A6%81%E7%B4%A0%E3%82%92%E3%83%AB%E3%83%BC%E3%83%97%E3%81%99%E3%82%8B%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-236892%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CDIV%20class%3D%22lia-message-template-problem-zone%22%3E%E5%95%8F%E9%A1%8C%3CP%3E%E9%80%A3%E6%83%B3%E9%85%8D%E5%88%97%E5%86%85%E3%81%AE%E3%81%99%E3%81%B9%E3%81%A6%E3%81%AE%E8%A6%81%E7%B4%A0%E3%82%92%E7%A2%BA%E8%AA%8D%E3%81%99%E3%82%8B%E5%BF%85%E8%A6%81%E3%81%8C%E3%81%82%E3%82%8A%E3%81%BE%E3%81%99%3C%2FP%3E%3C%2FDIV%3E%3CDIV%20class%3D%22lia-message-template-diagnosis-zone%22%3E%E8%A7%A3%E6%B1%BA%3CP%3E%26lt%3B%3CFIRST%20%E3%83%A1%E3%83%83%E3%82%BB%E3%83%BC%E3%82%B8%E3%81%A8%3D%22%22%3E%26lt%3B%3CNEXT%20%E3%83%A1%E3%83%83%E3%82%BB%E3%83%BC%E3%82%B8%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%99%E3%82%8B%3D%22%22%3E%3C%2FNEXT%3E%3C%2FFIRST%3E%3C%2FP%3E%3CBR%20%2F%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3E%2F%2F%20load%20a%20table%20of%20elements%0Adt%20%3D%20Open(%20%22https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FList_of_chemical_elements%22%2C%20HTML%20Table(%204%2C%20Column%20Names(%202%20)%2C%20Data%20Starts(%205%20)%20)%20)%3B%0A%2F%2F%20make%20an%20associative%20array%20using%20%22H%22%20to%20lookup%20%22Hydrogen%22%20and%20some%20of%20its%20properties%0Amap_Symbol_To_Data%20%3D%20Associative%20Array(%20dt%5B1%20%3A%3A%20118%2C%20%22Symbol%22%5D%2C%20dt%5B1%20%3A%3A%20118%2C%20%5B3%2F*element%20name*%2F%2C%201%2F*element%20number*%2F%2C%207%2F*atomic%20weight*%2F%5D%5D%20)%3B%0A%2F%2F%20close%20the%20table%0AClose(%20dt%2C%20nosave%20)%3B%0A%0A%2F%2F%20loop%20through%20the%20keys%20using%20%26lt%3B%3CFIRST%20and%3D%22%22%3E%26lt%3B%3CNEXT%20for%3D%22%22%3E%3C%2FNEXT%3E%3C%2FFIRST%3E%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FDIV%3E%3CDIV%20class%3D%22lia-message-template-solution-zone%22%3E%E8%AD%B0%E8%AB%96%3CP%3E%E4%B8%8A%E3%81%AE%E4%B8%AD%E5%A4%AE%E3%81%AE%E3%83%96%E3%83%AD%E3%83%83%E3%82%AF%E3%81%AF%E3%80%81aa%26lt%3B%3CFIRST%20%E3%83%A1%E3%83%83%E3%82%BB%E3%83%BC%E3%82%B8%E3%81%A8%3D%22%22%20aa%3D%22%22%3E%26lt%3B%3CNEXT%20%E3%83%A1%E3%83%83%E3%82%BB%E3%83%BC%E3%82%B8%3D%22%22%3E%3C%2FNEXT%3E%3C%2FFIRST%3E%3C%2FP%3E%3CP%3E%26lt%3B%3CFIRST%3E%3CBR%20%2F%3E%E9%96%A2%E9%80%A3%E9%A0%85%E7%9B%AE%3C%2FFIRST%3E%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fwww.jmp.com%2Fsupport%2Fhelp%2F14-2%2Fcreate-associative-arrays.shtml%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.jmp.com%2Fsupport%2Fhelp%2F14-2%2Fcreate-associative-arrays.shtml%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-440312%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20%E9%80%A3%E6%83%B3%E9%85%8D%E5%88%97%E3%81%AE%E8%A6%81%E7%B4%A0%E3%82%92%E3%83%AB%E3%83%BC%E3%83%97%E3%81%99%E3%82%8B%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-440312%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E3%81%82%E3%82%8A%E3%81%8C%E3%81%A8%E3%81%86%EF%BC%81%3C%2FP%3E%0A%3CP%3E%E3%81%AA%E3%81%9C%E5%A4%89%E6%9B%B4%E3%81%97%E3%81%9F%E3%81%AE%E3%81%8B%E7%96%91%E5%95%8F%E3%81%AB%E6%80%9D%E3%81%84%E3%81%BE%E3%81%97%E3%81%9F%E3%80%82%20%E3%82%A6%E3%82%A3%E3%82%AD%E3%83%9A%E3%83%87%E3%82%A3%E3%82%A2%E3%81%AB%E3%81%AF%3CA%20href%3D%22https%3A%2F%2Fen.wikipedia.org%2Fw%2Findex.php%3Ftitle%3DList_of_chemical_elements%26amp%3Baction%3Dhistory%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%E5%81%89%E5%A4%A7%E3%81%AA%E6%AD%B4%E5%8F%B2%3C%2FA%3E%E3%80%81%E3%80%9C30jun2021%E3%81%AE%E3%82%88%E3%81%86%E3%81%A7%E3%81%99%E3%80%82%20%E3%81%BE%E3%81%9F%E3%80%81%3CA%20href%3D%22https%3A%2F%2Fen.wikipedia.org%2Fw%2Findex.php%3Ftitle%3DList_of_chemical_elements%26amp%3Boldid%3D1031067113%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%E5%8F%A4%E3%81%84%E3%83%9A%E3%83%BC%E3%82%B8%3C%2FA%3E%E3%80%81%E4%BB%A5%E5%89%8D%E3%81%AF%E3%81%A9%E3%81%86%E3%81%A0%E3%81%A3%E3%81%9F%E3%81%8B%E7%96%91%E5%95%8F%E3%81%AB%E6%80%9D%E3%81%86%E5%A0%B4%E5%90%88%E3%81%A7%E3%82%82%E3%80%81%E3%81%93%E3%82%8C%E3%81%AF%E3%81%BE%E3%81%A0%E6%A9%9F%E8%83%BD%E3%81%97%E3%81%BE%E3%81%99%E3%80%82%3C%2FP%3E%0A%3CP%3E%E5%85%83%E3%81%AE%E3%82%B3%E3%83%BC%E3%83%89%E3%81%A7%E3%81%AF%E3%80%81%E5%88%97%E7%95%AA%E5%8F%B7%E3%81%A8%E5%88%97%E5%90%8D%E3%81%AE%E7%B5%84%E3%81%BF%E5%90%88%E3%82%8F%E3%81%9B%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%A6%E3%81%84%E3%81%BE%E3%81%97%E3%81%9F%E3%80%82%20%E3%81%9D%E3%82%8C%E3%81%AF%E8%89%AF%E3%81%84%E3%81%93%E3%81%A8%E3%82%82%E6%82%AA%E3%81%84%E3%81%93%E3%81%A8%E3%82%82%E3%81%82%E3%82%8B%E3%80%81%E3%81%A8%E6%80%9D%E3%81%84%E3%81%BE%E3%81%99%E3%80%82%20%E6%95%B0%E5%80%A4%E3%81%A8%E3%81%97%E3%81%A6%E3%81%AF%E5%95%8F%E9%A1%8C%E3%81%82%E3%82%8A%E3%81%BE%E3%81%9B%E3%82%93%E3%81%A7%E3%81%97%E3%81%9F%E3%81%8C%E3%80%81%E5%B0%91%E3%81%AA%E3%81%8F%E3%81%A8%E3%82%82%E5%90%8D%E5%89%8D%E4%BB%98%E3%81%8D%E5%88%97%E3%81%AF%E5%A4%B1%E6%95%97%E3%81%97%E3%81%BE%E3%81%97%E3%81%9F%E3%80%82%20%E3%81%97%E3%81%8B%E3%81%97%E3%80%81%E3%81%9D%E3%81%AE%E5%A0%B4%E5%90%88%E3%80%81%E3%82%AB%E3%83%A9%E3%83%A0%207%20%E3%81%BE%E3%81%9F%E3%81%AF%208%20%E3%81%AF%E3%80%81%E9%96%93%E9%81%95%E3%81%A3%E3%81%9F%E3%82%AB%E3%83%A9%E3%83%A0%E3%81%8B%E3%82%89%E3%81%AE%E4%B8%8D%E6%AD%A3%E3%81%AA%E5%8E%9F%E5%AD%90%E9%87%8F%E3%81%AB%E3%82%88%E3%82%8A%E3%80%81%E9%9D%99%E3%81%8B%E3%81%AB%E5%A4%B1%E6%95%97%E3%81%97%E3%81%9F%E3%82%8A%E5%8B%95%E4%BD%9C%E3%81%97%E3%81%9F%E3%82%8A%E3%81%97%E3%81%A6%E3%81%84%E3%82%8B%E5%8F%AF%E8%83%BD%E6%80%A7%E3%81%8C%E3%81%82%E3%82%8A%E3%81%BE%E3%81%99%E3%80%82%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-440300%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20%E9%80%A3%E6%83%B3%E9%85%8D%E5%88%97%E3%81%AE%E8%A6%81%E7%B4%A0%E3%82%92%E3%83%AB%E3%83%BC%E3%83%97%E3%81%99%E3%82%8B%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-440300%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%E3%81%82%E3%82%8A%E3%81%8C%E3%81%A8%E3%81%86%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F982%22%20target%3D%22_blank%22%3E%40Craige_Hales%3C%2FA%3E%E5%BD%B9%E7%AB%8B%E3%81%A4%E3%83%87%E3%83%A2%E3%83%B3%E3%82%B9%E3%83%88%E3%83%AC%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%81%AE%E3%81%9F%E3%82%81%E3%81%AB%E3%80%82%3C%2FP%3E%0A%3CP%3E%E3%81%93%E3%81%AE%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%97%E3%83%88%E3%82%92%E8%A9%A6%E3%81%97%E3%81%A6%E3%81%BF%E3%82%8B%E3%81%A8%E3%80%81Wikipedia%20%E3%81%8C%E3%83%86%E3%83%BC%E3%83%96%E3%83%AB%E3%82%92%E6%9B%B4%E6%96%B0%E3%81%97%E3%81%A6%E3%80%81%E9%80%A3%E6%83%B3%E9%85%8D%E5%88%97%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%81%8C%E3%82%A8%E3%83%A9%E3%83%BC%E3%82%92%E8%BF%94%E3%81%99%E3%82%88%E3%81%86%E3%81%AB%E3%81%AA%E3%81%A3%E3%81%A6%E3%81%84%E3%82%8B%E3%81%93%E3%81%A8%E3%81%AB%E6%B0%97%E4%BB%98%E3%81%8D%E3%81%BE%E3%81%97%E3%81%9F%E3%80%82%3C%2FP%3E%0A%3CP%3E%E9%80%A3%E6%83%B3%E9%85%8D%E5%88%97%E3%82%92%E6%AD%A3%E3%81%97%E3%81%8F%E7%94%9F%E6%88%90%E3%81%99%E3%82%8B%E3%81%AB%E3%81%AF%E3%80%81%E3%81%93%E3%82%8C%E3%82%92%E5%AE%9F%E8%A1%8C%E3%81%99%E3%82%8B%E5%BF%85%E8%A6%81%E3%81%8C%E3%81%82%E3%82%8B%E8%A1%8C%E3%81%A0%E3%81%A8%E6%80%9D%E3%81%84%E3%81%BE%E3%81%99%E3%80%82%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Emap_Symbol_To_Data%20%3D%20Associative%20Array(%20dt%5B1%20%3A%3A%20118%2C%20%22Element%202%22%5D%2C%20dt%5B1%20%3A%3A%20118%2C%20%5B3%2F*element%20name*%2F%2C%201%2F*element%20number*%2F%2C%208%2F*atomic%20weight*%2F%5D%5D%20)%3B%0A%26nbsp%3B%26nbsp%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-381699%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20%E9%80%A3%E6%83%B3%E9%85%8D%E5%88%97%E3%81%AE%E8%A6%81%E7%B4%A0%E3%82%92%E3%83%AB%E3%83%BC%E3%83%97%E3%81%99%E3%82%8B%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-381699%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Esym%20%3D%20map_Symbol_To_Data%20%26lt%3B%26lt%3B%20first%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%E6%9C%80%E5%88%9D%E3%81%AE%E3%82%AD%E3%83%BC%E3%82%92%E5%8F%96%E5%BE%97%E3%81%97%E3%81%BE%E3%81%99%E3%80%82%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Esym%20%3D%20map_Symbol_To_Data%20%26lt%3B%26lt%3B%20next(%20sym%20)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%E7%8F%BE%E5%9C%A8%E3%81%AE%E3%82%AD%E3%83%BC%E3%81%AE%E5%BE%8C%E3%81%AE%E3%82%AD%E3%83%BC%E3%82%92%E5%8F%96%E5%BE%97%E3%81%97%E3%81%BE%E3%81%99%E3%80%82%3CEM%3E%E3%82%B7%E3%83%A0%3C%2FEM%3E%E3%80%82%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EJSL%20%E5%A4%89%E6%95%B0%E3%80%81%E9%96%A2%E6%95%B0%E3%80%81%E3%83%A1%E3%82%BD%E3%83%83%E3%83%89%E3%81%A7%E3%81%AF%E5%A4%A7%E6%96%87%E5%AD%97%E3%81%AF%E9%87%8D%E8%A6%81%E3%81%A7%E3%81%AF%E3%81%82%E3%82%8A%E3%81%BE%E3%81%9B%E3%82%93%E3%80%82%20%E3%81%9F%E3%81%A0%E3%81%97%E3%80%81%E5%AE%9F%E9%9A%9B%E3%81%AE%E3%82%AD%E3%83%BC%E5%80%A4%E3%81%AB%E3%81%A8%E3%81%A3%E3%81%A6%E3%81%AF%E9%87%8D%E8%A6%81%E3%81%A7%E3%81%99%E3%80%82%20sym%3D%22A%22%20%E3%81%A8%20sym%3D%22a%22%20%E3%81%AF%202%20%E3%81%A4%E3%81%AE%E7%95%B0%E3%81%AA%E3%82%8B%E3%82%AD%E3%83%BC%E3%81%A7%E3%81%99%E3%80%82%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Emap_Symbol_To_Data%5Bsym%5D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%E9%80%A3%E6%83%B3%E9%85%8D%E5%88%97%E5%86%85%E3%81%AE%20sym%20%E5%80%A4%E3%82%92%E6%A4%9C%E7%B4%A2%E3%81%97%E3%81%BE%E3%81%99%E3%80%82%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Emap_symbol_to_data%20%E3%81%AF%E3%80%81%E9%80%A3%E6%83%B3%E9%85%8D%E5%88%97%E3%81%8C%E3%82%B7%E3%83%B3%E3%83%9C%E3%83%AB%20(sym%E3%80%81%E3%82%AD%E3%83%BC)%20%E3%81%AE%E3%83%87%E3%83%BC%E3%82%BF%E5%80%A4%E3%81%B8%E3%81%AE%E3%83%9E%E3%83%83%E3%83%94%E3%83%B3%E3%82%B0%E3%81%A7%E3%81%82%E3%82%8B%E3%81%93%E3%81%A8%E3%82%92%E7%A4%BA%E3%81%99%E3%81%93%E3%81%A8%E3%81%AB%E3%81%AA%E3%81%A3%E3%81%A6%E3%81%84%E3%81%BE%E3%81%99%E3%80%82%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-381693%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20%E9%80%A3%E6%83%B3%E9%85%8D%E5%88%97%E3%81%AE%E8%A6%81%E7%B4%A0%E3%82%92%E3%83%AB%E3%83%BC%E3%83%97%E3%81%99%E3%82%8B%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-381693%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E6%9C%80%E5%88%9D%E3%81%AE%E3%83%A1%E3%82%BD%E3%83%83%E3%83%89%20(First%E3%80%81Next)%20%E3%81%AF%E3%80%81%E9%80%A3%E6%83%B3%E9%85%8D%E5%88%97%E3%81%AE%E3%82%AD%E3%83%BC%E3%81%BE%E3%81%9F%E3%81%AF%E5%80%A4%E3%82%92%E3%83%AB%E3%83%BC%E3%83%97%E3%81%97%E3%81%BE%E3%81%99%E3%81%8B%3F%20%E3%81%BE%E3%81%9F%E3%80%81%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%97%E3%83%88%20%E3%82%A4%E3%83%B3%E3%83%87%E3%83%83%E3%82%AF%E3%82%B9%E3%81%AB%E3%81%AF%E3%82%B9%E3%83%9A%E3%83%AB%E3%81%AE%E4%B8%8D%E4%B8%80%E8%87%B4%E3%81%8C%E3%81%82%E3%82%8A%E3%81%BE%E3%81%99%E3%80%82%E6%9C%80%E5%88%9D%E3%81%AF%20First%20%E3%81%8C%E5%A4%A7%E6%96%87%E5%AD%97%E3%81%AB%E3%81%AA%E3%81%A3%E3%81%A6%E3%81%84%E3%81%BE%E3%81%9B%E3%82%93%E3%81%8C%E3%80%81%E3%81%9D%E3%81%AE%E5%BE%8C%E3%81%AF%E4%B8%8B%E3%81%AE%E3%81%BB%E3%81%86%E3%81%AB%E3%81%AA%E3%82%8B%E3%81%9F%E3%82%81%E3%80%81%E5%A4%A7%E6%96%87%E5%AD%97%E3%81%AB%E3%81%99%E3%82%8B%E5%BF%85%E8%A6%81%E3%81%8C%E3%81%82%E3%82%8B%E3%81%8B%E3%81%A9%E3%81%86%E3%81%8B%E3%82%8F%E3%81%8B%E3%82%8A%E3%81%BE%E3%81%9B%E3%82%93%E3%80%82%20%E3%81%9D%E3%81%86%E3%81%82%E3%82%8B%E3%81%B9%E3%81%8D%E3%81%A7%E3%81%97%E3%82%87%E3%81%86%E3%81%8B%EF%BC%9F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-237918%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20%E9%80%A3%E6%83%B3%E9%85%8D%E5%88%97%E3%81%AE%E8%A6%81%E7%B4%A0%E3%82%92%E3%83%AB%E3%83%BC%E3%83%97%E3%81%99%E3%82%8B%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-237918%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3Efor%20%E3%83%AB%E3%83%BC%E3%83%97%E3%81%AE%E8%B3%A2%E3%81%84%E4%BD%BF%E3%81%84%E6%96%B9%E3%80%82%E7%A7%81%E3%81%AF%E3%81%93%E3%82%8C%E3%81%BE%E3%81%A7%E9%80%A3%E6%83%B3%E9%85%8D%E5%88%97%E3%81%A7%20while%20%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%9F%E3%81%93%E3%81%A8%E3%81%97%E3%81%8B%E3%81%82%E3%82%8A%E3%81%BE%E3%81%9B%E3%82%93%E3%81%A7%E3%81%97%E3%81%9F%E3%80%82%E3%81%93%E3%82%8C%E3%81%AF%E8%A9%A6%E3%81%97%E3%81%A6%E3%81%BF%E3%82%8B%E3%81%97%E3%81%8B%E3%81%82%E3%82%8A%E3%81%BE%E3%81%9B%E3%82%93%E3%80%82%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
Looping through an Associative Array's elements
Problem

You need to look at every element in an Associative Array

Solution

use the <<First and <<Next messages


// load a table of elements
dt = Open( "https://en.wikipedia.org/wiki/List_of_chemical_elements", HTML Table( 4, Column Names( 2 ), Data Starts( 5 ) ) );
// make an associative array using "H" to lookup "Hydrogen" and some of its properties
map_Symbol_To_Data = Associative Array( dt[1 :: 118, "Symbol"], dt[1 :: 118, [3/*element name*/, 1/*element number*/, 7/*atomic weight*/]] );
// close the table
Close( dt, nosave );

// loop through the keys using <<FIRST and <<NEXT
For( sym = map_Symbol_To_Data << first, !Is Empty( sym ), sym = map_Symbol_To_Data << next( sym ),
	// print the symbol and look up the related data 
	Write( "\!n", sym, " ", map_Symbol_To_Data[sym] )
);

// another way to loop through them; this requires duplicating the data
keys = map_Symbol_To_Data << getkeys;
values = map_Symbol_To_Data << getvalues;
// loop through the pair of lists using an index
For( ikey = 1, ikey <= N Items( keys ), ikey += 1,
	sym = keys[ikey];
	Write( "\!n", sym, " ", values[ikey] );
	// also, you don't have to use a list of values, 
	// you could use the key to look it up:
	Write( "\!n", sym, " ", map_Symbol_To_Data[sym] );
);
Discussion

The middle block above demonstrates the aa<<First and aa<<Next messages, and the IsEmpty test. Sending the aa<<First message to the associative array object returns the first key. The aa<<Next(prev key) returns the next key in the sequence.

The <<first, <<next technique can streamline the JSL a lot by not introducing unneeded variables. The third block introduces three extra variables and some copying. Creating the two lists may make sense if you need them anyway or will use them several times. The lookups in the associative array are slower than indexing into the list.


See Also

https://www.jmp.com/support/help/14-2/create-associative-arrays.shtml 

 

Comments
johnmoore

Clever use of a for loop.  I have only used  while's with associative arrays before.  I will have to try this.

mostarr

Does the first method (First, Next) loop through the keys or the values of the associative array? Also, in the Scripting Index, there is a spelling inconsistency--at first First is not capitalized, then it is lower down, so I don't know if it should be capitalized or not. Should it be?

sym = map_Symbol_To_Data << first

retrieves the first key.

sym = map_Symbol_To_Data << next( sym )

retrieves the key after the current key in sym.

 

Capitalization is not important for jsl variables, functions, or methods. It is important for the actual key value however. sym="A" and sym="a" are two distinct keys.

 

map_Symbol_To_Data[sym]

looks up the sym value in the associative array.

 

map_symbol_to_data is supposed to indicate the associative array is a mapping of symbols (sym, the keys) to data values.

 

 

ron_horne

 

Thank you @Craige_Hales  for the useful demonstration.

When trying this script i have noticed that Wikipedia has updated the table such that the associative array command returns an error.

I think this is the line that needs to be run if for the associative array to be produced correctly.

 

map_Symbol_To_Data = Associative Array( dt[1 :: 118, "Element 2"], dt[1 :: 118, [3/*element name*/, 1/*element number*/, 8/*atomic weight*/]] );
  

 

Thanks!

which left me wondering, why the change? Wikipedia has great history, looks like ~30jun2021. It also has the old page, which still works if you wonder what it used to look like.

The original code used a mix'n'match of column numbers and column names. That's good and bad, I guess. At least the named column failed, though it would have been fine as a number. But then column 7 or 8 might have been silently failing/working with a bad atomic weight from the wrong column.

 

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.