Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Inserting filenames into html lines

197 views
Skip to first unread message

Alfred Mansfield

unread,
Sep 14, 2001, 7:38:48 PM9/14/01
to
Hi!

Can someone help me with this problem?

I have a folder filled with 50 or so picture files (gif).

I want to write a batchfile which can be placed inside this folder and upon
excuting it, it would automatically generate a series of lines; shown below:

---------------------------
<a href="PICT~A.gif"><img src="PICT~A.gif" alt="1" width="100"
height="100"></a>
<a href="PICT~B.gif"><img src="PICT~B.gif" alt="1" width="100"
height="100"></a>
...
<a href="PICT~X.gif"><img src="PICT~X.gif" alt="1" width="100"
height="100"></a>
---------------------------


Where PICT~A is the filename of the "first" gif file and PICT~X is the
filename of the "last" gif file in the folder. It is not neccessary that
the gif files must be in some particular order (they are not named that way
anyway)

For those who understand html, you would see that this is actually a nice
picture gallery generator. It's simple but very useful.


I attempted it by doing this:

---------------------------
command/c FOR %%n in (1 2) DO prompt $la href="%1"$g$limg src="%1" alt="1"
width="100" height="100"$g$l/a$g $_ |FIND/v "prompt">_____

type _____|find "a href=">>index.html
---------------------------

This works but it is very troublesome as I have to pull each gif file at a
time onto the batchfile in order for it to generate that corresponding line
for that gif file.

I am looking for a way in which the batchfile automatically generates and
inserts the gif filenames into the PICT~ variables in the html lines above.

If possible, it would be better to use the dir/b command so that the full
filename wouldn't used. (In above example, the full filename is unavoidably
generated in dos, this looks cumbersome and is not necessary as the
index.html would be placed in the same directory as the gif files)

Any help or advice would be appreciated!
Thank you!

Todd Vargo

unread,
Sep 14, 2001, 3:21:43 PM9/14/01
to

"Alfred Mansfield" <alm...@hotmail.com> wrote in message
news:Gvpo7.9028$Pm5.1...@news2-win.server.ntlworld.com...

:: Make the following additions (no changes to original code)
@echo off
if makehtml==%1 goto makehtml
for %%? in (*.gif) do call %0 makehtml %%?
goto end

:makehtml


> command/c FOR %%n in (1 2) DO prompt $la href="%1"$g$limg src="%1" alt="1"
> width="100" height="100"$g$l/a$g $_ |FIND/v "prompt">_____
>
> type _____|find "a href=">>index.html

:end

> ---------------------------

--
Todd Vargo (body of message must contain my name to reply by email)

Herbert Kleebauer

unread,
Sep 14, 2001, 4:08:12 PM9/14/01
to

Alfred Mansfield wrote:
>
> Hi!
>
> Can someone help me with this problem?
>
> I have a folder filled with 50 or so picture files (gif).
>
> I want to write a batchfile which can be placed inside this folder and upon
> excuting it, it would automatically generate a series of lines; shown below:
>
> ---------------------------
> <a href="PICT~A.gif"><img src="PICT~A.gif" alt="1" width="100"
> height="100"></a>
> <a href="PICT~B.gif"><img src="PICT~B.gif" alt="1" width="100"
> height="100"></a>
> ...
> <a href="PICT~X.gif"><img src="PICT~X.gif" alt="1" width="100"
> height="100"></a>
> ---------------------------

@echo off
echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>edl.com
echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU!WvX0GwUY Wv;ovBX2Gv0ExGIuht6>>edl.com
echo ?@}I{uNWEF~NuCIOEFAKLCK_Ij@KEuHAEFCKYCK_[h@{HM?cCGu?GwHmis>>edl.com
echo CGH`LbuuGN@@MrzGgbgC?oG?I_DgoNOG?w@OgLNuuroD@?FHoGpBBDcB?1>>edl.com
echo ?pIoBzaMB{bMBV}MxvHmE?coF?DO~yanxCO_p?@?lpZrH~sa`LyNHKqDGw>>edl.com
echo QVTNG`BQEKICtdL{D?{esLysICu_{OuD@sBzEKHt~F@ogFHYq`EE{S~{Hq>>edl.com
echo bgC[Lr@CE{HQ}@ExuBvRmBBwjFCs?osqs?}n`LKLj?o{}HwJvBTrB{EKt~>>edl.com
echo ~1}HGGHB{bB}}KGuJAxLCSK}BwuNB_FE{sCIE?FAupCKE?NAHQNJwLECuQ>>edl.com
echo sa{Oe~CK~CIoCKe?KEFBBvCCIEFBBvC?y1jnj@ComJYJpB{BijZN}mJquj>>edl.com
echo B{}]JqJBBcBTmKJ\jbB{]KFrj~CIE?jABrokrAA_@NJBHmBTnMR1JyjxBo>>edl.com
echo IxrhgBFsj?]rM}s~guspj?Trb{gA{OsLXssTsy{Ok{cQ{dsHhsKdsQ{Sq{>>edl.com
echo jQKqsHVk_OCAx@b@f{W@CosI}1BHIz}hjzK}G~guNw[uNwOB@MD@CwDCOO>>edl.com
echo Tmzo`uBcTmJqZjBktc{OAyfIZp?oIEFBAfCKFMj~CIE?jBOpx{ERzDt`jC>>edl.com
echo ?ol{OOzDt`jCAoc{FOzMt`ICC_KgF[FI?WEg@[Wh?KEu~N~BQr{DNgLo}J>>edl.com
echo ?tgBgIoqh?ooU}B\EuJAuzC?rCGOCyF?EEsPwrj~vPjrB{EKt~~1}HCGHB>>edl.com
echo {bB}}KRNxbBzEK_B]\CMaAy?sexCM_H?@_`LJNDB`Lbca??ao??CO?0>>edl.com

dir /b *.gif >index.htm
dir /b *.jpg >>index.htm
edl "" "<a href=$22$#0$22><img src=$22$#0$22 alt=$22$#0"<index.htm >_.1
edl "" "$#0$22 width=$22100$22 height=$22100$22></a>"<_.1 >index.htm
del _.1
del edl.com


:: usage: edl "string1" "string2" <infile >outfile
:: replaces any non empty line in infile by string2
:: (a line is non empty if it contains at least one
:: character greater 0x20) and writes it to outfile.
::
:: Any character in string1 separates words
::
:: string2 can contain:
:: $00-$ff : hexbytes
:: $:abcd : input line [ab:cd] ab,cd hex values
:: $#0 : complete input line
:: $#n (n=1..8) : n. word in input line
:: $#9 : 9. word (or last word if there are
:: more than 9 words) in input line
:: $l : line till first separator char
:: $L : line till last separator char
:: $r : line after first separator char
:: $R : line after last separator char
:: $ty : year
:: $tm : month
:: $td : day

Todd Vargo

unread,
Sep 14, 2001, 4:15:28 PM9/14/01
to

"Todd Vargo" <t...@birdlover.com> wrote in message
news:9ntlja$9mlkp$1...@ID-25025.news.dfncis.de...

>
>
> :: Make the following additions (no changes to original code)
> @echo off
> if makehtml==%1 goto makehtml
> for %%? in (*.gif) do call %0 makehtml %%?
> goto end
>
> :makehtml
> > command/c FOR %%n in (1 2) DO prompt $la href="%1"$g$limg src="%1"
alt="1"
> > width="100" height="100"$g$l/a$g $_ |FIND/v "prompt">_____
> >
> > type _____|find "a href=">>index.html
>
> :end
>
> > ---------------------------

Also, if your interested in using Qbasic, here is an old batch you could
look at too. It don't do exactly what you want (displays all .gif files on a
single page), but you can possibly figure it out on your own.


:: Gif2htm.bat requires Qbasic.exe to be in your path.
:: Written by Todd Vargo in Windows 98 on Nov 3, 1999
@echo off
if not "%1"=="/?" goto doit
echo.
echo Makes Allgifs.htm of all .GIF images within any directory.
echo.
echo Makehtm [path] [/?]
echo.
echo path - Specifies optional directory to create HTM file in.
echo (Defaults to current directory if path not given)
echo /? - Displays this help
echo.
echo Supports drag & drop of any folder.
goto end
:error
echo [%1] is not a directory!
goto end
:doit
if not exist %1.\nul goto error
dir /b %1.\*.gif>gif2htm1.txt
echo> gif2htm1.bas l$=chr$(60):g$=chr$(62):q$=chr$(34)
echo>>gif2htm1.bas open"gif2htm1.txt"for input as #1
echo>>gif2htm1.bas open"%1.\allgifs.htm"for output as #2
echo>>gif2htm1.bas ?#2,l$+"html"+g$+l$+"center"+g$
echo>>gif2htm1.bas do while not eof(1):x=x+1:line input #1,f$
echo>>gif2htm1.bas ?#2,l$+"p"+g$+l$+"img src="+q$+f$+q$+"
alt="+q$+mid$(f$,1,len(f$)-4)+q$+g$
echo>>gif2htm1.bas loop:?#2,l$+"/center"+g$+l$+"/html"+g$:close
echo>>gif2htm1.bas if x=0 then kill"%1.\allgifs.htm"
echo>>gif2htm1.bas system
qbasic /b /run gif2htm1
del gif2htm1.*
if not "%windir%"=="" if exist %1.\allgifs.htm start /max %1.\allgifs.htm
cls
:end
echo.

BTW, I don't write code in this compact fashion any more. If you can't
figure it out to modify it, then pass it up because I'm not going into an
off topic 'How to use Qbasic' type of thread.

Ted Davis

unread,
Sep 14, 2001, 4:59:42 PM9/14/01
to

As it happens, I'm working on a related problem in another window at
this time. I'm using AWK scripts to read the files and replace
replacable parameters. Your problem is much simpler since you have
only one variable.

@echo off
DIR /b *.gif > }{.txt
echo {printf( "<a href=\"PICT~%%s\"><img src=\"PICT~%%s\" alt=\"1\"
width=\"100\" height=\"100\"></a>\n", $0, $0) } > }{.awk
gawk -f}{.awk }{.txt > out.txt
del }{.*


Where gawk is the appropriate version of the gawk interpreter for your
OS - see <http://gearbox.maem.umr.edu/~batch/multilingual.html> for
background information and downloading location (it's completely free
(a GNU port under the FSF's GPL)). Real lines are indented two spaces
- anything against the margin wrapped and is part of the line above.

When run against my c:\myfiles directory, it produced this output:

<a href="PICT~east.section.gif"><img src="PICT~east.section.gif"


alt="1" width="100" height="100"></a>

<a href="PICT~Schroedinger-cat-l.gif"><img
src="PICT~Schroedinger-cat-l.gif" alt="1" width="100"
height="100"></a>
<a href="PICT~ted_at_work.gif"><img src="PICT~ted_at_work.gif" alt="1"


width="100" height="100"></a>

<a href="PICT~west.section.gif"><img src="PICT~west.section.gif"


alt="1" width="100" height="100"></a>

If "PICT~" is part of the real file names, remove it from the printf()
string. To insert more instances of the file name, just insert "%%s"
where you want it and and another ", $0" to the printf() arguments.

T.E.D. (tda...@gearbox.maem.umr.edu)
SPAM filter: Messages to this address *must* contain "T.E.D."
somewhere in the body or they will be automatically rejected.

Dr John Stockton

unread,
Sep 14, 2001, 2:56:09 PM9/14/01
to
JRS: In article <Gvpo7.9028$Pm5.1...@news2-win.server.ntlworld.com>,
seen in news:alt.msdos.batch, Alfred Mansfield <alm...@hotmail.com>
wrote at Fri, 14 Sep 2001 16:38:48 :-

>
>I have a folder filled with 50 or so picture files (gif).
>
>I want to write a batchfile which can be placed inside this folder and upon
>excuting it, it would automatically generate a series of lines; shown below:
>
>---------------------------
><a href="PICT~A.gif"><img src="PICT~A.gif" alt="1" width="100"
>height="100"></a>


Using my program COLS, via sig line 3, this would be a one-line job if
we had longer lines. As is, we need 2 lines (newsreader wraps the
first), and one for tidiness. #60 = < #62 = > #34 = "


DIR /b *.gif | COLS #60 'a * 'href= #34 1- #62 #60 'img * 'src= #34
1- #34 * 'alt= #34 '1 #34 * 'width= #34 '100 #34 > xxx

COLS <xxx 1- * 'height= #34 '100 #34 #62 #60 '/a #62 > yyy.htm

DEL xxx


COLS.PAS contains instructions.


Another way would be with MiniTrue, from <URL: http://www.pagesz.net/~mi
nitrue/>, or presumably SED - you need an editor that can recognise text
(here a whole line) and repeat it at will. As above, you just have the
tiresome matter of representing all those potent characters. The basic
job could be

DIR *.gif /b | MTR -x+ -no - "^(.*)\r$" = "xx \1 yy \1 zz\r"

and you could use later passes to expand xx yy zz ...

SED is more standard, but I'm not familiar with it.

--
© John Stockton, Surrey, UK. j...@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL: http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
PAS, EXE in <URL: http://www.merlyn.demon.co.uk/programs/> - see 00index.txt.
Do not Mail News to me. Before a reply, quote with ">" or "> " (SoRFC1036)

laura fairhead

unread,
Sep 15, 2001, 2:19:48 PM9/15/01
to
On Fri, 14 Sep 2001 16:38:48 -0700, "Alfred Mansfield" <alm...@hotmail.com> wrote:

You can loop through the .GIF files with a FOR loop, and use a
recursive call to the batch so that for each file name you append
the formatted output to the file. With an initial one-off
recursive call to execute the whole thing with stdout redirected
it should be pretty fast (100 files take about 3 seconds here).

===================[START OF CODE]===================================
@ECHO OFF
IF !%2==!. %3
%COMSPEC%/C %0 . . GOTO:MAIN>index.html
GOTO OUT
:MAIN
FOR %%_ IN (*.GIF) DO CALL %0 %%_ . GOTO:GIF
GOTO OUT
:GIF
PROMPT $LA HREF="%1"$G$LIMG SRC="%1" ALT=1 WIDTH=100 HEIGHT=100$G$L/A$G
ECHO ON
%=%
@ECHO OFF
:OUT
===================[END OF CODE]=====================================


--
: ${L} # http://lf.8k.com:80

>
>

Alfred Mansfield

unread,
Sep 16, 2001, 1:23:47 AM9/16/01
to
Thank you all!!!!!!!!!!!!!!!!!!!!!!!!!

Most of your help/advice (solution) worked!!

Thank very much!

"Alfred Mansfield" <alm...@hotmail.com> wrote in message
news:Gvpo7.9028$Pm5.1...@news2-win.server.ntlworld.com...

Alfred Mansfield

unread,
Sep 16, 2001, 1:28:35 AM9/16/01
to
Hi!

Just wondering, what program did you use to make the com file?

It's very direct.


"Herbert Kleebauer" <kl...@unibwm.de> wrote in message
news:3BA263AC...@unibwm.de...

Herbert Kleebauer

unread,
Sep 16, 2001, 7:05:05 AM9/16/01
to
Alfred Mansfield wrote:
>
> Hi!
>
> Just wondering, what program did you use to make the com file?

It is a normal assembler program (see listing below) which
is converted to an ascii only format with the following batch:

::----------------------------------------------------------------------

rem - save the lines below as CONVERT.BAT
rem - write a COM program and assemble it with ORG=0x178 (PROG.COM)
rem (you must not use the standard ORG=0x100 for this com program)
rem - enter: CONVERT PROG.COM PROG.BAT
rem - the BATCH file PROG.BAT contains an encoded form of PROG.COM

@echo off
echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>bat.com
echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU!WvX0GwUY Wv;ovBX2Gv0ExGIuht6>>bat.com
echo ??wQ@tyM?WxI?@zA=`Lbw?y_y~?_xA[bz?B_L??oAN`_H?e?as?Fx?pkz?>>bat.com
echo B_}A[aIA]b@MCs?A_rVAgr?\gBGpangV_~r?TO?wGJLy?hKxAG@z?G`L?K>>bat.com
echo K?wQO`LRaRPdwA_by??cxA_bL?@O=Et`x?y_z?P_L?@oXZ`SdBW\ngbTiA>>bat.com
echo _Syi?To_gD_lWPOOnSOOOTg`ODgDCDgLCDgNCDggCDgrKDgtKDgWKDYdKT>>bat.com
echo \QQTDDDTQXTTCqWP}=w@s`aTnbmSILl@gbdTo_n@EwCTokO@mwWDOosPW=>>bat.com
echo kOrFsTnsAP~c?@xHOTV`TPoWuDTvFTV_XPnzuPWAuTuFqSwDoStHFTusgD>>bat.com
echo a}}Oms`DlnbTdILOngbT}o_?`a}SbmsPLlnD??I??~?OBA@TEDCTHGFTKJ>>bat.com
echo ITNMLTQPOTTSRTWVUTZYXTp\[D`_1TcbaTfedTihgTlkjTonmTrqpTutsT>>bat.com
echo xwvT=zyD?}=D????}}??s`aTnbmSILl@gbdTg_nP0>>bat.com
bat.com <%1 >%2
del bat.com

::----------------------------------------------------------------------

; @=$100
@=$178

;********** get separators ************

move.w #$81,r5
movu.bw -1.b(r5.w),r6
move.w #.wl10,lab1
move.w #_30,lab2
br.b _31
_30:
move.w r5,string1
move.w #_40,lab2
_31: br.w .wl10
_40: dec.w r5
move.w r5,string2
move.w r6,r0
move.b r0,(r5.w)

;************ get date ****************
move.b #$2a,m0 ; get date function
trap #$21 ; call dos
move.w r2,r0 ; year
divu.b c100,m0|r0 ; last 2 digits -> m0
lsr.w #8,r0 ; last 2 digits -> r0
move.w #date,r3 ; adr of write buffer
bsr.w _10 ; output in write buffer
move.b m1,r0 ; month
bsr.w _10 ; output in write buffer
move.b r1,r0 ; day
move.w #readline,-(sp) ; return to readline

_10: divu.b c10,m0|r0 ; r0=high m0=low digit
add.w #'00',r0 ; convert to ascii
move.w r0,(r3.w) ; copy in write buffer
inc.w r3 ; inc write pointer
inc.w r3 ; inc write pointer
eor.w r0,r0 ; clear r0
rts.w

c100: dc.b 100 ; constant 100
c10: dc.b 10 ; constant 10


;****** read next line from stdin *****
readline:
eor.w r0,r0
move.b r0,intoken
move.w r0,sep1
move.w #token1,r5
move.w r5,r6
move.w #18*2,r2
_05: move.b #0,(r6.w)
inc.w r6
dbf.w r2,_05
move.w #buf,r6
move.w #1,r2
eor.w r3,r3
eor.w r4,r4

_10: move.b #$3f,m0
move.w r6,r1
trap #$21
bcs.b .x200
or.w r1,r1
bmi.b .x200
dec.w r0
sne.b endflag
bne.b _30
move.b (r6.w),r0
cmp.b #$0d,r0
beq.b _10
cmp.b #$0a,r0
beq.b _30
cmp.b #$20,r0
bls.b _20
inc.w r4
_20:
tst.b #$ff,intoken
bne.b _90

bsr.w tst_sep
bcs.b _91
move.w r6,(r5.w)
inc.w r5
inc.w r5

_90: move.w r6,(r5.w) ; suppose EOF
inc.w (r5.w)
bsr.w tst_sep
bcc.b _91
move.w r6,(r5.w)
inc.w r5
inc.w r5
cmp.w #token9,r5
bls.b _91
subq.w #4,r5
_91: inc.w r6
br.b _10

.x100: eor.b r0,r0
inc.b r0
.x101: move.b #$4c,m0
trap #$21
.x200: eor.b r0,r0
br.b .x101


_30: move.w r6,token0+2
tst.w #$ffff,sep1
bne.b _31
move.w r6,sep1
move.w r6,sep9
_31:
;****** test if line is empty *****

move.w string2,r5
dec.w r4
bpl.b _40
move.w #empty,r5
_40:

movu.bw (r5.w),r6
inc.w r5

;******** write line to stdout ********

writeline:
move.w #_10,lab1
move.w #_30,lab2
.wl10:
_10: dec.w r6
bmi.b .x200
movu.bw (r5.w),r0
inc.w r5
cmp.b #'"',r0
beq.b _20
jmp.w (lab1)
_20: jmp.w (lab2)
_30: move.w #_50,lab2
_31: move.w #_40,lab1
br.b _10

_90: move.w #$0104,r1
br.b _10
_91: move.w sep1,r4
_99: eor.w r3,r3
br.b _73
_92: move.w sep9,r4
br.b _99
_93: move.w sep9,r3
_98: inc.w r3
move.w token0+2,r4
br.b _72
_94: move.w sep1,r3
br.b _98

_70: move.w #_71,lab1
_79: br.b _10
_71: sub.b #'0',r0
lsl.w #2,r0
move.w r0,r3
move.w token+2(r3.w),r4
_73: move.w token(r3.w),r3
_72: cmp.w r4,r3
bhs.b _31
move.b (r3.w),r0
inc.w r3
bsr.w put_byte
br.b _72

_45: dec.b m1
beq.b _44
_42: bsr.w put_byte
br.b _31

_41: cmp.b #'#',r0
beq.b _70
cmp.b #'t',r0
beq.b _80
cmp.b #':',r0
beq.b _90
cmp.b #'l',r0
beq.b _91
cmp.b #'L',r0
beq.b _92
cmp.b #'R',r0
beq.b _93
cmp.b #'r',r0
beq.b _94

or.b #$20,r0
sub.b #'a'-10,r0
bpl.b _43
add.b #'a'-10-'0',r0
_43: lsl.w #4,r3
add.w r3,r0
dec.b r1
beq.b _45
move.w r0,r3
_49: br.b _79

_44: dec.b r0
dec.b m0
movu.bw r0,r4
movu.bw m0,r3
add.w #buf,r3
add.w #buf,r4
inc.w r4
cmp.w token0+2,r4
bls.b _72
move.w token0+2,r4
br.b _72

_40: cmp.b #'$',r0
bne.b _42
move.w #2,r1
eor.w r3,r3
move.w #_41,lab1
br.b _49


_80: move.w #_81,lab1
br.b _49
_81: cmp.b #'y',r0
bne.b _82
move.w #year,r3
br.b _89
_82: cmp.b #'m',r0
bne.b _83
move.w #month,r3
br.b _89
_83: cmp.b #'d',r0
bne.b _84
move.w #day,r3
_89: move.b (r3.w),r0
bsr.w put_byte
move.b 1.b(r3.w),r0
bsr.w put_byte
_84: br.w _31

_50:

;****** test if all done *****
tst.b #$ff,endflag
bne.w .x100

move.b #$0d,r0
bsr.w put_byte
move.b #$0a,r0
bsr.w put_byte
br.w readline


tst_sep: ; carry=0 if no separator char
; carry=1 if separator char

move.w r5,-(sp)
move.w string1,r5
_30: cmp.w string2,r5
bhs.b _10
cmp.b (r5.w),r0
beq.b _20
inc.w r5
br.b _30

_10: bclr.w #0,sr
br.b _21
_20: tst.w #$ffff,sep1
bne.b _40
move.w r6,sep1
_40: move.w r6,sep9
bset.w #0,sr
_21: scc.b intoken
move.w (sp)+,r5
rts.w


put_byte:
movem.w r0-r7,-(sp)
move.b r0,obuf
move.b #$40,m0
move.w #obuf,r1
move.w #1,r2
move.w r2,r3
trap #$21
movem.w (sp)+,r0-r7
rts.w

empty: dc.b 5,'"$#0"'
endflag:dc.b 0

token:
token0: dc.w buf
blk.w 1
token1: blk.w 2
token2: blk.w 2
token3: blk.w 2
token4: blk.w 2
token5: blk.w 2
token6: blk.w 2
token7: blk.w 2
token8: blk.w 2
token9: blk.w 2
intoken:blk.b 1
sep1: blk.w 1
sep9: blk.w 1

date:
year: blk.b 2
month: blk.b 2
day: blk.b 2
string1:blk.w 1
string2:blk.w 1
lab1: blk.w 1
lab2: blk.w 1
obuf: blk.w 1
buf: blk.w 1

Alfred Mansfield

unread,
Sep 17, 2001, 7:18:55 PM9/17/01
to
Hello!

Is there/can you make a simple user-prompting exectable similar to "bat.com"
in your example which can be created in a batchfile.

This com/exe would simply pause the batchfile and prompt the user to enter a
string. It would then set this string as a variable.

It would work just like ASKENV.exe (if you have ever heard of it).
The problem with askenv is that I can't "insert" it into the batchfile just
like how bat.com was inserted.

This is useful because then batchfiles can be distributed without the user
having to install/copy extra msdos executables onto their hard disk.

Also, it doesn't require the user to input information in the batchfile
using the traditional method where a msdos window has to be opened and the
command had to be typed in manually followed by substituting %n variables.

Thanks for your help!


Herbert Kleebauer

unread,
Sep 17, 2001, 5:40:47 PM9/17/01
to
Alfred Mansfield wrote:
>
> Hello!
>
> Is there/can you make a simple user-prompting exectable similar to "bat.com"
> in your example which can be created in a batchfile.
>
> This com/exe would simply pause the batchfile and prompt the user to enter a
> string. It would then set this string as a variable.

@echo off
echo BATCH_INPUT___hgQX-PPP_XPPP E#HH0E50EG0Ef0Ehs>myinput.com
echo myinput.bat hoAX5@@PZYh@xX5@D3!r/P[WX,b,-PZh>>myinput.com
echo X3!X2ErP,{,{PYX4=0ErWX,j,-PZh@@X3!=set input>>myinput.com

echo Enter your name:
myinput.com
call myinput.bat
echo Hello %input%


echo
XP,;P_,EP0Ex0Ez0Em3Em-ZBP(Eiu![j@_YQ2M@53#@CI~.8'uxCISZ[SC5.bM!C>ech.com
ech "Enter your name: "
myinput.com
call myinput.bat
echo Hello %input%


Alfred Mansfield

unread,
Sep 18, 2001, 10:32:10 PM9/18/01
to
Thank you very much!! Very clever!! :)


"Herbert Kleebauer" <kl...@unibwm.de> wrote in message

news:3BA66D...@unibwm.de...

Dr John Stockton

unread,
Sep 18, 2001, 6:58:00 PM9/18/01
to
JRS: In article <avop7.21538$mj6.3...@news6-win.server.ntlworld.com>

, seen in news:alt.msdos.batch, Alfred Mansfield <alm...@hotmail.com>
wrote at Mon, 17 Sep 2001 16:18:55 :-

>
>Is there/can you make a simple user-prompting exectable similar to "bat.com"
>in your example which can be created in a batchfile.
>
>This com/exe would simply pause the batchfile and prompt the user to enter a
>string. It would then set this string as a variable.
>

If you do not want raw binary in a script - and raw binary is
susceptible to un-noticed damage if the script is mis-edited,
then see whether my NQYR does what you need. Fetch via sig line 3.


{ NQYR EnvNam aaa bbb ccc
will write "aaa bbb ccc ? ", will read a line, and do the equivalent of
SET UpperCase(EnvNam)=<line read>

One character is ignored after EnvNam; otherwise, spaces and tabs count }


So NQYR fodder What's for lunch, Mum
might set FODDER to Roast Beef and Yorkshire Pudding

Alfred Mansfield

unread,
Sep 19, 2001, 2:22:23 PM9/19/01
to
Just wondering, is this part really necessary? Or is it to demonstrate that
ECHO in dos can also be assembled this way (as with the myinput.com)?

Regards..

"Herbert Kleebauer" <kl...@unibwm.de> wrote in message

news:3BA66D...@unibwm.de...
> Alfred Mansfield wrote:

snip-------

> echo
> XP,;P_,EP0Ex0Ez0Em3Em-ZBP(Eiu![j@_YQ2M@53#@CI~.8'uxCISZ[SC5.bM!C>ech.com
> ech "Enter your name: "
> myinput.com
> call myinput.bat
> echo Hello %input%

snip-------


Herbert Kleebauer

unread,
Sep 19, 2001, 7:00:00 AM9/19/01
to
Alfred Mansfield wrote:
>
> Just wondering, is this part really necessary? Or is it to demonstrate that
> ECHO in dos can also be assembled this way (as with the myinput.com)?
>
> Regards..

>

> > echo
> > XP,;P_,EP0Ex0Ez0Em3Em-ZBP(Eiu![j@_YQ2M@53#@CI~.8'uxCISZ[SC5.bM!C>ech.com
> > ech "Enter your name: "
> > myinput.com
> > call myinput.bat
> > echo Hello %input%
>

Sorry, was a wrap around. Should be:

echo XP,;P_,EP0Ex0Ez0Em3Em-ZBP(Eiu![j@_YQ2M@53#@CI~.8'uxCISZ[SC5.bM!C>ech.com

ech.com does not append a <CR><LF> so your input starts after
Enter your name: and not in the next line.

Herbert

Alfred Mansfield

unread,
Sep 19, 2001, 11:29:05 PM9/19/01
to
Sorry! I should have been more observant!!

Thanks again!!

"Herbert Kleebauer" <kl...@unibwm.de> wrote in message

news:3BA87A...@unibwm.de...

Alfred Mansfield

unread,
Sep 20, 2001, 12:13:18 AM9/20/01
to

"laura fairhead" <laura_f...@my-deja.com> wrote in message
news:3ba39a89...@news.cis.dfn.de...

> ===================[START OF CODE]===================================
> @ECHO OFF
> IF !%2==!. %3
> %COMSPEC%/C %0 . . GOTO:MAIN>index.html
> GOTO OUT
> :MAIN
> FOR %%_ IN (*.GIF) DO CALL %0 %%_ . GOTO:GIF
> GOTO OUT
> :GIF
> PROMPT $LA HREF="%1"$G$LIMG SRC="%1" ALT=1 WIDTH=100 HEIGHT=100$G$L/A$G
> ECHO ON
> %=%
> @ECHO OFF
> :OUT
> ===================[END OF CODE]=====================================

After studying this batchfile over and over again I still get quite
confused!
What does "%=%" do?

Thanks!
PS. It is very fast!!


laura fairhead

unread,
Sep 22, 2001, 8:02:08 AM9/22/01
to

It doesn't really do anything. In general %var% always gets replaced with
the contents of the variable named 'var'. There are no special /magic
variable names. So %=% will just get replaced with what is in the variable
named '='. The idea is that since you can't actually legally define a variable
with that name it will always evaluate to nothing at all. So it's really
just the same as a blank line when it comes down to it, and a blank line
would have been fine here. I just use that so that it is clear a blank
line should be there that's all. Since ECHO is ON at that point the
PROMPT gets printed, and this is why you couldn't just use a comment;

REM **** this line is just a place-holder ****

(because that would print the PROMPT and the REM ...... )

What bits of the batch don't you understand in particular?

The main thing going on is just the recursion mechanism on line2;
IF !%2==!. %3

It checks that parameter #2 is a period, and if it is then the
command in parameter #3 is executed. This means that any call to
the program like;

PROGRAM parameter1 . COMMAND

Gets to that line, and after variables are substituted (DOS always
substitutes all the variables before it does anything else) you
would get;

IF !.==!. COMMAND

'COMMAND' is always just 'GOTO:LABEL', so it will jump into the
program at the point ':LABEL'.

The first time this is done is on line 3 (when the program is
initially run from the command line);

%COMSPEC%/C %0 . . GOTO:MAIN>index.html

It just re-runs the program but the new run will jump in at ':MAIN'
(thus avoiding an infinite loop). All it is doing here is redirecting
output of the program to the file 'index.html'.

It is as if you were running some batch that produced output on the
screen, if you wanted that to go to a file instead you would use;

%COMSPEC%/C PROGRAM >file

Because %0 is the batch programs name all that is happening is
the program is doing this by itself and saves you typing.

Everything that happens after that goes to the 'index.html' file
instead of the screen.

After that it is doing the loop bit, because you want to do something
for each *.GIF file. You can't do more than one command in a FOR
loop so for each *.GIF file it issues a (returning) CALL;

CALL %0 %%_ . GOTO:GIF

That calls the program with the parameters;
%1 = GIF filename
%2 = .
%3 = GOTO:GIF

So when you get to line 2 and variables %2 and %3 are replaced you get;

IF !.==!. GOTO:GIF

The period in parameter 2 triggers the line to execute the command
and that is a GOTO:GIF. So it goes straight to the bit for outputting
your formatted HTML lines;

:GIF
PROMPT $LA HREF="%1"$G$LIMG SRC="%1" ALT=1 WIDTH=100 HEIGHT=100$G$L/A$G
ECHO ON
%=%
@ECHO OFF
:OUT

The PROMPT is set, just like in your original program. Turning ECHO ON
and then having that blank line means that one PROMPT gets output,
but of course because the output of the program is redirected now to
the file 'index.html' it gets added to that file instead of the screen.

I hope that clarifies it some for you. If there is still anything particular
you don't quite understand about it and want me to explain, then just
shout and I'll do my best....

--
: ${L:-aura} # http://lf.8k.com:80


0 new messages