Por favor ayúdenme a eliminar el carácter de carro en JSLTengo un script jsl que llama al archivo Python para identificar un directorio específico desde cualquier lugar. Funciona bien pero el resultado tiene un carácter carruaje que lo arruina todo.
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
";
Alguien, ¿podría ayudarme a convertir esta cadena para eliminar el carácter de carro y tener este aspecto?
home_dir = "C:\dtemp"
Automatización y secuencias de comandosRe: Por favor ayúdame a eliminar el carácter de carro en JSLcr = "
";
home_dir = "C:\dtemp
";
home_dir = substitute(home_dir, cr, "");
Re: Por favor ayúdame a eliminar el carácter de carro en JSL @pmroz ¡La solución es buena! Aquí hay una referencia general a la personajes invisibles comunes que puede aparecer en una cadena de caracteres. Puede utilizar la secuencia de escape para buscar.
Re: Por favor ayúdame a eliminar el carácter de carro en JSLcur_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);El resultado sigue siendo el mismo .. 
home_dir = "C: \ dekel_post_processing
";
home_dir = "C: \ dekel_post_processing
";
Re: Por favor ayúdame a eliminar el carácter de carro en JSLLo probé con "(\ r)" como búsqueda RegEx pero sigue teniendo el mismo problema.
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);Resultado.
home_dir = "C:\tmp
";
home_dir = "C:\tmp
";
Lo que quiero:
home_dir = "C:\tmp"
Re: Por favor ayúdame a eliminar el carácter de carro en JSLAunque funciona si solo ejecuta estas pocas líneas individualmente.
cr = "
";
home_dir = "C:\dtemp
";
show(home_dir);
home_dir = substitute(home_dir, cr, "");
show(home_dir);
Resultado:
home_dir = "C:\dtemp
";
home_dir = "C:\dtemp";
Re: Por favor ayúdame a eliminar el carácter de carro en JSL¿Tal vez esto?
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: Por favor ayúdame a eliminar el carácter de carro en JSLsí, finalmente funcionó. El truco es el siguiente:
suponga que tiene un archivo "ejemplo.jsl" y desea tener la ruta absoluta. Debes hacer lo siguiente:
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 );
El archivo de Python al que llamas es simple:
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: Por favor ayúdame a eliminar el carácter de carro en JSLAsí es como lo haría usando los caracteres de escape estándar en JMP
names default to here(1);
cr = "\!r";
home_dir = "C:\dtemp
";
show(home_dir);
home_dir = substitute(home_dir, cr, "");
show(home_dir);
Que dio los descansos
home_dir = "C:\dtemp
";
home_dir = "C:\dtemp";