- Feb
- 65
- 1
Hi,
I am working on a small script which is supposed to launch the PHP-File I am working in my webbrowser (after copying it to a temp-dir, if so required). In order to translate "local directory-separators" (\) into "web-friendly dir-separators" (/), I am using %@replace[^\,^/,%fp] - but unfortunately, when applied in a BTM, this empties the variable (whereas it works as expected when executing an echo of that on the command-line). (I am using TC 13 and have also tasted this against 15).
Where is the bug that I do not see?
usage: launch_php.btm c:\xampp\htdocs\foo.php
rem @echo off
ver
set fn=%@full[%1]
iff "%@ext[%fn]"=="php" then
set fp=%@path[%fn]
set fpu=%@upper[%fp]
set i=%@index[%fp,C:\XAMPP\HTDOCS\]
iff %i lt 0 then
set newnam =c:\xampp\htdocs\tmp\%@filename[%fn]
copy %fn %newnam
set fp=%@path["%newnam%"]
set fn=%newnam%
endiff
set relpth = %@instr[16,,%fn]
echo relpth=%relpth
echo repl1=%@replace[^\,^/,%relpth]
echo repl2=%@replace[^\,^/,"%relpth"]
echo repl3=%@replace[^\,^/,%relpth%]
rem ^^^^THIS KILLS "relpth" ^^^
echo Calling: http://localhost/xampp/%relpth
pause
http://localhost/xampp/%relpth
else
echo Only supporting PHP-Files currently!
endiff
I am working on a small script which is supposed to launch the PHP-File I am working in my webbrowser (after copying it to a temp-dir, if so required). In order to translate "local directory-separators" (\) into "web-friendly dir-separators" (/), I am using %@replace[^\,^/,%fp] - but unfortunately, when applied in a BTM, this empties the variable (whereas it works as expected when executing an echo of that on the command-line). (I am using TC 13 and have also tasted this against 15).
Where is the bug that I do not see?
usage: launch_php.btm c:\xampp\htdocs\foo.php
rem @echo off
ver
set fn=%@full[%1]
iff "%@ext[%fn]"=="php" then
set fp=%@path[%fn]
set fpu=%@upper[%fp]
set i=%@index[%fp,C:\XAMPP\HTDOCS\]
iff %i lt 0 then
set newnam =c:\xampp\htdocs\tmp\%@filename[%fn]
copy %fn %newnam
set fp=%@path["%newnam%"]
set fn=%newnam%
endiff
set relpth = %@instr[16,,%fn]
echo relpth=%relpth
echo repl1=%@replace[^\,^/,%relpth]
echo repl2=%@replace[^\,^/,"%relpth"]
echo repl3=%@replace[^\,^/,%relpth%]
rem ^^^^THIS KILLS "relpth" ^^^
echo Calling: http://localhost/xampp/%relpth
pause
http://localhost/xampp/%relpth
else
echo Only supporting PHP-Files currently!
endiff