ストリップ パス: JMP スクリプトでファイル パス変数からディレクトリを取得する方法JMP スクリプトのファイル パス変数からディレクトリを取得したいと考えています。
データ ファイルを開いていますが、解析結果をファイルと同じフォルダーに保存したいと考えています。
不格好な解決策を見つけましたが、これにはもっと洗練された解決策があることを望んでいました。
これが私の現在のコードです:
// Choose the directory that has the test data.
EMfile = Pick File("Select the file containing the EM summary table.");
// The next code is a clumsy way to get the directory of EMfile, but it works.
a = 1;
b = 1;
while (a != 0,
b = a+1;
a = munger(EMfile, b, "/");
);
b--;
file_dir = munger(EMfile, 0, b);
Re: ストリップ パス: JMP スクリプトでファイル パス変数からディレクトリを取得する方法これは、あなたが望むことをするかなりきれいなコードです
filelength = length(word(-1,emfile,"\/"));
pathlength=length(emfile)-filelength-1;
path=substr(emfile,1,pathlength);
必要に応じて、1 つのステートメントに折りたたむことができます