// 変数取り出し//式から変数だけを取り出すfunction ChangeStr(S) { var Scopy=S; S = S.replace(/[ ]+/g,"");// 空白を削除 S = S.replace(/[\r\n]/g,"");// 改行を削除 S = S.replace(/.+\=/g,"");// =より前は変数扱いしない S = S.replace(/[a-zA-z]+\(/g,"");// (直前のアルファベットは関数と判断 S = S.replace(/[\+\-*/\^=\(\){} ]+/g,"\n"); //S = S.replace(/\n[0-9]+\n/g,"\n"); S = S.split('\n'); //分割 for (i = 1; i < S.length;i++ ){ for (j = 0; j<i; ){ if (S[i] == S[j]){ S.splice(i, 1); //削除 j=0; } else j ++; } } S = S.sort(function(a, b) {return b.length - a.length;}); S = S.join('\r\n'); //結合 S = S.replace(/\r\n[0-9]+\r\n/g,"\r\n"); return Scopy+S }//メインvar S;ClipBoard.Clear(); //クリアEditor.Copy(); //コピーS = ClipBoard.Text;if (S != "" ){ S = ChangeStr(S); //変換 ClipBoard.Text = S; Editor.Past();}ClipBoard.Undo(); //戻す' 代入した式' 変数に数値に置き換えた式を得る。エクセルなどへの貼り付け用'選択全行を変換Function ChangeRows(S) Dim R, Rmax Dim S0, Si, Simax, V, N S = Split(S, VbCrLf) Rmax = UBound(S) ? S0 = S(0) For R = 1 To Rmax If S(R) <> "" Then Si = Split(S(R), " = ") Simax = UBound(Si) ? If Simax=1 Then V = Si(0) N = Si(1) S(0) = Replace(S(0), V, N) End If End If Next ChangeRows = S0 & VbCrLf & Join(S, VbCrLf)End Function'メインDim SClipBoard.Clear 'クリップボードをクリアEditor.Copy 'エディタからクリップボードへコピーS = ClipBoard.Text '変換対象の文字列If S = "" Then Editor.SelectRow '無選択時は行選択 Editor.Copy S = ClipBoard.TextEnd IfIf S <> "" Then S = ChangeRows(S) '変換 ClipBoard.Text = S Editor.PastEnd IfClipBoard.Undo 'クリップボードを戻す// 代入リスト// 全角=を変換し、GeoGebra代入用のリストにまとめるfunction ChangeStr(S) { S = S.replace(/=/g, "="); S = S.replace(/[\r\n]/g, ","); S = S.replace(/^[,]+/g, ""); S = S.replace(/[,]+$/g, ""); S = S.replace(/[,]+/g, ", "); S = "{"+S+"}" return S}//メインvar S;ClipBoard.Clear(); //クリアEditor.Copy(); //コピーS = ClipBoard.Text;if (S != "" ){ S = ChangeStr(S); ClipBoard.Text = S; Editor.Past();}ClipBoard.Undo(); //戻す