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, "");