Jean Pierre Daviau said:
Many thanks
I placed 6 .gif icons on the desktop
This line gives: < was unattended.
set _mypth=%_mypth%^<a href="%1"^>^<img src="%1"^>^</a^>^<br^>
The others prints ok.
Yes - you are correct BUT the error is actually occurring on the following
LOGICAL line.
if %_conteur% GTR 38 ( echo.
echo ^</td^>^<td^>
echo %_mypth%
echo.
set _mypth=
set _conteur=
)>>zx.htm
is ALL ONE logical line on seven PHYSICAL lines. The processor will
substitute the current value of _mypth into this line, and the current value
is "<a href="filename"><img src="filename"></a><br>"
since this starts with an unescaped "<", it is interpreted as a redirector -
and this is invalid syntax.
Fixing this problem is not easy, but it can be done.
This solution developed using XP
It may work for NT4/2K
----- batch begins -------
[1]@echo off
[2]set _mypth=
[3]set _conteur=
[4]echo ^<table^> >zx.htm
[5]for %%a in (*.gif) do call :sub %%a
[6]if defined _mypth call
utput
[7]echo ^</table^> >>zx.htm
[8]goto :eof
[9]::
[10]:sub
[11]set /a _conteur +=1
[12]set _mypth=%_mypth%[a href="%1"][/a][br]
[13]if %_conteur% GTR 38 call :output
[14]goto :eof
[15]
[16]:output
[17]echo .
[18]set _mypth=%_mypth:~1,-1%
[19](
[20] echo ^<tr^>^<td^>
[21] echo ^<%_mypth:][=^>^<%^>
[22] echo ^</td^>^</tr^>
[23])>>zx.htm
[24]set _mypth=
[25]set _conteur=
[26]goto :eof
------ batch ends --------
Lines start [number] - any lines not starting [number] have been wrapped and
should be rejoined. The [number] that starts the line should be removed
The label :eof is defined in NT+ to be end-of-file but MUST be expressed as
:eof
[5] calls :sub for each .GIF
:SUB builds _mypth as
[a href="x1"][img src="x1"][/a][br][a href="x2"][img src="x2"][/a][br]...
until 38 have been accumulated, then calls :output.
:OUTPUT outputs a <TR><TD> frame around _mypth.
[18] removes the first character of _mypth, which must be a "[" and also the
last char which must be a "]"
[21] echoes _mypt5h, replacing each "][" sequence with "><", with a leading
"<" and a trailing ">" to replace the characters removed by [18]
and then [24,25] clear _mypth and _conteur
If the last line is not 38 elements long, _mypth will still be defined when
the FOR loop terminates, so [6] calls :OUTPUT to produce the remaining
lines.
*** Comment:
I'm not sure that this is the desired HTML output. I would have expected
<TR>
<TD><A HREF...</A></TD><TD><A HREF...</A></TD>
</TR>
*** This can be easily accomplished by adding [TD] before [A HREF and {/TD]
in place of, or before or after [BR] in [12]
But there also seems to be no reason for building _mypth in any case -
wouldn't
<TD><A HREF...</A></TD>
<TD><A HREF...</A></TD>
....
accomplish the same thing in HTML - that is, one line for EACH filename,
with appropriate /TR and TR tokens at appropriate points?