경로 제거: 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);
원하는 경우 하나의 문으로 축소할 수 있습니다.