XR (Cross Referencer)

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
User avatar
Seb McClouth
Veteran
Posts: 342
Joined: Wed Nov 09, 2005 7:47 am
Location: Inside the Matrix...
Contact:

XR (Cross Referencer)

Post by Seb McClouth »

Hey all

I'm working on a program which, manly makes websites of certain map and it's submaps.

Code: Select all

DECLARE FUNCTION Replace$ (charc AS STRING, strg1 AS STRING, strg2 AS STRING)
DECLARE SUB MakeDirTable (filenr AS INTEGER)
DECLARE SUB MakeMainPage (filenr AS INTEGER)
DECLARE SUB CloseFile (filenr AS INTEGER)
DECLARE FUNCTION formlink$ (char AS STRING)
DECLARE FUNCTION Hundred$ (charac AS STRING)
DECLARE SUB MakeFooter (filenr AS INTEGER)
DECLARE SUB MakeHeader (filenr AS INTEGER, DirN AS STRING, FileN AS STRING, message AS STRING)
DECLARE FUNCTION TRIM$ (chara AS STRING)
DECLARE SUB OpenFile (Fln AS STRING, filenr AS INTEGER)
COMMON SHARED Curdir AS STRING

'make automated system to read firstly BaseDir$
'then make the files (dir-files and filed) for BaseDir$
'etc, where dirname is the dirname.dir/dirname.fil

BaseDir$ = "Novix25"

SHELL "dir " + BaseDir$ + " /b /ad /on > dir.txt"
SHELL "dir " + BaseDir$ + " /b /a-d /on > file.txt"

Curdir = BaseDir$

msg$ = "Welcome to mcclouth.zoastertech.com/nxr -- the Novix Cross Reference"

OpenFile "server\index.htm", 1
MakeHeader 1, "", "", msg$
MakeMainPage 1
MakeFooter 1
CloseFile 1

OpenFile "server\novix25\index.htm", 1
MakeHeader 1, "novix25", "", ""
MakeDirTable 1
MakeFooter 1
CloseFile 1

Curdir = BaseDir$ + "\ASM"


SHELL "del dir.txt"
SHELL "del file.txt"

SHELL "dir " + Curdir + " /b /ad /on > dir.txt"
SHELL "dir " + Curdir + " /b /a-d /on > file.txt"

OpenFile "server\novix25\asm\index.htm", 1
MakeHeader 1, "novix25\asm", "", ""
MakeDirTable 1
MakeFooter 1
CloseFile 1

Curdir = BaseDir$ + "\ASM" + "\GFX"



SHELL "del dir.txt"
SHELL "del file.txt"

SHELL "dir " + Curdir + " /b /ad /on > dir.txt"
SHELL "dir " + Curdir + " /b /a-d /on > file.txt"

OpenFile "server\novix25\asm\gfx\index.htm", 1
MakeHeader 1, "novix25\asm\gfx", "", ""
MakeDirTable 1
MakeFooter 1
CloseFile 1

SUB CloseFile (filenr AS INTEGER)
CLOSE #filenr
END SUB

FUNCTION formlink$ (char AS STRING)
IF INSTR(char, ".") THEN
	formlen% = LEN(char)
	FOR b% = 1 TO formlen%
		IF MID$(char, 1, b%) = "." THEN
			tempname$ = LEFT$(char, b%)
		    
		END IF
	NEXT
	tempname$ = tempname$ + RIGHT$(char, 3)
ELSE
	tempname$ = char
END IF
formlink$ = tempname$ + ".htm"
END FUNCTION

FUNCTION Hundred$ (charac AS STRING)
IF LEN(charac) = 1 THEN
	Hundred$ = "00" + charac
ELSEIF LEN(charac) = 2 THEN
	Hundred$ = "0" + charac
ELSE
	Hundred$ = charac
END IF
END FUNCTION

SUB MakeDirTable (filenr AS INTEGER)
	PRINT #filenr, "<br>"
	PRINT #filenr, "<table>"
	PRINT #filenr, "  <tr>"
	PRINT #filenr, "    <th>Name</th>"
	PRINT #filenr, "    <th>Size</th>"
	PRINT #filenr, "    <th>Time</th>"
	PRINT #filenr, "    <th>Desc</th>"
	PRINT #filenr, "  </tr>"

	filenr2 = FREEFILE
	OPEN "dir.txt" FOR INPUT AS #filenr2
	DO WHILE NOT EOF(filenr2)
		INPUT #filenr2, a$
		PRINT #filenr, " <tr>"
		PRINT #filenr, "   <td><a href=" + CHR$(34) + a$ + ">" + a$ + "</a></td>"
		PRINT #filenr, " </tr>"
	LOOP
	CLOSE #filenr2

	OPEN "file.txt" FOR INPUT AS #filenr2
	DO WHILE NOT EOF(filenr2)
		INPUT #filenr2, a$
		PRINT #filenr, " <tr>"
		linkname$ = formlink(a$)
		PRINT #filenr, "   <td><a href=" + CHR$(34) + linkname$ + CHR$(34) + ">" + a$ + "</a></td>"
		PRINT #filenr, " </tr>"
	LOOP
	CLOSE #filenr2

	PRINT #filenr, "</table>"
END SUB

SUB MakeFileTable (filenr AS INTEGER, filename AS STRING)
	PRINT #filenr, "<br>"
	
	      
	number% = 1

	filenr2 = FREEFILE
	OPEN filename FOR INPUT AS #filenr2
	DO WHILE NOT EOF(filenr2)
		INPUT #filenr2, a$
		PRINT #filenr, "<a href=" + CHR$(34) + formlink$(filename) + " id=" + CHR$(34) + " name=" + CHR$(34) + ">" + Hundred$( _
TRIM$(STR$(number%))) + "</a> " + a$ + "<br>"
	LOOP
	CLOSE #filenr2

END SUB

SUB MakeFooter (filenr AS INTEGER)
	PRINT #filenr, "<br>"
	PRINT #filenr, "<hr>"
	PRINT #filenr, "<center><i>The original LXR software by the <a href=" + CHR$(34) + ">LXR community</a>, this experimental version by <a>McClouth Software</a> for Novix.<br>"
	PRINT #filenr, "nxr kindly hosted by <a href=" + CHR$(34) + ">Zoastertech</a>, 'like a toothbrush for your computer.'"
	PRINT #filenr, "</body>"
	PRINT #filenr, "</html>"
END SUB

SUB MakeHeader (filenr AS INTEGER, DirN AS STRING, FileN AS STRING, message AS STRING)
	PRINT #filenr, "<html>"
	PRINT #filenr, "<head>"
	PRINT #filenr, "<title>NXR / The Novix Cross Reference</title>"
	PRINT #filenr, "</head>"
	PRINT #filenr, "<style>"
	PRINT #filenr, "UL {list-style: 'disc'"
	PRINT #filenr, "</style>"
	
	PRINT #filenr, "<table>"
	PRINT #filenr, "<tr>"

IF message <> "" THEN
	PRINT #filenr, "<td>NXR</td>"
	PRINT #filenr, "<td>" + message + "</td>"
ELSEIF DirN <> "" THEN
	DirN = Replace$(DirN, "\", "/")
	PRINT #filenr, "<td>NXR</td>"
	PRINT #filenr, "<td><a href=" + CHR$(34) + DirN + ">" + DirN + "/" + "<a href=" + CHR$(34) + FileN + ">" +  _
FileN + "</a></td>"
END IF

	PRINT #filenr, "</tr>"
	PRINT #filenr, "</table>"
	PRINT #filenr, ""
END SUB

SUB MakeMainPage (filenr AS INTEGER)
PRINT #filenr, "<br>"
PRINT #filenr, "<table>"
PRINT #filenr, "<tr>"
PRINT #filenr, "<td>"
PRINT #filenr, "<b>Welcome to mcclouth.zoastertech.com/nxr</b><br>"
PRINT #filenr, "NXR, " + CHR$(34) + "the Novix Cross Referencer" + CHR$(34) + " is a software toolset<br>"
PRINT #filenr, "for indexing and presenting source code repositories.<br>"
PRINT #filenr, "NXR is initially targeted at the Novix source code.<br>"
PRINT #filenr, "<br>"
PRINT #filenr, "<b>Browse the code</b><br>"
PRINT #filenr, "This is the browsable source code repository at<br>"
PRINT #filenr, "mcclouth.zoastertech.com/nxr:"
PRINT #filenr, "<ul>"
PRINT #filenr, "<li><a href=" + CHR$(34) + ">Novix 2.5.0.4</a></li>"
PRINT #filenr, "</ul>"
PRINT #filenr, "<b>NXR Source code</b><br>"
PRINT #filenr, "For the interested, the source code will be available<br>"
PRINT #filenr, "soon. Don't hesitate to contact the <a href=" + CHR$(34) + ">webmaster</a>.<br>"
PRINT #filenr, "<br>"
PRINT #filenr, "<b>Thanks</b><br>"
PRINT #filenr, "<a href=" + CHR$(34) + ">Pete Berg's  QB site</a>, <a href=" + CHR$(34) + ">Zoastertech</a>, for their space,<br>"
PRINT #filenr, "everyone over at Pete's QBsite forum for helping<br>"
PRINT #filenr, "along the way. And Z!re for Novix, and giving me<br>"
PRINT #filenr, "permission to use Novix and make this Cross Reference possible.<br>"
PRINT #filenr, "<br>"
PRINT #filenr, "<b>About</b><br>"
PRINT #filenr, "mcclouth.zoastertech.com/nxr is provided as a<br>"
PRINT #filenr, "non-profit service to the public in the hope that<br>"
PRINT #filenr, "it is found useful. It is herded by Sebastian<br>"
PRINT #filenr, "McClouth in his spare time."
PRINT #filenr, "<br>"
PRINT #filenr, "</td>"
PRINT #filenr, "<td>"
PRINT #filenr, "<table>"
PRINT #filenr, "<tr>"
PRINT #filenr, "<td>"
PRINT #filenr, "<img src=" + CHR$(34) + ">"
PRINT #filenr, "</td>"
PRINT #filenr, "</tr>"
PRINT #filenr, "</table>"
PRINT #filenr, "<b>What's new</b><br>"
PRINT #filenr, "07-18-2008 <br>"
PRINT #filenr, "The Noix Cross Reference build officially started.<br>"
PRINT #filenr, "<br>"
PRINT #filenr, "07-15-2008 <br>"
PRINT #filenr, "Today, NXR has been born.<br>"
PRINT #filenr, "</table>"
END SUB

SUB OpenFile (Fln AS STRING, filenr AS INTEGER)
OPEN Fln FOR OUTPUT AS #filenr
END SUB

FUNCTION Replace$ (charc AS STRING, strg1 AS STRING, strg2 AS STRING)

temp$ = charc
b = 1

IF INSTR(charc, strg1) THEN
	FOR a = 1 TO LEN(temp$)
		IF MID$(temp$, a, 1) = strg1 THEN
			MID$(temp$, a, 1) = strg2
		END IF
	NEXT
END IF
Replace$ = temp$
END FUNCTION

FUNCTION TRIM$ (chara AS STRING)
TRIM$ = LTRIM$(RTRIM$(chara))
END FUNCTION
This is what I have this far. Could you guys help me out making an thingy where it 'automaticaly' reads all the files and dirs and converts them to html?

Thx in advance.

Grtz
QBinux is a Linux distribution with the aim of integrating the work of the vast community of free software developers at Pete's QBASIC Site in order to create a modern, performant, safe and easy to use system for system administrators and desktop users.
Post Reply