#module
#defcfunc srnd int len, int type, local types, local typee, local rstr, local code
dim types, 4 : types = '!', '0', 'A', 'a' // タイプ開始コード
dim typee, 4 : typee = '~', '9', 'Z', 'z' // タイプ終了コード
// 生成
sdim rstr, len + 1
repeat len
code = rnd(typee - types) + types // 文字コードは'!'(=33)から'~'(=126)までの93種
// 指定タイプとの照合
if ((type & 1) = 0) && (code >= types.1) && (code <= typee.1) : continue cnt
if ((type & 2) = 0) && (code >= types.2) && (code <= typee.2) : continue cnt
if ((type & 4) = 0) && (code >= types.3) && (code <= typee.3) : continue cnt
poke rstr, cnt, code
loop
return rstr
#global
randomize
repeat
redraw 0
color 255, 255, 255 : boxf : color
pos 10, 10 : mes "記号のみ"
mes "2文字パターン : " + srnd(2, 0)
mes "5文字パターン : " + srnd(5, 0)
mes "8文字パターン : " + srnd(8, 0)
pos 10, 100 : mes "記号と数字のみ"
mes "2文字パターン : " + srnd(2, 1)
mes "5文字パターン : " + srnd(5, 1)
mes "8文字パターン : " + srnd(8, 1)
pos 10, 200 : mes "記号と英大文字のみ"
mes "2文字パターン : " + srnd(2, 2)
mes "5文字パターン : " + srnd(5, 2)
mes "8文字パターン : " + srnd(8, 2)
pos 10, 300 : mes "記号と英小文字のみ"
mes "2文字パターン : " + srnd(2, 4)
mes "5文字パターン : " + srnd(5, 4)
mes "8文字パターン : " + srnd(8, 4)
pos 10, 400 : mes "記号と英字のみ"
mes "2文字パターン : " + srnd(2, 6)
mes "5文字パターン : " + srnd(5, 6)
mes "8文字パターン : " + srnd(8, 6)
redraw
wait 300
loop
|