JSL에서 캐리지 문자를 제거하도록 도와주세요.어디에서나 특정 디렉토리를 식별하기 위해 Python 파일을 호출하는 jsl 스크립트가 있습니다. 그것은 잘 작동하지만 그 결과 모든 것을 망치는 캐리지 캐릭터가 생겼습니다.
cur_dir = Substr( Get Default Directory(), 2, 999 );
cur_dir = Substitute( cur_dir, "/", "\" );
show(cur_dir);
_path_script = cur_dir || "find_home_directory.py";
show(_path_script);
home_dir = RunProgram(
executable( "python" ),
options( _path_script),
readfunction( "text" )
);
show(home_dir);
home_dir = "C:\dtemp
";
누구라도 이 문자열을 변환하여 캐리지 문자를 제거하고 다음과 같이 보이는 방법을 알려주실 수 있나요?
home_dir = "C:\dtemp"
자동화 및 스크립팅Re: JSL에서 캐리지 문자를 제거하는 데 도움을 주세요.JMP에서 표준 이스케이프 문자를 사용하여 수행하는 방법은 다음과 같습니다.
names default to here(1);
cr = "\!r";
home_dir = "C:\dtemp
";
show(home_dir);
home_dir = substitute(home_dir, cr, "");
show(home_dir);
결과를 준 것은
home_dir = "C:\dtemp
";
home_dir = "C:\dtemp";
Re: JSL에서 캐리지 문자를 제거하는 데 도움을 주세요.네 드디어 성공했습니다. 트릭은 다음과 같습니다.
"example.jsl" 파일이 있고 절대 경로를 원한다고 가정합니다. 다음을 수행해야 합니다.
cur_dir = Substr( Get Default Directory(), 2 );
cur_dir = Convert File Path( cur_dir, Windows );
Show( cur_dir );
_path_script = cur_dir || "find_home_directory.py";
Show( _path_script );
home_dir = Run Program( executable( "python" ), options( _path_script ), readfunction( "text" ) );
Show( home_dir );
path_to_example_jsl = Substitute( home_dir, "\r", "example.jsl" );
Show( path_to_example_jsl );
호출하는 python 파일은 간단합니다.
import os
def find_home_dir():
cur_dir = os.path.dirname(os.path.realpath(__file__))
while True:
if "file_which_defines_root" in os.listdir(cur_dir):
break
else:
cur_dir = os.path.dirname(cur_dir)
print(cur_dir.strip())
if __name__ == '__main__':
find_home_dir()
Re: JSL에서 캐리지 문자를 제거하는 데 도움을 주세요.아마도 이것은?
cur_dir = Substr( Get Default Directory(), 2 );
cur_dir = Convert File Path( cur_dir, Windows );
Show( cur_dir );
_path_script = cur_dir || "find_home_directory.py";
Show( _path_script );
home_dir = Run Program( executable( "python" ), options( _path_script ), readfunction( "text" ) );
Show( home_dir );
home_dir = Substitute( home_dir, "\r", "" );
Show( home_dir );
Re: JSL에서 캐리지 문자를 제거하는 데 도움을 주세요.이 몇 줄을 개별적으로 실행하면 작동하지만.
cr = "
";
home_dir = "C:\dtemp
";
show(home_dir);
home_dir = substitute(home_dir, cr, "");
show(home_dir);
결과:
home_dir = "C:\dtemp
";
home_dir = "C:\dtemp";
Re: JSL에서 캐리지 문자를 제거하는 데 도움을 주세요.나는 그것을 시도했다 "(\r)"을 정규식 검색으로 사용하지만 여전히 동일한 문제가 발생합니다.
cur_dir = Substr( Get Default Directory(), 2, 999 );
cur_dir = Substitute( cur_dir, "/", "\" );
show(cur_dir);
_path_script = cur_dir || "find_home_directory.py";
show(_path_script);
home_dir = RunProgram(
executable( "python" ),
options( _path_script),
readfunction( "text" )
);
show(home_dir);
cr = Regex(home_dir,"(\r)");
home_dir = substitute(home_dir, cr, "");
show(home_dir);결과.
home_dir = "C:\tmp
";
home_dir = "C:\tmp
";
내가 원하는 것:
home_dir = "C:\tmp"
Re: JSL에서 캐리지 문자를 제거하는 데 도움을 주세요.cur_dir = Substr( Get Default Directory(), 2, 999 );
cur_dir = Substitute( cur_dir, "/", "\" );
show(cur_dir);
_path_script = cur_dir || "find_home_directory.py";
show(_path_script);
home_dir = RunProgram(
executable( "python" ),
options( _path_script),
readfunction( "text" )
);
show(home_dir);
cr ="
";
home_dir = substitute(home_dir, cr, "");
show(home_dir);결과는 여전히 동일합니다.:(
home_dir = "C:\dekel_post_processing
";
home_dir = "C:\dekel_post_processing
";
Re: JSL에서 캐리지 문자를 제거하는 데 도움을 주세요.@pmroz 의 솔루션은 좋은 솔루션입니다! 다음은 에 대한 일반적인 참조입니다. 일반적인 보이지 않는 문자 문자열에 나타날 수 있습니다. 이스케이프 시퀀스를 사용하여 검색할 수 있습니다.
Re: JSL에서 캐리지 문자를 제거하는 데 도움을 주세요.cr = "
";
home_dir = "C:\dtemp
";
home_dir = substitute(home_dir, cr, "");