h@43: // YML2 standardlib version 2.5.8 h@43: h@43: function "yml:hex2dec" { h@43: param "hex"; h@43: param "_result", 0; h@43: h@43: const "hd", "substring($hex, 1, 1)"; h@43: const "a", """translate($hd, 'ABCDEFabcdef123456789', h@43: '123456123456000000000')"""; h@43: h@43: const "d" choose { h@43: when "$a>0" value "$a + 9"; h@43: otherwise value "$hd"; h@43: } h@43: h@43: choose { h@43: when "string-length($hex) = 1" h@43: value "$_result * 16 + $d"; h@43: otherwise call "yml:hex2dec" h@43: with "hex", "substring($hex, 2, 8)", h@43: with "_result", "$_result * 16 + $d"; h@43: } h@43: } h@43: h@43: function "yml:dec2hex" { h@43: param "dec"; h@43: param "bits", !16**7!; h@43: h@43: const "v", "floor($dec div $bits)"; h@43: value "substring('0123456789abcdef', $v + 1, 1)"; h@43: h@43: if "$bits > 1" call "yml:dec2hex" h@43: with "dec", "$dec - $bits * $v", h@43: with "bits", "$bits div 16"; h@43: } h@43: h@43: def "yml:dec2hex" { h@43: param "dec"; h@43: param "digits", 8; h@43: h@43: result call "yml:dec2hex" with "dec", "$dec", with "bits", "math:power(16, $digits - 1)"; h@43: } h@43: h@43: def "yml:hex2dec" { h@43: param "hex"; h@43: result call "yml:hex2dec" with "hex", "$hex"; h@43: } h@43: h@43: def "yml:lcase" { h@43: param "text", "''"; h@43: result "translate($text, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"; h@43: } h@43: h@43: def "yml:ucase" { h@43: param "text", "''"; h@43: result "translate($text, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"; h@43: } h@43: h@43: def "yml:mixedCase" { h@43: param "text", "''"; h@43: result "concat(yml:lcase(substring($text,1,1)),substring($text,2))"; h@43: } h@43: h@43: def "yml:capit" { h@43: param "text", "''"; h@43: result "concat(yml:ucase(substring($text,1,1)),substring($text,2))"; h@43: } h@43: