Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


Example Picture Viewer

Keywords: 	 Example Picture Viewer

Example:

This script prompts a user for a directory that contains .bmp,.gif and .jpeg files, then displays the graphics, one by one, in an HTML dialog.

WinBatch code:

AddExtender("WWHTM34I.DLL")


BaseDirectory=DirGet()
UseHtmlFile=strcat(BaseDirectory,"Banner_view.html")
temp= strcat(BaseDirectory,"temp.html")

WinTitle("","Picture Peeker")

;This is an image file viewer.

;Ask user for directory
flags=1|2
dir1=AskDirectory("Select the Working Directory", "", "","Are you sure?",flags)

srcfolder=dir1
;Change to directory.
DirChange(srcfolder)

; Get and count files, display list.
srclist=FileItemize(strcat(dir1,"*.BMP|*.GIF|*.JPEG"))
srccount=ItemCount(srclist, @tab)
;Message("File list count = %srccount% ", srclist)
xx=1
bb=BinaryAlloc(100000)
While xx <= srccount
gosub dohtmlfixup
url=hBrowse(2,temp,3)
if url=="" then exit
button=hGetVarValue("button","xxx")
endwhile
exit 



:DoHtmlFixup
BinaryEODSet(bb,0)
BinaryRead(bb,UseHtmlFile)

Structure=BinaryTagInit(bb,"{{","}}")

while 1
    structure=BinaryTagFind(structure)
    if structure=="" then break
    wbdata=strtrim(BinaryTagExtr(structure,0))
    wbcmd=strlower(ItemExtract(1,wbdata," "))
    wbparams=strtrim(strsub(wbdata,strlen(wbcmd)+1,-1))
    HtmlValue="???????"
    gosub %wbcmd% ; 
    structure=BinaryTagRepl(structure,HtmlValue)
	 BinaryWrite(bb,temp)
endwhile
return

:Value
   HtmlValue=%wbparams%
   return

:dafile
HtmlValue=""
it=ItemExtract(xx,srclist,@tab)
fillit=strcat(srcfolder,it)
htmlvalue=fillit
xx=xx+1
return

HTML code:

<html>

<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<title>Pic Viewer</title>
</head>

<body bgcolor="#FFFFFF">

<h1 align="center">Picture Viewer</h1>
<div align="center"><center>

<table border="0">
    <tr>
        <td><p align="center">From:</p>
        </td>
        <td><p align="center">{{VALUE SRCFOLDER}}</p>
        </td>
    </tr>
</table>
</center></div>

<p>&nbsp;</p>
<div align="center"><center>
<form method="POST" action="ignored">

<img src="{{dafile}}">

<p><INPUT TYPE="SUBMIT" VALUE="NEXT" name="button">

</form>
</center></div>
</body>
</html>




Article ID:   W14181
Filename:   Example Picture Viewer.txt