himorogiの日記

主にプログラミングに関することなど。少々ハード(電子工作)についても。

おまけ:numbers の生成

スクリプトエディタ版

app = Application.currentApplication();
app.includeStandardAdditions =true;

function numbers(x){
	return ( "0000" + Math.floor( Math.random()*Math.pow(10,x) ) ).substr(-x)
}
app.displayAlert( numbers( 3 ) + String.fromCharCode(13) + numbers( 4 ) );

Automator

function run() {	
	function numbers(x){
		return ( "0000" + Math.floor( Math.random()*Math.pow(10,x) ) ).substr(-x)
	}
	return numbers(3) + String.fromCharCode(13) + numbers(4);
}

結果は省略