• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

zXref (version 1.10)

Started by Patrice Terrier, August 14, 2009, 08:25:54 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Patrice Terrier

zXref is based on pbcodec from Borje Hagsten.
It has been reworked to work in plain SDK mode using the latest PB9 string goodies.

It combines the capabilities of pbcodec + inclean into one single small exe, and it is a good companion to the zTrace utility.

zXref, merges the main source code and the private include files into one single file, that is used to create an XREF report, and a new file ready to compile with all un-used SUB and FUNCTION removed from the resulting $xxxxxx.bas file.

Note: YOU must customize the zXref.cfg file with a text editor to match your own PATH environment!

History:
09-13-2009 Version 1.10: - ISFILE has been replaced with zExist to detect files and folders.
09-02-2009 Version 1.09: - Added new checkbox "Clean code", to produce either XREF only or XREF + cleaned code.
08-31-2009 Version 1.08: - Parsing #IF in include file to detect un-used sections (see BuildSingleFile).
                                   - Added zDoEvents() to process pending messages while doing the scan job
                                   - Added ProgressBar to show what the program is doing.
08-19-2009 Version 1.06: - Function detection has been enforced for compatibility with PB9 (the word Function being used in UDT).
                                   - Added METHOD detection.
                                   - No more need to use "EXCLUDE:" in the config file (detect un-used code in the standard includes).
                                   - Better parsing of keywords (UcaseCrunchSpace).
08-18-2009 Version 1.04: CALLBACK and EXPORTED sub/function are not removed from code.
08-18-2009 Version 1.03: combo of pbcodec and inclean.
08-18-2009 Merge the Main source + all Includes (except standard) into one single file.
08-17-2009 Support of José Roca's include files, while standard include files are EXCLUDE from the recursive scan.
08-16-2009 Added zXref.cfg, to resolve missing include path.
08-12-2009 First version

zXref is freeware.

... 
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Bud Meyer

#1
Tests ok for me, but I had to edit this line in IsFileMain because my COMPILE statements are tab indented:
      sBuffer = LTRIM$(zBufin((sFileName), nDone), ANY $SPC & $TAB)

Here's an example of what I mean:
#IF %DestFolder = 0  
   #COMPILE DLL "C:\Program Files\MyFolder\MyProg.exe"
#ELSE  
   #COMPILE DLL "C:\Program Files (x86)\MyFolder\MyProg.exe"
#ENDIF


Also, it generated and left behind a bunch of 0 byte inc files in my folder.

I look forward to future updates of this program. :)

Patrice Terrier

#2
Bud,

I have updated the ZIP file, with a new version. i have done a lot of changes

Here is the result i got on my computer scanning zXref.bas

PBcodec version 1.14 (exe size: 91648 bytes)

¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
PBcodec report: ZXREF.BAS + include files. Generated 08-15-2009, 08:48:13
4154 lines scanned in 0.129 seconds (1925562 lines/minute)
¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤


zXref version 1.00 (exe size: 87040 bytes)

================================================================================
XRef report: ZXREF.BAS + include files. Generated 08-15-2009, 08:47:09
4154 lines scanned in 0.062 seconds (4020000 lines/minute)
================================================================================


QuoteAlso, it generated and left behind a bunch of 0 byte inc files in my folder.
I don't understand what you mean, i do not create any inc files, could you please elaborate?

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Bud Meyer

Quote from: Patrice Terrier on August 15, 2009, 09:06:46 AM
I don't understand what you mean, i do not create any inc files, could you please elaborate?
Many of the includes in my program are stored in a different folder than the main bas file. After running zXref, 0 bytes copies of those "external" includes appear in my program folder and I have to delete them manually.

Patrice Terrier

I am unable to reproduce this behavior, anyone else?
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Trento Castricone

Everything worked as expected , except:
I declared the vaiable "ADlg" twice as a GLOBAL.
zXref noted the problem , but thought one was an array.

The zero length files have the names of the include files and RC file.

Thanks for your efforts

Patrice Terrier

I am on VISTA 64-bit and i can't see any file with zero byte matching the name of the include or rc file.

???
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Trento Castricone

I am using Vista-32.
I LOVE zero lenght files - there can be no problems in them.  Easy to remove.

James C. Fuller

No extra files here with XP Home SP3

James

Patrice Terrier

Are you using long file name with space or accentuated characters?
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Patrice Terrier

I am totaly lost on that one.

Try changing the open mode from "0, 1" to "0, 2" in zFopen
example :
IF zFOpen((sFileName), 0, 2, hFile) = 0 THEN
instead of
IF zFOpen((sFileName), 0, 1, hFile) = 0 THEN

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Trento Castricone

Did not help - same zero length files.

Are line numbers going to be supported?

Paul Squires

Excellent work Patrice (as usual) :)

I use your zTrace everyday so I imagine that I'll be using zXref as well.

I noticed that when you're parsing for the Sub/Function that you are not taking into considering syntax such as "THREAD FUNCTION..." or "STATIC Sub...".  I think that the only place that STATIC is checked for is in IsFileMain.

I am just skimming down through the source. Borje sure liked to use a lot of "magic numbers" in the code. I did notice that there is a lot of things like INSTR(UCASE$(sBuffer)... especially in the DoProcess routine. I think it would make sense to create a separate variable once representing the UCASE of a line and use that variable rather than constantly having to UCASE it???

Just thinking out loud... I see that the program uses global arrays to store all of the functions, variables, etc, and then uses ARRAY SCAN to determine if the variables are present in the arrays prior to adding new ones. I used to do something similar but changed my code to use a Hash table and the results were dramatic (at least for me). On large program source code I could see it cutting down the processing time even further (at the expense of a little bit more complexity). You could store a InfoStruct at each found location in the Hash tables.

Thanks Patrice.

Paul Squires
FireFly Visual Designer SQLitening Database System JellyFish Pro Editor
http://www.planetsquires.com

Patrice Terrier

Trento,

Do you have another application (like SED) that could be using the same include files at the time you are zXref the source code?

Paul,

I did a major rewrite of Börje's code, because it is the only way for me to understand what is going on, and twisting the code to my programming style helps me to progress with it.

For example, this pbcodec code:

              sWork = PARSE$(LineStr, CHR$(34), 2)     'get filename

              IF LEFT$(sWork, 2) = ".\" THEN  'resolve eventual relative paths
                 sWork = FilePathStr + MID$(sWork, 2)
              ELSEIF LEFT$(sWork, 3) = "..\" THEN
                 sWork = LEFT$(FilePathStr, INSTR(-2, FilePathStr, "\")) + MID$(sWork, 4)
              ELSEIF LEFT$(sWork, 4) = "...\" THEN
                 sTemp2 = LEFT$(FilePathStr, INSTR(-2, FilePathStr, "\"))
                 sWork = LEFT$(sTemp2, INSTR(-2, sTemp2, "\")) + MID$(sWork, 5)
              ELSEIF LEFT$(sWork, 5) = "....\" THEN
                 sTemp2 = LEFT$(FilePathStr, INSTR(-2, FilePathStr, "\"))
                 sTemp2 = LEFT$(sTemp2, INSTR(-2, sTemp2, "\"))
                 sWork = LEFT$(sTemp2, INSTR(-2, sTemp2, "\")) + MID$(sWork, 6)
              ELSEIF LEFT$(sWork, 6) = ".....\" THEN
                 sTemp2 = LEFT$(FilePathStr, INSTR(-2, FilePathStr, "\"))
                 sTemp2 = LEFT$(sTemp2, INSTR(-2, sTemp2, "\"))
                 sTemp2 = LEFT$(sTemp2, INSTR(-2, sTemp2, "\"))
                 sWork = LEFT$(sTemp2, INSTR(-2, sTemp2, "\")) + MID$(sWork, 7)
              ELSEIF LEFT$(sWork, 7) = "......\" THEN
                 sTemp2 = LEFT$(FilePathStr, INSTR(-2, FilePathStr, "\"))
                 sTemp2 = LEFT$(sTemp2, INSTR(-2, sTemp2, "\"))
                 sTemp2 = LEFT$(sTemp2, INSTR(-2, sTemp2, "\"))
                 sTemp2 = LEFT$(sTemp2, INSTR(-2, sTemp2, "\"))
                 sWork = LEFT$(sTemp2, INSTR(-2, sTemp2, "\")) + MID$(sWork, 8)
              END IF

              IF INSTR(-1, sWork, ".") = 0 THEN          'if no file extension is given,
                 sWork = sWork + ".BAS"                  'compiler assumes .BAS file
              END IF


became in zXref:

                sWork = PARSE$(sLineStr, CHR$(34), 2)     'get filename
'               // Patrice
'               // Check if it starts with a dot ".\", "..\", "...\", "....\", ".....\", "......\"
                IF ASC(sWork) = 46 THEN
                   sTemp2 = FilePathStr
                   K = 1: One = 0
                   WHILE ASC(sWork, K) = 46
                       K += 1
                       IF ASC(sWork, K) = 92 THEN
                          sWork = sTemp2 + MID$(sWork, K + One)
                       ELSE
                          sTemp2 = SplitPath(sTemp2): One = 1
                       END IF
                   WEND
                END IF

                IF INSTR(-1, sWork, ".") = 0 THEN           'if no file extension is given,
                   sWork = sWork + ".BAS"                   'compiler assumes .BAS file
                END IF


About  "STATIC Sub" i never used it, i know it only as STATEMENT to define static variable inside SUB or FUNCTION.

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Donnie Ewald

I ended up with zero-length files too.  Specifically, these are files that are INCLUDEd in the source file but are not found in the local directory.