function getCode(chars: string, length: integer=3, separator: string="") :: string: set {_code} to "" set {_percent::*} to {_chars} split at "," set {_count} and {_last} to 0 loop {_percent::*}: if loop-value contains "%%": set {_split::*} to loop-value split at "%%" if size of {_split::*} > 2: return "&cError: %loop-value%" if {_split::1} parsed as number is a number: set {_between::%{_split::2}%::start} to {_last} add ({_split::1} parsed as number) to {_count} set {_between::%{_split::2}%::end} to {_count} set {_last} to {_count} + 0.001 set {_between::%{_split::2}%::character} to {_split::2} else: set {_between::%loop-value%::start} to {_last} add 100 to {_count} set {_between::%loop-value%::end} to {_count} set {_last} to {_count} + 0.001 set {_between::%loop-value%::character} to loop-value loop {_length} times: set {_random} to random number between 0 and {_count} set {_indexes::*} to indexes of {_between::*} loop {_indexes::*}: if {_random} is between {_between::%loop-value-2%::start} and {_between::%loop-value-2%::end}: set {_value} to loop-value-2 replace "[procent]" and "[percent]" with "%%" in {_between::%loop-value-2%::character} replace "[przecinek]" and "[comma]" with "," in {_between::%loop-value-2%::character} if {_length} is loop-number: set {_code} to "%{_code}%%{_between::%loop-value-2%::character}%" else: set {_code} to "%{_code}%%{_between::%loop-value-2%::character}%%{_separator}%" stop loop return {_code}