A function returning atomic number Z from standard atomic weight can be like below: (tested working for the first #83 atoms. Not working for specific isotopes!)
fn Z_from_AW(Atomic_Weight) { return
If( And ( Atomic_Weight > 1.00794 - 0.05 , Atomic_Weight < 1.00794 + 0.05 ) , 1 ,
If( And ( Atomic_Weight > 4.002602 - 0.05 , Atomic_Weight < 4.002602 + 0.05 ) , 2 ,
If( And ( Atomic_Weight > 6.941 - 0.05 , Atomic_Weight < 6.941 + 0.05 ) , 3 ,
If( And ( Atomic_Weight > 9.012182 - 0.05 , Atomic_Weight < 9.012182 + 0.05 ) , 4 ,
If( And ( Atomic_Weight > 10.811 - 0.05 , Atomic_Weight < 10.811 + 0.05 ) , 5 ,
If( And ( Atomic_Weight > 12.0107 - 0.05 , Atomic_Weight < 12.0107 + 0.05 ) , 6 ,
If( And ( Atomic_Weight > 14.0067 - 0.05 , Atomic_Weight < 14.0067 + 0.05 ) , 7 ,
If( And ( Atomic_Weight > 15.9994 - 0.05 , Atomic_Weight < 15.9994 + 0.05 ) , 8 ,
If( And ( Atomic_Weight > 18.9984032 - 0.05 , Atomic_Weight < 18.9984032 + 0.05 ) , 9 ,
If( And ( Atomic_Weight > 20.1797 - 0.05 , Atomic_Weight < 20.1797 + 0.05 ) , 10 ,
If( And ( Atomic_Weight > 22.98977 - 0.05 , Atomic_Weight < 22.98977 + 0.05 ) , 11 ,
If( And ( Atomic_Weight > 24.305 - 0.05 , Atomic_Weight < 24.305 + 0.05 ) , 12 ,
If( And ( Atomic_Weight > 26.981538 - 0.05 , Atomic_Weight < 26.981538 + 0.05 ) , 13 ,
If( And ( Atomic_Weight > 28.0855 - 0.05 , Atomic_Weight < 28.0855 + 0.05 ) , 14 ,
If( And ( Atomic_Weight > 30.973761 - 0.05 , Atomic_Weight < 30.973761 + 0.05 ) , 15 ,
If( And ( Atomic_Weight > 32.065 - 0.05 , Atomic_Weight < 32.065 + 0.05 ) , 16 ,
If( And ( Atomic_Weight > 35.453 - 0.05 , Atomic_Weight < 35.453 + 0.05 ) , 17 ,
If( And ( Atomic_Weight > 39.948 - 0.05 , Atomic_Weight < 39.948 + 0.05 ) , 18 ,
If( And ( Atomic_Weight > 39.0983 - 0.05 , Atomic_Weight < 39.0983 + 0.05 ) , 19 ,
If( And ( Atomic_Weight > 40.078 - 0.05 , Atomic_Weight < 40.078 + 0.05 ) , 20 ,
If( And ( Atomic_Weight > 44.95591 - 0.05 , Atomic_Weight < 44.95591 + 0.05 ) , 21 ,
If( And ( Atomic_Weight > 47.867 - 0.05 , Atomic_Weight < 47.867 + 0.05 ) , 22 ,
If( And ( Atomic_Weight > 50.9415 - 0.05 , Atomic_Weight < 50.9415 + 0.05 ) , 23 ,
If( And ( Atomic_Weight > 51.9961 - 0.05 , Atomic_Weight < 51.9961 + 0.05 ) , 24 ,
If( And ( Atomic_Weight > 54.938049 - 0.05 , Atomic_Weight < 54.938049 + 0.05 ) , 25 ,
If( And ( Atomic_Weight > 55.845 - 0.05 , Atomic_Weight < 55.845 + 0.05 ) , 26 ,
If( And ( Atomic_Weight > 58.9332 - 0.05 , Atomic_Weight < 58.9332 + 0.05 ) , 27 ,
If( And ( Atomic_Weight > 58.6934 - 0.05 , Atomic_Weight < 58.6934 + 0.05 ) , 28 ,
If( And ( Atomic_Weight > 63.546 - 0.05 , Atomic_Weight < 63.546 + 0.05 ) , 29 ,
If( And ( Atomic_Weight > 65.409 - 0.05 , Atomic_Weight < 65.409 + 0.05 ) , 30 ,
If( And ( Atomic_Weight > 69.723 - 0.05 , Atomic_Weight < 69.723 + 0.05 ) , 31 ,
If( And ( Atomic_Weight > 72.64 - 0.05 , Atomic_Weight < 72.64 + 0.05 ) , 32 ,
If( And ( Atomic_Weight > 74.9216 - 0.05 , Atomic_Weight < 74.9216 + 0.05 ) , 33 ,
If( And ( Atomic_Weight > 78.96 - 0.05 , Atomic_Weight < 78.96 + 0.05 ) , 34 ,
If( And ( Atomic_Weight > 79.904 - 0.05 , Atomic_Weight < 79.904 + 0.05 ) , 35 ,
If( And ( Atomic_Weight > 83.798 - 0.05 , Atomic_Weight < 83.798 + 0.05 ) , 36 ,
If( And ( Atomic_Weight > 85.4678 - 0.05 , Atomic_Weight < 85.4678 + 0.05 ) , 37 ,
If( And ( Atomic_Weight > 87.62 - 0.05 , Atomic_Weight < 87.62 + 0.05 ) , 38 ,
If( And ( Atomic_Weight > 88.90585 - 0.05 , Atomic_Weight < 88.90585 + 0.05 ) , 39 ,
If( And ( Atomic_Weight > 91.224 - 0.05 , Atomic_Weight < 91.224 + 0.05 ) , 40 ,
If( And ( Atomic_Weight > 92.90638 - 0.05 , Atomic_Weight < 92.90638 + 0.05 ) , 41 ,
If( And ( Atomic_Weight > 95.94 - 0.05 , Atomic_Weight < 95.94 + 0.05 ) , 42 ,
If( And ( Atomic_Weight > 98 - 0.05 , Atomic_Weight < 98 + 0.05 ) , 43 ,
If( And ( Atomic_Weight > 101.07 - 0.05 , Atomic_Weight < 101.07 + 0.05 ) , 44 ,
If( And ( Atomic_Weight > 102.9055 - 0.05 , Atomic_Weight < 102.9055 + 0.05 ) , 45 ,
If( And ( Atomic_Weight > 106.42 - 0.05 , Atomic_Weight < 106.42 + 0.05 ) , 46 ,
If( And ( Atomic_Weight > 107.8682 - 0.05 , Atomic_Weight < 107.8682 + 0.05 ) , 47 ,
If( And ( Atomic_Weight > 112.411 - 0.05 , Atomic_Weight < 112.411 + 0.05 ) , 48 ,
If( And ( Atomic_Weight > 114.818 - 0.05 , Atomic_Weight < 114.818 + 0.05 ) , 49 ,
If( And ( Atomic_Weight > 118.71 - 0.05 , Atomic_Weight < 118.71 + 0.05 ) , 50 ,
If( And ( Atomic_Weight > 121.76 - 0.05 , Atomic_Weight < 121.76 + 0.05 ) , 51 ,
If( And ( Atomic_Weight > 127.6 - 0.05 , Atomic_Weight < 127.6 + 0.05 ) , 52 ,
If( And ( Atomic_Weight > 126.90447 - 0.05 , Atomic_Weight < 126.90447 + 0.05 ) , 53 ,
If( And ( Atomic_Weight > 131.293 - 0.05 , Atomic_Weight < 131.293 + 0.05 ) , 54 ,
If( And ( Atomic_Weight > 132.90545 - 0.05 , Atomic_Weight < 132.90545 + 0.05 ) , 55 ,
If( And ( Atomic_Weight > 137.327 - 0.05 , Atomic_Weight < 137.327 + 0.05 ) , 56 ,
If( And ( Atomic_Weight > 138.9055 - 0.05 , Atomic_Weight < 138.9055 + 0.05 ) , 57 ,
If( And ( Atomic_Weight > 140.116 - 0.05 , Atomic_Weight < 140.116 + 0.05 ) , 58 ,
If( And ( Atomic_Weight > 140.90765 - 0.05 , Atomic_Weight < 140.90765 + 0.05 ) , 59 ,
If( And ( Atomic_Weight > 144.24 - 0.05 , Atomic_Weight < 144.24 + 0.05 ) , 60 ,
If( And ( Atomic_Weight > 145 - 0.05 , Atomic_Weight < 145 + 0.05 ) , 61 ,
If( And ( Atomic_Weight > 150.36 - 0.05 , Atomic_Weight < 150.36 + 0.05 ) , 62 ,
If( And ( Atomic_Weight > 151.964 - 0.05 , Atomic_Weight < 151.964 + 0.05 ) , 63 ,
If( And ( Atomic_Weight > 157.25 - 0.05 , Atomic_Weight < 157.25 + 0.05 ) , 64 ,
If( And ( Atomic_Weight > 158.92534 - 0.05 , Atomic_Weight < 158.92534 + 0.05 ) , 65 ,
If( And ( Atomic_Weight > 162.5 - 0.05 , Atomic_Weight < 162.5 + 0.05 ) , 66 ,
If( And ( Atomic_Weight > 164.93032 - 0.05 , Atomic_Weight < 164.93032 + 0.05 ) , 67 ,
If( And ( Atomic_Weight > 167.259 - 0.05 , Atomic_Weight < 167.259 + 0.05 ) , 68 ,
If( And ( Atomic_Weight > 168.93421 - 0.05 , Atomic_Weight < 168.93421 + 0.05 ) , 69 ,
If( And ( Atomic_Weight > 173.04 - 0.05 , Atomic_Weight < 173.04 + 0.05 ) , 70 ,
If( And ( Atomic_Weight > 174.967 - 0.05 , Atomic_Weight < 174.967 + 0.05 ) , 71 ,
If( And ( Atomic_Weight > 178.49 - 0.05 , Atomic_Weight < 178.49 + 0.05 ) , 72 ,
If( And ( Atomic_Weight > 180.9479 - 0.05 , Atomic_Weight < 180.9479 + 0.05 ) , 73 ,
If( And ( Atomic_Weight > 183.84 - 0.05 , Atomic_Weight < 183.84 + 0.05 ) , 74 ,
If( And ( Atomic_Weight > 186.207 - 0.05 , Atomic_Weight < 186.207 + 0.05 ) , 75 ,
If( And ( Atomic_Weight > 190.23 - 0.05 , Atomic_Weight < 190.23 + 0.05 ) , 76 ,
If( And ( Atomic_Weight > 192.217 - 0.05 , Atomic_Weight < 192.217 + 0.05 ) , 77 ,
If( And ( Atomic_Weight > 195.078 - 0.05 , Atomic_Weight < 195.078 + 0.05 ) , 78 ,
If( And ( Atomic_Weight > 196.96655 - 0.05 , Atomic_Weight < 196.96655 + 0.05 ) , 79 ,
If( And ( Atomic_Weight > 200.59 - 0.05 , Atomic_Weight < 200.59 + 0.05 ) , 80 ,
If( And ( Atomic_Weight > 204.3833 - 0.05 , Atomic_Weight < 204.3833 + 0.05 ) , 81 ,
If( And ( Atomic_Weight > 207.2 - 0.05 , Atomic_Weight < 207.2 + 0.05 ) , 82 ,
If( And ( Atomic_Weight > 208.98038 - 0.05 , Atomic_Weight < 208.98038 + 0.05 ) , 83 , 0
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
;}