From: LukasP <LP...@po...> - 2010-07-19 14:32:06
|
... There's no doubt there are possibilities how to convert \ to /. The solution suggested bellow is usable on Linux, but not in Windows - when I need to convert hundreds of datafiles under Windows to png and when I use command "dir /s /b *.dat", I get a list where "\" is used as directory separator in file path. Personally - on Windows - I use an ("ultra-easy") bksl2sl.exe utility, which reads stdin, each occurance of "\" replaces by "/" and writes bytes to stdout. It works, although its "non-standard". Petr Mikulik wrote: > >> is there a built-in string replacing function? >> a = replace("ABC\\XYZ", "\\", "/") # a -> "ABC/XYZ" > > you can use the following: > > # replace "o" by "XYZ": > a="hello world" > b="echo ".a." | sed s=o=XYZ=g" > c=system(b) > print c > > => it prints: > hellXYZ wXYZrld > ... OK, I treat it as a possibility which works on Linux; it doesn't work on Windows. IMHO, I don't think it's the way of best performance - to create new process, wait for the pipe until it is broken and the take the result. When converting a large number of files, a built-in replacing function should be much quicker, don't you think? Petr Mikulik wrote: > >> It would be very useful especially when migrating between Linux and Win >> apps >> as Linux uses "/" as directory separator but Windows use "\". > > This is not needed if gnuplot is compiled by a gcc-based suite on Windows; > thus use always "/". > > --- > Petr Mikulik > ... Personally, no problem with using "/" for directory separator (and "-" for command option). But it's otherwise on Windows - its commands use "\" for path description and "/" as command separator; I cann't do nothing with that. LuP -- View this message in context: http://old.nabble.com/Function-%22replace%22-for-strings--tp29173139p29205345.html Sent from the Gnuplot - Dev mailing list archive at Nabble.com. |