Blitz (47/193)

From:David McMinn
Date:8 Aug 2000 at 09:45:40
Subject:Re: Investigator

Hi Tony

> My main prog is just a string of (x)include statements. Would it be
> possible to get it to recognise these and follow the includes to get a
> total report for the whole thing?

Probably :)

> If Curt doesn't have the time, I'll try & give it a go, but I'm
> hopeless when it comes to recursion and I'll need a LOT of guidance
> with the simplest stuff (like how do I recognise the Xinclude
> token??).

Recursion is simple, but has a few pitfalls. All it is is that you have a
function which calls itself. The one thing you MUST make sure of though is that
anything specific to the current iteration is a local variable.

An example would be counting the number of lines in Blitz source code, but
using XInclude's - each time you find an xinclude statement the function calls
itself, but the number of lines in the source code would be a local variable.
Remember that local variables are completely separate between function calls,
even when you have nested function calls to the same function.

Another thing to think of is that if you use Blitz's file I/O then you may
struggle with recursion. Each new nested call to the function must use a
different file number, or you'd screw up an earlier call to the function. Of
course, you could pass the file number as a parameter, and when going one level
deeper, just pass the current file number + 1.

An alternative to recursion might be to scan the files for XInclude's first and
stick all the filenames of the sources into a list. You could then process the
list separately, one file at a time. Disadvantage here would be that the source
would need to be scanned twice, making it a lot slower.

As for detecting the XInclude token, save a program from Blitz that has only
the line XInclude "blah". Now load it up in a hex editor. The first 2 bytes
should be the token for XInclude.



|) /\ \/ ][ |) |\/| c |\/| ][ |\| |\| | dave@satanicdreams.com
http://members.xoom.com/David_McMinn | ICQ=16827694
Don't tell me I'm still on this feckin' island!!!

---------------------------------------------------------------------
To unsubscribe, e-mail: blitz-list-unsubscribe@netsoc.ucd.ie
For additional commands, e-mail: blitz-list-help@netsoc.ucd.ie