Registration Code.

I made a little script that makes a registration code such as “DIY0-068W-W4CR-R5AA”.

set randomString to randomString_(4)
on randomString_(anumb)
	set randomChars to {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}
	set aString to ""
	set thestring to ""
	repeat (anumb * 4) times
		set aString to aString & some item of randomChars
	end repeat
	set numb to 0
	repeat anumb times
		set numb to numb + 1
		if numb is not anumb then
			set thestring to thestring & text beginning thru 4 of aString & "-"
		else
			set thestring to thestring & text beginning thru 4 of aString
		end if
		set aString to text 4 thru end of aString
	end repeat
	return thestring
end randomString_

Hi,

nice script.
But two repeat loops are not needed


set randomString to randomString_()
on randomString_()
	set randomChars to {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}
	set aString to ""
	repeat with i from 1 to 16
		set aString to aString & some item of randomChars
		if i < 16 and i mod 4 = 0 then set aString to aString & "-"
	end repeat
	return aString
end randomString_