モーダル ダイアログ ボックスからの入力を必要とするプラットフォームからの出力を自動化するにはどうすればよいでしょうか?
以下に 2 つの例を示します。 1 つ目は、ダイアログ ボックスですべてのオプションを指定する場合に機能します。
すべてのオプションを指定できる場合は、2 番目も同じように機能することが期待されます。私の推測では、一部のオプションが正しい名前または構文を使用していないと思われます (残念ながら、Jmp はデバッグ情報を提供しません)。以下の例を参照してください (Jmp 14 EA 7 で動作します)...
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
//This Works when all options in Save Document Matrix are specified:
te=dt<<TEXT explorer=""></TEXT>
一般に、再コード化ダイアログはスクリプト化できません。 JMP の将来のリリースで検討するために、お客様のフィードバックを JMP 開発チームに伝えました。
いつもJMPをご利用いただきありがとうございます。
返信ありがとうございます。レーベンシュタイン距離が役立つ日が来るかもしれません。
一般的にスクリプトを作成して、プラットフォームの最後の部分を自動化する方法を探しています。 これに関するドキュメントがないことは承知しています - または、少なくとも私はそれを見つけることができませんでした - しかし、最初の例で見たように、すべての値が呼び出し時に提供される場合、モーダル ダイアログ ボックスを回避することができます。 すべてのダイアログ ボックスで機能するかどうかはわかりませんが、1 つのダイアログ ボックスで機能したので、これが一般的に機能する可能性は十分にあると思います。 それ以外の場合は、これを機能させるように開発者に懇願します。そうすれば、反復的なタスクを回避し、プラットフォームと Jmp スクリプトの可能性を最大限に引き出すことができます。
残念ながら、モーダル ダイアログ ボックスが閉じない限り、クリックせずにモーダル ダイアログ ボックスを閉じる方法はありません。 この場合、自分で再コーディングのスクリプトを作成できます。最も難しい部分は、文字列距離関数を見つけたり書いたりすることです。
以下のスクリプトを使用すると、簡単に始めることができますが、この距離関数をそのまま使用しないでください。非常に非効率的です。5 文字の単語で 2 の距離は長いですが、「JANE」、「JAMES」、および「JOE」はすべて「JANE」になることがわかります。
Names default to here( 1 );
// FUNCTION TO CALCULATE DISTANCE BETWEEN STRINGS
//Rewrite of example C code from wikipedia:
//https://en.wikipedia.org/wiki/Levenshtein_distance
//very inefficient
// len_s and len_t are the number of characters in string s and t respectively
LevenshteinDistance_ = function({s, len_s, t, len_t},
// show(s || char(len_s) || t || char(len_t));
// base case: empty strings
if ( substr( s, 1, len_s ) == substr( t, 1, len_t ), 0, //strings match, distance is zero
len_s == 0, len_t, //s empty, distance is the length of t
len_t == 0, len_s, //t empty, distance is the length of s
// return minimum of delete char from s, delete char from t, and delete char from both
minimum(
LevenshteinDistance_(s, len_s - 1, t, len_t ) + 1,
LevenshteinDistance_(s, len_s , t, len_t - 1) + 1,
LevenshteinDistance_(s, len_s - 1, t, len_t - 1) +
if (substr(s, len_s, 1) == substr(t, len_t, 1), 0, 1) // test if last characters of the strings match
);
);
);
//Wrapper that finds strings lengths for you
LevenshteinDistance = function({s, t}, LevenshteinDistance_(s, length(s), t, length(t)));
// EXAMPLE
//data table
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << New Column( "name recoded", Character, "Nominal" );
//replace names with the first name in the table having a Levenshtein
//distance of two or less when compared to that value
for( i = 1, i <= min(15, N Rows( dt )), i++, //for each row in the table
//if row one always use that value
Column( dt, "name recoded")[i] = if( i == 0, Column( dt, "name")[i], <BR />
newvalue = Column(dt, "name")[i]; //assume you will use this rows' value<BR />
match = 0; //flag indicating that a match is found
for( j = 1, j < i & match == 0, j++, //look at all previous rows to find a match
//if a match use the previous row value and stop looking for more matches
if( LevenshteinDistance( Column(dt, "name")[i], Column(dt, "name")[j] ) <= 2,
newvalue = Column(dt, "name")[j];
match = 1;
)
);
newvalue;
);
);