読者です 読者をやめる 読者になる 読者になる

k_ikiの雑記帳

DTPのこと、創作のことなど、思いつくまま

ダイアロググループについて その3

前回と前々回のつづき。
のひひ様作成のスクリプトを、mg様のアドバイスに従ってWindowsで動くように書き直したものです。
動作確認環境:WindowsXP sp3/InDesign CS3 ver.5.0.4
※何か所かY座標を間違えてて、美しいダイアログとは言い難いですがひとまず動くのでアップしておきます。

#target "InDesign"
#targetengine "textconvert"

//ダイアログ表示のおまじない
app.scriptPreferences.userInteractionLevel=1699311169;

//変数初期化
var A_notChange;
var A_enEnglish_emEnglish;
var A_emEnglish_enEnglish;

var B_notChange;
var B_enNumber_emNumber;
var B_emNumber_enNumber;
var B_specialNumber;

var C_notChange;
var C_enToutenemComma_emTouten;
var C_enToutenemTouten_emComma;

var D_notChange;
var D_enKutenemPeriod_emKuten;
var D_enKutenemKuten_emPeriod;

var E_notChange;
var E_enSign_emSign;
var E_emSign_enSign;
var E_sign01;
var E_sign02;
var E_sign03;
var E_sign04;
var E_sign05;
var E_sign06;
var E_sign07;
var E_sign08;
var E_sign09;
var E_sign10;
var E_sign11;
var E_sign12;
var E_sign13;
var E_sign14;
var E_sign15;
var E_sign16;
var E_sign17;
var E_sign18;
var E_sign19;
var E_sign20;
var E_sign21;
var E_sign22;
var E_sign23;
var E_sign24;
var E_sign25;
var E_sign26;
var E_sign27;
var E_sign28;
var E_sign29;

var F_enKatakana_emKatakana;
var F_FirstSpace;
var F_EndSpace;

var G_anyText1_run;
var G_anyText1_before;
var G_anyText1_after;
var G_anyText2_run;
var G_anyText2_before;
var G_anyText2_after;
var G_anyText3_run;
var G_anyText3_before;
var G_anyText3_after;

var H_multiDocumetsRun;

func_main();
function func_main(){
	var dlg = new Window("window", "変換指定", [250,100,895,850]);
	var runButton = dlg.add('button', [320,680,620,725],"実行", {name:'ok'});

	//-------------------------------------------------------
	dlg.EngChanPnl = dlg.add('panel', [030,030,280,130], "英字の処理"); 
	A_notChange = dlg.EngChanPnl.add('radiobutton', [020,015,200,035], "変換しない"); 
	A_enEnglish_emEnglish = dlg.EngChanPnl.add('radiobutton', [020,045,200,065], "半角英字を全角にする"); 
	A_emEnglish_enEnglish = dlg.EngChanPnl.add('radiobutton', [020,065,200,085], "全角英字を半角にする"); 
	A_notChange.value = true;

	//-------------------------------------------------------
	dlg.NumChgPnl = dlg.add('panel', [030,150,280,280], "数字の処理");
	B_notChange = dlg.NumChgPnl.add('radiobutton', [020,015,200,035], "変換しない");
	B_enNumber_emNumber = dlg.NumChgPnl.add('radiobutton', [020,045,200,065], "半角数字を全角にする");
	B_emNumber_enNumber = dlg.NumChgPnl.add('radiobutton', [020,065,200,085], "全角数字を半角にする"); 
	B_specialNumber = dlg.NumChgPnl.add('radiobutton', [020,085,200,105], "1桁を全角に2桁以上を半角にする");
	B_notChange.value = true;

	//-------------------------------------------------------
	dlg.CommaChgPnl = dlg.add('panel', [030,300,280,405], "読点の処理");
	C_notChange = dlg.CommaChgPnl.add('radiobutton', [020,015,200,035], "変換しない");
	C_enToutenemComma_emTouten = dlg.CommaChgPnl.add('radiobutton', [020,045,200,065], "半角、全角,を全角、にする");
	C_enToutenemTouten_emComma = dlg.CommaChgPnl.add('radiobutton', [020,065,200,085], "半角、全角、を全角,にする");
	C_notChange.value = true;

	//-------------------------------------------------------
	dlg.PiriodChgPnl =	dlg.add('panel', [030,425,280,530], "句点の処理");
	D_notChange = dlg.PiriodChgPnl.add('radiobutton', [020,015,200,035], "変換しない");
	D_enKutenemPeriod_emKuten = dlg.PiriodChgPnl.add('radiobutton', [020,045,200,065], "半角。全角.を全角。にする");
	D_enKutenemKuten_emPeriod = dlg.PiriodChgPnl.add('radiobutton', [020,065,200,085], "半角。全角。を全角.にする");
	D_notChange.value = true;

	//-------------------------------------------------------
	dlg.KigoChgPnl = dlg.add('panel', [320,030,620,480], "記号の処理");
	E_notChange = dlg.KigoChgPnl.add('radiobutton', [020,015,200,035], "変換しない");
	E_enSign_emSign = dlg.KigoChgPnl.add('radiobutton', [020,045,200,065], "以下の半角記号を全角にする");
	E_emSign_enSign = dlg.KigoChgPnl.add('radiobutton', [020,065,200,085], "以下の全角記号を半角にする");
	E_notChange.value = true;
	dlg.KigoChgPnl2 = dlg.KigoChgPnl.add('panel', [015,100,285,435], "処理する記号");
	E_sign01 = dlg.KigoChgPnl2.add('checkbox', [020,015,070,035], "( )");
	E_sign02 = dlg.KigoChgPnl2.add('checkbox', [085,015,135,035], "「 」");
	E_sign03 = dlg.KigoChgPnl2.add('checkbox', [150,015,200,035], "[ ]");
	E_sign04 = dlg.KigoChgPnl2.add('checkbox', [215,015,265,035], "{ }");
	E_sign05 = dlg.KigoChgPnl2.add('checkbox', [020,050,070,070], " +");
	E_sign06 = dlg.KigoChgPnl2.add('checkbox', [085,050,135,070], " −");
	E_sign07 = dlg.KigoChgPnl2.add('checkbox', [150,050,200,070], " =");
	E_sign08 = dlg.KigoChgPnl2.add('checkbox', [215,050,265,070], " 〜");
	E_sign09 = dlg.KigoChgPnl2.add('checkbox', [020,070,070,090], " !");
	E_sign10 = dlg.KigoChgPnl2.add('checkbox', [085,070,135,090], " ?");
	E_sign11 = dlg.KigoChgPnl2.add('checkbox', [150,070,200,090], " #");
	E_sign12 = dlg.KigoChgPnl2.add('checkbox', [215,070,265,090], " $");
	E_sign13 = dlg.KigoChgPnl2.add('checkbox', [020,105,070,125], " %");
	E_sign14 = dlg.KigoChgPnl2.add('checkbox', [085,105,135,125], " &");
	E_sign15 = dlg.KigoChgPnl2.add('checkbox', [150,105,200,125], " @");
	E_sign16 = dlg.KigoChgPnl2.add('checkbox', [215,105,265,125], " ¥");
	E_sign17 = dlg.KigoChgPnl2.add('checkbox', [020,140,070,160], " ;");
	E_sign18 = dlg.KigoChgPnl2.add('checkbox', [085,140,135,160], " :");
	E_sign19 = dlg.KigoChgPnl2.add('checkbox', [150,140,200,160], " _");
	E_sign20 = dlg.KigoChgPnl2.add('checkbox', [215,140,265,160], " /");
	E_sign21 = dlg.KigoChgPnl2.add('checkbox', [020,175,070,195], " <");
	E_sign22 = dlg.KigoChgPnl2.add('checkbox', [085,175,135,195], " >");
	E_sign23 = dlg.KigoChgPnl2.add('checkbox', [150,175,200,195], " ・");
	E_sign24 = dlg.KigoChgPnl2.add('checkbox', [215,175,265,195], " ^");
	E_sign25 = dlg.KigoChgPnl2.add('checkbox', [020,210,070,230], " *");
	E_sign26 = dlg.KigoChgPnl2.add('checkbox', [085,210,135,230], " |");
	E_sign27 = dlg.KigoChgPnl2.add('checkbox', [150,210,200,230], " Space");
	E_sign28 = dlg.KigoChgPnl2.add('checkbox', [020,250,250,270], " ‘ ’(要注意)");
	E_sign29 = dlg.KigoChgPnl2.add('checkbox', [020,285,250,305], " “ ”(要注意)");

	//-------------------------------------------------------
	dlg.SonotaPnl = dlg.add('panel', [320,500,620,610], "その他の処理");
	F_enKatakana_emKatakana = dlg.SonotaPnl.add('checkbox', [020,015,200,035], "半角カタカナを全角にする");
	F_FirstSpaceDelete = dlg.SonotaPnl.add('checkbox', [020,045,200,065], "行頭の余分なスペースを削除");
	F_EndSpaceDelete = dlg.SonotaPnl.add('checkbox', [020,065,200,085], "行末の余分なスペースを削除");

	//-------------------------------------------------------
	dlg.NiniPnl = dlg.add('panel', [030,550,280,725], "任意文字の処理");
	dlg.NiniPnl.add('statictext', [061,015,220,035], "検索文字     置換文字");
	G_anyText1_run = dlg.NiniPnl.add('checkbox', [020,050,040,070], "");
	G_anyText1_before = dlg.NiniPnl.add('edittext', [050,050,120,070], "");
	G_anyText1_after = dlg.NiniPnl.add('edittext', [150,050,230,070], "");
	dlg.NiniPnl.add('statictext', [128,053,150,070], "→");
	G_anyText2_run = dlg.NiniPnl.add('checkbox', [020,080,040,100], "");
	G_anyText2_before = dlg.NiniPnl.add('edittext', [050,080,120,100], "");
	G_anyText2_after = dlg.NiniPnl.add('edittext', [150,080,230,100], "");
	dlg.NiniPnl.add('statictext', [128,083,150,100], "→");
	G_anyText3_run = dlg.NiniPnl.add('checkbox', [020,120,040,140], "");
	G_anyText3_before = dlg.NiniPnl.add('edittext', [050,120,120,140], "");
	G_anyText3_after = dlg.NiniPnl.add('edittext', [150,120,230,140], "");
	dlg.NiniPnl.add('statictext', [128,123,150,140], "→");

	//-------------------------------------------------------
	H_multiDocumetsRun = dlg.add('checkbox', [320,650,540,670], "複数のドキュメントを処理する");

	var flag_run = dlg.show();
	runButton.onClick = func_run;

}//func_main閉じ





function func_run(){
	//変換指定がなかったら処理しない
	if (A_notChange.value == true && B_notChange.value == true && C_notChange.value == true && D_notChange.value == true && E_notChange.value == true && F_enKatakana_emKatakana.value == false && F_FirstSpaceDelete.value == false && F_EndSpaceDelete.value == false && G_anyText1_run.value == false && G_anyText2_run.value == false && G_anyText3_run.value == false){
		alert("処理を選択してください");
		exit();
	}
	if (H_multiDocumetsRun.value == true){	//複数のドキュメントを処理する場合
		if (app.documents.length > 0){	//開いているドキュメントがあったら処理しない
			alert("ドキュメントは全て閉じた状態で実行してください");
			exit();
		}else{
			func_multiRun();
			alert("終了しました");
		}
	}else{	//現在開いているドキュメントを処理する場合
		if (app.documents.length == 0){	//開いているドキュメントがなかったら処理しない
			alert("処理するドキュメントを開いて実行してください");
			exit();
		}else{
			func_singleRun();
			alert("終了しました");
		}
	}
}//func_run閉じ



function func_multiRun() {

	app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;//ダイアログウインドウの表示は許可しない

	var document_open_folder = Folder.selectDialog("Indesignドキュメントのあるフォルダを選択してください");
	if (document_open_folder == null){	//フォルダ選択ダイアログでキャンセルを押したらここを通る
		exit();
	}

	var indd_List = func_findFile(document_open_folder); //関数呼び出し(選択フォルダ以下全てのinddファイル取得)
	if ( indd_List.length===0 ) { //返り値の配列が0なら
		alert("InDesignファイルが見つかりませんでした");
		exit();
	}

	func_styleSimple(indd_List);
	app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;//ダイアログウインドウの表示を許可に戻す
}//func_multiRun閉じ

//再帰処理のfunction//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function func_findFile(document_open_folder) {
	var indd_List=[]; //返り値用の配列
	var all_List = document_open_folder.getFiles(); //フォルダの内容を全て取得
	for (var i=0; i<all_List.length; i++) {
		if(all_List[i] instanceof Folder) { //フォルダなら...
			var res = func_findFile(all_List[i]); //再帰的呼び出し
			indd_List=indd_List.concat(res); //返り値を配列に加える(配列の結合)
		}
		var all_List_fName = all_List[i].name;
		if (all_List_fName.match (/\.indd/)) {
			indd_List.push(all_List[i]);
		}
	}
	return indd_List; //配列を返す
}///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function func_styleSimple(indd_List){

	//プログレスバー処理*******************************************************
	function createProgressBarPanel (){
			var pBar = new Window("window", "テキスト整形");
			pBar.msg = pBar.add("statictext", [12,12,400,32], "処理中...");
			pBar.progressBar = pBar.add("progressbar", [12,32,400,54],0,indd_List.length);
			return pBar;
	}
	var pbarPanel = createProgressBarPanel();
	var bar_num = 1;
	//*********************************************************************

	for( i=0; i<indd_List.length; i++){
		app.open(File(indd_List[i]));	//ファイルを開く

		pbarPanel.show();//プログレスバー処理******

		func_singleRun();
		app.activeDocument.close(SaveOptions.yes);	//ドキュメントを保存して閉じる

		pbarPanel.progressBar.value = bar_num;//プログレスバー処理******
		bar_num = bar_num + 1;//プログレスバー処理******

	}	//forの閉じ
	pbarPanel.close();//プログレスバー処理******
}




function func_find_and_replace(myObject,myCheckSelection){
	//■通常の検索置換の例■■■■■■■■■■■■■■■■■■■■■■
	//func_takeFindText(myObject, "検索文字", "置換文字", "検索文字スタイル", "置換文字スタイル","検索段落スタイル", "置換段落スタイル",  myCheckSelection);
	//■正規表現の検索置換の例■■■■■■■■■■■■■■■■■■■■
	//func_takeFindGrep(myObject, "検索文字", "置換文字", "検索文字スタイル", "置換文字スタイル","検索段落スタイル", "置換段落スタイル",  myCheckSelection);

	if (A_enEnglish_emEnglish.value == true){
		func_takeFindText(myObject,"a","a", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"b","b", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"c","c", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"d","d", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"e","e", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"f","f", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"g","g", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"h","h", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"i","i", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"j","j", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"k","k", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"l","l", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"m","m", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"n","n", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"o","o", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"p","p", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"q","q", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"r","r", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"s","s", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"t","t", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"u","u", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"v","v", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"w","w", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"x","x", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"y","y", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"z","z", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"A","A", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"B","B", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"C","C", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"D","D", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"E","E", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"F","F", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"G","G", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"H","H", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"I","I", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"J","J", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"K","K", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"L","L", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"M","M", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"N","N", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"O","O", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"P","P", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"Q","Q", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"R","R", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"S","S", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"T","T", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"U","U", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"V","V", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"W","W", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"X","X", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"Y","Y", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"Z","Z", "", "","", "",  myCheckSelection);
	}

	if (A_emEnglish_enEnglish.value == true){
		func_takeFindText(myObject,"a","a", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"b","b", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"c","c", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"d","d", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"e","e", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"f","f", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"g","g", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"h","h", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"i","i", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"j","j", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"k","k", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"l","l", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"m","m", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"n","n", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"o","o", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"p","p", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"q","q", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"r","r", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"s","s", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"t","t", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"u","u", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"v","v", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"w","w", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"x","x", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"y","y", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"z","z", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"A","A", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"B","B", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"C","C", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"D","D", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"E","E", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"F","F", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"G","G", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"H","H", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"I","I", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"J","J", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"K","K", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"L","L", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"M","M", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"N","N", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"O","O", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"P","P", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"Q","Q", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"R","R", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"S","S", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"T","T", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"U","U", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"V","V", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"W","W", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"X","X", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"Y","Y", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"Z","Z", "", "","", "",  myCheckSelection);
	}	

	if (B_enNumber_emNumber.value == true){
		func_takeFindText(myObject,"0","0", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"1","1", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"2","2", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"3","3", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"4","4", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"5","5", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"6","6", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"7","7", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"8","8", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"9","9", "", "","", "",  myCheckSelection);
	}

	if (B_emNumber_enNumber.value == true){
		func_takeFindText(myObject,"0","0", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"1","1", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"2","2", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"3","3", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"4","4", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"5","5", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"6","6", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"7","7", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"8","8", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"9","9", "", "","", "",  myCheckSelection);
	}

	if (B_specialNumber.value == true){
		func_takeFindText(myObject,"0","0", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"1","1", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"2","2", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"3","3", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"4","4", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"5","5", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"6","6", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"7","7", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"8","8", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"9","9", "", "","", "",  myCheckSelection);
		func_takeFindGrep(myObject,"([^01234567890123456789\.]|^)0([^01234567890123456789\.]|$)","$10$2", "", "","", "",  myCheckSelection);
		func_takeFindGrep(myObject,"([^01234567890123456789\.]|^)1([^01234567890123456789\.]|$)","$11$2", "", "","", "",  myCheckSelection);
		func_takeFindGrep(myObject,"([^01234567890123456789\.]|^)2([^01234567890123456789\.]|$)","$12$2", "", "","", "",  myCheckSelection);
		func_takeFindGrep(myObject,"([^01234567890123456789\.]|^)3([^01234567890123456789\.]|$)","$13$2", "", "","", "",  myCheckSelection);
		func_takeFindGrep(myObject,"([^01234567890123456789\.]|^)4([^01234567890123456789\.]|$)","$14$2", "", "","", "",  myCheckSelection);
		func_takeFindGrep(myObject,"([^01234567890123456789\.]|^)5([^01234567890123456789\.]|$)","$15$2", "", "","", "",  myCheckSelection);
		func_takeFindGrep(myObject,"([^01234567890123456789\.]|^)6([^01234567890123456789\.]|$)","$16$2", "", "","", "",  myCheckSelection);
		func_takeFindGrep(myObject,"([^01234567890123456789\.]|^)7([^01234567890123456789\.]|$)","$17$2", "", "","", "",  myCheckSelection);
		func_takeFindGrep(myObject,"([^01234567890123456789\.]|^)8([^01234567890123456789\.]|$)","$18$2", "", "","", "",  myCheckSelection);
		func_takeFindGrep(myObject,"([^01234567890123456789\.]|^)9([^01234567890123456789\.]|$)","$19$2", "", "","", "",  myCheckSelection);
	}

	if (C_enToutenemComma_emTouten.value == true){
		func_takeFindGrep(myObject,"(、|,)","、", "", "","", "",  myCheckSelection);		
	}

	if (C_enToutenemTouten_emComma.value == true){
		func_takeFindGrep(myObject,"(、|、)",",", "", "","", "",  myCheckSelection);		
	}

	if (D_enKutenemPeriod_emKuten.value == true){
		func_takeFindGrep(myObject,"(。|.)","。", "", "","", "",  myCheckSelection);		
	}

	if (D_enKutenemKuten_emPeriod.value == true){
		func_takeFindGrep(myObject,"(。|。)",".", "", "","", "",  myCheckSelection);		
	}

	if (E_enSign_emSign.value == true){
		if (E_sign01.value == true){
			func_takeFindText(myObject,"(","(", "", "","", "",  myCheckSelection);
			func_takeFindText(myObject,")",")", "", "","", "",  myCheckSelection);
		}
		if (E_sign02.value == true){
			func_takeFindText(myObject,"「","「", "", "","", "",  myCheckSelection);
			func_takeFindText(myObject,"」","」", "", "","", "",  myCheckSelection);
		}
		if (E_sign03.value == true){
			func_takeFindText(myObject,"[","[", "", "","", "",  myCheckSelection);
			func_takeFindText(myObject,"]","]", "", "","", "",  myCheckSelection);
		}
		if (E_sign04.value == true){
			func_takeFindText(myObject,"{","{", "", "","", "",  myCheckSelection);
			func_takeFindText(myObject,"}","}", "", "","", "",  myCheckSelection);
		}
		if (E_sign05.value == true){
			func_takeFindText(myObject,"+","+", "", "","", "",  myCheckSelection);
		}
		if (E_sign06.value == true){
			func_takeFindText(myObject,"-","−", "", "","", "",  myCheckSelection);
		}
		if (E_sign07.value == true){
			func_takeFindText(myObject,"=","=", "", "","", "",  myCheckSelection);
		}
		if (E_sign08.value == true){
			func_takeFindText(myObject,"~","〜", "", "","", "",  myCheckSelection);
		}
		if (E_sign09.value == true){
			func_takeFindText(myObject,"!","!", "", "","", "",  myCheckSelection);
		}
		if (E_sign10.value == true){
			func_takeFindText(myObject,"?","?", "", "","", "",  myCheckSelection);
		}
		if (E_sign11.value == true){
			func_takeFindText(myObject,"#","#", "", "","", "",  myCheckSelection);
		}
		if (E_sign12.value == true){
			func_takeFindText(myObject,"$","$", "", "","", "",  myCheckSelection);
		}
		if (E_sign13.value == true){
			func_takeFindText(myObject,"%","%", "", "","", "",  myCheckSelection);
		}
		if (E_sign14.value == true){
			func_takeFindText(myObject,"&","&", "", "","", "",  myCheckSelection);
		}
		if (E_sign15.value == true){
			func_takeFindText(myObject,"@","@", "", "","", "",  myCheckSelection);
		}
		if (E_sign16.value == true){
			func_takeFindText(myObject,"\\","¥", "", "","", "",  myCheckSelection);
		}
		if (E_sign17.value == true){
			func_takeFindText(myObject,";",";", "", "","", "",  myCheckSelection);
		}
		if (E_sign18.value == true){
			func_takeFindText(myObject,":",":", "", "","", "",  myCheckSelection);
		}
		if (E_sign19.value == true){
			func_takeFindText(myObject,"_","_", "", "","", "",  myCheckSelection);
		}
		if (E_sign20.value == true){
			func_takeFindText(myObject,"/","/", "", "","", "",  myCheckSelection);
		}
		if (E_sign21.value == true){
			func_takeFindText(myObject,"<","<", "", "","", "",  myCheckSelection);
		}
		if (E_sign22.value == true){
			func_takeFindText(myObject,">",">", "", "","", "",  myCheckSelection);
		}
		if (E_sign23.value == true){
			func_takeFindText(myObject,"・","・", "", "","", "",  myCheckSelection);
		}
		if (E_sign24.value == true){
			func_takeFindText(myObject,"^","^", "", "","", "",  myCheckSelection);
		}
		if (E_sign25.value == true){
			func_takeFindText(myObject,"*","*", "", "","", "",  myCheckSelection);
		}
		if (E_sign26.value == true){
			func_takeFindText(myObject,"|","|", "", "","", "",  myCheckSelection);
		}
		if (E_sign27.value == true){
			func_takeFindText(myObject," "," ", "", "","", "",  myCheckSelection);
		}
		if (E_sign28.value == true){
			func_takeFindGrep(myObject,"'([^']+)'","‘$1’", "", "","", "",  myCheckSelection);
		}
		if (E_sign29.value == true){
			func_takeFindGrep(myObject,'"([^"]+)"',"“$1”", "", "","", "",  myCheckSelection);
		}
	}

	if (E_emSign_enSign.value == true){
		if (E_sign01.value == true){
			func_takeFindText(myObject,"(","(", "", "","", "",  myCheckSelection);
			func_takeFindText(myObject,")",")", "", "","", "",  myCheckSelection);
		}
		if (E_sign02.value == true){
			func_takeFindText(myObject,"「","「", "", "","", "",  myCheckSelection);
			func_takeFindText(myObject,"」","」", "", "","", "",  myCheckSelection);
		}
		if (E_sign03.value == true){
			func_takeFindText(myObject,"[","[", "", "","", "",  myCheckSelection);
			func_takeFindText(myObject,"]","]", "", "","", "",  myCheckSelection);
		}
		if (E_sign04.value == true){
			func_takeFindText(myObject,"{","{", "", "","", "",  myCheckSelection);
			func_takeFindText(myObject,"}","}", "", "","", "",  myCheckSelection);
		}
		if (E_sign05.value == true){
			func_takeFindText(myObject,"+","+", "", "","", "",  myCheckSelection);
		}
		if (E_sign06.value == true){
			func_takeFindText(myObject,"−","-", "", "","", "",  myCheckSelection);
		}
		if (E_sign07.value == true){
			func_takeFindText(myObject,"=","=", "", "","", "",  myCheckSelection);
		}
		if (E_sign08.value == true){
			func_takeFindText(myObject,"〜","~", "", "","", "",  myCheckSelection);
		}
		if (E_sign09.value == true){
			func_takeFindText(myObject,"!","!", "", "","", "",  myCheckSelection);
		}
		if (E_sign10.value == true){
			func_takeFindText(myObject,"?","?", "", "","", "",  myCheckSelection);
		}
		if (E_sign11.value == true){
			func_takeFindText(myObject,"#","#", "", "","", "",  myCheckSelection);
		}
		if (E_sign12.value == true){
			func_takeFindText(myObject,"$","$", "", "","", "",  myCheckSelection);
		}
		if (E_sign13.value == true){
			func_takeFindText(myObject,"%","%", "", "","", "",  myCheckSelection);
		}
		if (E_sign14.value == true){
			func_takeFindText(myObject,"&","&", "", "","", "",  myCheckSelection);
		}
		if (E_sign15.value == true){
			func_takeFindText(myObject,"@","@", "", "","", "",  myCheckSelection);
		}
		if (E_sign16.value == true){
			func_takeFindText(myObject,"¥","\\", "", "","", "",  myCheckSelection);
		}
		if (E_sign17.value == true){
			func_takeFindText(myObject,";",";", "", "","", "",  myCheckSelection);
		}
		if (E_sign18.value == true){
			func_takeFindText(myObject,":",":", "", "","", "",  myCheckSelection);
		}
		if (E_sign19.value == true){
			func_takeFindText(myObject,"_","_", "", "","", "",  myCheckSelection);
		}
		if (E_sign20.value == true){
			func_takeFindText(myObject,"/","/", "", "","", "",  myCheckSelection);
		}
		if (E_sign21.value == true){
			func_takeFindText(myObject,"<","<", "", "","", "",  myCheckSelection);
		}
		if (E_sign22.value == true){
			func_takeFindText(myObject,">",">", "", "","", "",  myCheckSelection);
		}
		if (E_sign23.value == true){
			func_takeFindText(myObject,"・","・", "", "","", "",  myCheckSelection);
		}
		if (E_sign24.value == true){
			func_takeFindText(myObject,"^","^", "", "","", "",  myCheckSelection);
		}
		if (E_sign25.value == true){
			func_takeFindText(myObject,"*","*", "", "","", "",  myCheckSelection);
		}
		if (E_sign26.value == true){
			func_takeFindText(myObject,"|","|", "", "","", "",  myCheckSelection);
		}
		if (E_sign27.value == true){
			func_takeFindText(myObject," "," ", "", "","", "",  myCheckSelection);
		}
		if (E_sign28.value == true){
			func_takeFindGrep(myObject,"[‘’]","'", "", "","", "",  myCheckSelection);
		}
		if (E_sign29.value == true){
			func_takeFindGrep(myObject,"[“”]",'"', "", "","", "",  myCheckSelection);
		}
	}

	if (F_enKatakana_emKatakana.value == true){
		func_takeFindText(myObject,"ア","ア", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"イ","イ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ウ","ウ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"エ","エ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"オ","オ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"カ","カ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"キ","キ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ク","ク", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ケ","ケ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"コ","コ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ガ","ガ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ギ","ギ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"グ","グ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ゲ","ゲ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ゴ","ゴ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"サ","サ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"シ","シ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ス","ス", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"セ","セ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ソ","ソ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ザ","ザ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ジ","ジ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ズ","ズ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ゼ","ゼ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ゾ","ゾ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"タ","タ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"チ","チ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ツ","ツ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ッ","ッ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"テ","テ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ト","ト", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ダ","ダ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ヂ","ヂ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ヅ","ヅ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"デ","デ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ド","ド", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ナ","ナ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ニ","ニ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ヌ","ヌ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ネ","ネ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ノ","ノ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ハ","ハ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ヒ","ヒ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"フ","フ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ヘ","ヘ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ホ","ホ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"バ","バ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ビ","ビ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ブ","ブ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ベ","ベ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ボ","ボ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"パ","パ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ピ","ピ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"プ","プ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ペ","ペ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ポ","ポ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"マ","マ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ミ","ミ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ム","ム", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"メ","メ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"モ","モ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ヤ","ヤ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ユ","ユ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ヨ","ヨ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ャ","ャ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ュ","ュ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ョ","ョ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ラ","ラ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"リ","リ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ル","ル", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"レ","レ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ロ","ロ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ワ","ワ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ヲ","ヲ", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ン","ン", "", "","", "",  myCheckSelection);
		func_takeFindText(myObject,"ー","ー", "", "","", "",  myCheckSelection);
	}

	if (F_FirstSpaceDelete.value == true){
		func_takeFindGrep(myObject,"^[  ]+","", "", "","", "",  myCheckSelection);
	}
	if (F_EndSpaceDelete.value == true){
		func_takeFindGrep(myObject,"[  ]+$","", "", "","", "",  myCheckSelection);
	}

	if (G_anyText1_run.value == true){
		func_takeFindText(myObject,G_anyText1_before.text,G_anyText1_after.text, "", "","", "",  myCheckSelection);
	}
	if (G_anyText2_run.value == true){
		func_takeFindText(myObject,G_anyText2_before.text,G_anyText2_after.text, "", "","", "",  myCheckSelection);
	}
	if (G_anyText3_run.value == true){
		func_takeFindText(myObject,G_anyText3_before.text,G_anyText3_after.text, "", "","", "",  myCheckSelection);
	}
	//func_takeFindText(myObject,"あ","<2474>", "", "","", "",  myCheckSelection);	//文字をUnicodeに変換するものだがアプリが落ちてしまう…
}//func_find_and_replace閉じ



function func_singleRun(){
	var myObject;
	var myCheckSelection = false;
	if(app.documents.length > 0){
		if(app.selection.length > 0){
			switch(app.selection[0].constructor.name){
				case "InsertionPoint":
				case "Character":
				case "Word":
				case "TextStyleRange":
				case "Line":
				case "Paragraph":
				case "TextColumn":
				case "Text":
					app.scriptPreferences.userInteractionLevel = 1699311169
					//myFindText(myObject, myFindLimit, myFindPreferences, myChangePreferences, myCheckSelection);
					myObject = func_rangeDialog();
					myCheckSelection = myObject[1];
					myObject = myObject[0];
					if(myObject != "None"){
						func_find_and_replace(myObject, myCheckSelection);
						//myFindChangeByList(myObject, myCheckSelection);
					}
					break;
				default:
					for(var sel = 0;sel < app.selection.length;sel++){
						func_find_and_replace(app.selection[sel], false);
					}
					//myFindChangeByList(app.documents.item(0), false);
			}
		}else{
			//Nothing was selected, so simply search the document.
			func_find_and_replace(app.documents.item(0), false);
			//myFindChangeByList(app.documents.item(0), false);
		}
	}else{
		alert("ドキュメントが開かれていません");
	}
}//func_singleRun閉じ

function func_rangeDialog(){
	var myObject;
	var myDialog = app.dialogs.add({name:"処理する範囲を指定してください"});
	with(myDialog.dialogColumns.add()){
		with(dialogRows.add()){
			//with(dialogColumns.add()){
			//	staticTexts.add({staticLabel:"処理する範囲:"});
			//}
			var myRangeButtons = radiobuttonGroups.add();
			with(myRangeButtons){
				radiobuttonControls.add({staticLabel:"選択範囲", checkedState:true});
				radiobuttonControls.add({staticLabel:"ストーリー"});
				radiobuttonControls.add({staticLabel:"ドキュメント"});
			}
		}
	}
	var myResult = myDialog.show();
	if(myResult == true){
		switch(myRangeButtons.selectedButton){
			case 0:
				myObject = app.selection[0];
				myCheckSelection = true;
				break;
			case 1:
				myObject = app.selection[0].parentStory;
				myCheckSelection = false;
				break;
			case 2:
				myObject = app.documents.item(0);
				myCheckSelection = false;
				break;
		}
	}else{
		myObject = "None";
		myDialog.destroy();
		exit();
	}
	myDialog.destroy();
	return [myObject, myCheckSelection];
}//func_rangeDialog閉じ

function func_takeFindText(myObject, myFindStr, myChangeStr, myFindC_style, myChangeC_style,myFindP_style, myChangeP_style, myCheckSelection){
	//検索置換
	if(myCheckSelection == true){
		//検索対象が選択範囲の時のみtrue
		myObject = app.selection[0];
	}
	app.changeTextPreferences = NothingEnum.nothing;
	app.findTextPreferences = NothingEnum.nothing;
	app.findChangeTextOptions.caseSensitive = true;//大文字小文字を区別するかどうか
	if(myFindStr != ""){
		app.findTextPreferences.findWhat = myFindStr;
	}
	if(myChangeStr != ""){
		app.changeTextPreferences.changeTo = myChangeStr;
	}
	if(myFindC_style != ""){
		app.findTextPreferences.appliedCharacterStyle = app.activeDocument.characterStyles.item(myFindC_style);
	}
	if(myChangeC_style != ""){
		app.changeTextPreferences.appliedCharacterStyle = app.activeDocument.characterStyles.item(myChangeC_style);
	}
	if(myFindP_style != ""){
		app.findTextPreferences.appliedParagraphStyle = app.activeDocument.paragraphStyles.item(myFindP_style);
	}
	if(myChangeP_style != ""){
		app.changeTextPreferences.appliedParagraphStyle = app.activeDocument.paragraphStyles.item(myChangeP_style);
	}

		var myLoopLimit = 0;
		var myFoundItemsCount = 0;
		var myFoundItemsCountOld = 0;
		outsideloop:
		do{
			try{
			//ここで検索置換している
			myFoundItems = myObject.changeText();
			}catch(msg){
				//文字が短くなってエラーに
				return;
			}
			myLoopLimit ++;
			if(myLoopLimit > 100){
				var myResult = confirm("100回検索置換しました。続けますか?");
				if(myResult == false){
					break outsideloop;
				}
				else{
					myLoopLimit = 0;
				}
			}
			myFoundItemsCount = myFoundItems.length;
			if(myFoundItemsCount == 0){
					myLoopLimit = 1001;
			}else if(myFoundItemsCountOld == myFoundItemsCount){
					//こうしないと置換文字無しでスタイルだけ適応させるときになんどもくりかえしてしまう。
					myLoopLimit = 1001;
			}
			myFoundItemsCountOld = myFoundItemsCount;
		}while(myLoopLimit < 1000);
	
	//Reset the find/change preferences after each search.
	app.changeTextPreferences = NothingEnum.nothing;
	app.findTextPreferences = NothingEnum.nothing;
	if(myCheckSelection == true){
		//検索対象が選択範囲の時のみtrue
		//If myCheckSelection is true, reacquire a reference to the selection each time through the loop.
		//You need to do this because deleting/adding characters has the potential to invalidate the
		//text reference you're using.
		myObject = app.selection[0];
	}
}//func_takeFindText閉じ

function func_takeFindGrep(myObject, myFindStr, myChangeStr, myFindC_style, myChangeC_style,myFindP_style, myChangeP_style, myCheckSelection){
	//正規表現の検索置換
	app.changeGrepPreferences = NothingEnum.nothing;
	app.findGrepPreferences = NothingEnum.nothing;
	if(myFindStr != ""){
		app.findGrepPreferences.findWhat = myFindStr;
	}
	if(myChangeStr != ""){
		app.changeGrepPreferences.changeTo = myChangeStr;
	}
	if(myFindC_style != ""){
		app.findGrepPreferences.appliedCharacterStyle = app.activeDocument.characterStyles.item(myFindC_style);
	}
	if(myChangeC_style != ""){
		app.changeGrepPreferences.appliedCharacterStyle = app.activeDocument.characterStyles.item(myChangeC_style);
	}
	if(myFindP_style != ""){
		app.findGrepPreferences.appliedParagraphStyle = app.activeDocument.paragraphStyles.item(myFindP_style);
	}
	if(myChangeP_style != ""){
		app.changeGrepPreferences.appliedParagraphStyle = app.activeDocument.paragraphStyles.item(myChangeP_style);
	}
	var myFoundItems = myObject.changeGrep();
	app.changeGrepPreferences = NothingEnum.nothing;
	app.findGrepPreferences = NothingEnum.nothing;
	if(myCheckSelection == true){
		myObject = app.selection[0];
	}
}//func_takeFindGrep閉じ