	implicit none
	integer maxmoves,maxnode
	parameter (maxnode=140)
	parameter (maxmoves=500)
c	character*80 long(maxnode)
c	integer llong(maxnode)
	character*80 short(maxnode)
	integer lshort(maxnode)
	character*90 line
	integer maxverbs
	parameter(maxverbs=15)
	integer move(maxmoves,maxverbs)
	integer nch,n,node,nnodes,nmoves
	character*12 filenm,link,last
	integer k,j,lnode
c==
	open(unit=2,file='text.txt',status='old')
	read (2,100) nch,line
100	format(q,a)

	read(line,*) n
	if (n.ne.1) stop'bad section number'
c	do k=1,maxnode
	do k=1,10000
	read (2,100) nch,line
	n=index(line,',')
	if (n.eq.0) n=nch+1
	nnodes = node
c	read(line(1:n-1),*),node
	read(line(1:n-1),*),node
	if (node.lt.0) goto 10
c	long(node)=line(n+1:nch)
c	llong(node)=nch-n
	enddo

10	type *,'read ',nnodes,' nodes'
	read (2,100) nch,line
	read(line,*) n
	if (n.ne.2) stop'bad section number 2'
	do k=1,maxnode
	read (2,100) nch,line
	n=index(line,',')
	if (n.eq.0) n=nch+1
	read(line(1:n-1),*),node
	if (node.lt.0) goto 20
	short(node)=line(n+1:nch)
	lshort(node)=nch-n
	enddo

20	read (2,100) nch,line
	read(line,*) n
	if (n.ne.3) stop'bad section number 3'
	do k=1,maxmoves
	read (2,100) nch,line
	read(line,*) n
	if (n.lt.0) goto 30
	read(line,*) (move(k,j),j=1,maxverbs)
	nmoves = k
	enddo
	
30	close(unit=2)
	k=1

	open(unit=2,file='text.txt',status='old')
	read (2,100) nch,line
	read(line,*) n
	if (n.ne.1) stop'bad section number'
	read (2,100) nch,line
	n=index(line,',')
	if (n.eq.0) n=nch+1


	do node=1,nnodes
	write(filenm,200) node
200	format('node',i3.3,'.html')
	type *,'Doing node',node

	open(unit=3,status='new',file=filenm,carriagecontrol='list')
	write(3,*)'<html>'
	write(3,*)'<head>'
	write(3,*)'<link rev=made href="mailto:advax@triumf.ca">'
	write(3,*)'<!-- Colossal Cave Node ',node,' -->'
	if (lshort(node).gt.0)
	1 write(3,*)'<title>',short(node)(1:lshort(node)),'</title>'
	write(3,*)'</head>'
	write(3,*)'<body>'


65	read(line(1:n-1),*),lnode
	if (lnode.ne.node) goto 60
	write(3,*)line(n+1:nch)
	read (2,100) nch,line
	n=index(line,',')
	if (n.eq.0) n=nch+1
	goto 65

60	write(3,*)'<p>'
	if (move(k,1).ne.node) stop'node phase in move'
	
	write(3,*)'<hr>' ! horizontal line
45	last=link
	if (move(k,3).gt.nnodes) then
	    write(3,*)'<!-- special dest. ',move(k,3),' -->'
	    type *,'special destination ',move(k,3)
	endif
	write(link,200) move(k,3)
	if (move(k,2).ne.0) write(3,*)'<!-- conditional ',move(k,2),' -->'
	do j=4,10
	if (move(k,j).eq.1) write(3,*)
	1 '<a href="',last,'"><img src="OK.gif" alt="OK "></a>'
	if (move(k,j).eq.3) write(3,*)
	1 '<a href="',link,'"><img src="enter.gif" alt="Enter "></a>'
	if (move(k,j).eq.4) write(3,*)
	1 '<a href="',link,'"><img src="upstairs.gif" alt="Upstairs "></a>'
	if (move(k,j).eq.5) write(3,*)
	1 '<a href="',link,'"><img src="dstairs.gif" alt="Downstairs "></a>'
	if (move(k,j).eq.7) write(3,*)
	1 '<a href="',link,'"><img src="forward.gif" alt="Forward "></a>'
	if (move(k,j).eq.8) write(3,*)
	1 '<a href="',link,'"><img src="back.gif" alt="Back "></a>'
	if (move(k,j).eq.11) write(3,*)
	1 '<a href="',link,'"><img src="exit.gif" alt="Exit "></a>'
	if (move(k,j).eq.19) write(3,*)
	1 '<a href="',link,'"><img src="in.gif" alt="In "></a>'
	if (move(k,j).eq.29) write(3,*)
	1 '<a href="',link,'"><img src="up.gif" alt="Up "></a>'
	if (move(k,j).eq.30) write(3,*)
	1 '<a href="',link,'"><img src="down.gif" alt="Down "></a>'
	if (move(k,j).eq.36) write(3,*)
	1 '<a href="',link,'"><img src="left.gif" alt="Left "></a>'
	if (move(k,j).eq.37) write(3,*)
	1 '<a href="',link,'"><img src="right.gif" alt="Right "></a>'
	if (move(k,j).eq.43) write(3,*)
	1 '<a href="',link,'"><img src="east.gif" alt="East "></a>'
	if (move(k,j).eq.44) write(3,*)
	1 '<a href="',link,'"><img src="west.gif" alt="West "></a>'
	if (move(k,j).eq.45) write(3,*)
	1 '<a href="',link,'"><img src="north.gif" alt="North "></a>'
	if (move(k,j).eq.46) write(3,*)
	1 '<a href="',link,'"><img src="south.gif" alt="South "></a>'
	if (move(k,j).eq.47) write(3,*)
	1 '<a href="',link,'"><img src="ne.gif" alt="NorthEast "></a>'
	if (move(k,j).eq.48) write(3,*)
	1 '<a href="',link,'"><img src="se.gif" alt="SouthEast "></a>'
	if (move(k,j).eq.49) write(3,*)
	1 '<a href="',link,'"><img src="sw.gif" alt="SouthWest "></a>'
	if (move(k,j).eq.50) write(3,*)
	1 '<a href="',link,'"><img src="nw.gif" alt="NorthWest "></a>'
	enddo !j
	k=k+1
c	write(3,*)'<br>'
	if (move(k,1).ne.node) goto 50
	goto 45

50	write(3,*)'</body>'
	write(3,*)'</html>'
	close(unit=3)
	enddo ! node
	end
