• Welcome to Theos PowerBasic Museum 2017.

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

#75
PBFORMS.INC

I do not have any code using that one, thus i didn't even think of it.

I have removed the call to zTrace that was used to track down what was going on.

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

Bud Meyer

v1.06 still works fine* for me by the way, and it reduces the compiled size about 4.5KB. :)

*it still omits this function, which I must manually paste in each time:
FUNCTION BrowseForFolderProc (BYVAL hWnd AS LONG, BYVAL wMsg AS LONG, BYVAL wParam AS LONG, BYVAL lpData AS LONG) AS LONG
   IF wMsg = %BFFM_INITIALIZED THEN
       DIALOG SEND hWnd, %BFFM_SETSELECTION, %TRUE, lpData
   ELSEIF wMsg = %BFFM_SELCHANGED THEN
       DIM zBuffer AS ASCIIZ * %MAX_PATH
       CALL SHGetPathFromIDList(BYVAL wParam, zBuffer)
       'IF ISFALSE CBWPARAM OR ISFALSE LEN(zBuffer) OR ISFALSE (GETATTR(zBuffer) AND %SUBDIR) OR MID$(zBuffer,2,1) <> ":" THEN  ' Not a local or mapped drive
       '    DIALOG SEND CBHNDL, %BFFM_ENABLEOK, %FALSE, %FALSE
       'ELSEIF (GETATTR(zBuffer) AND %SYSTEM) AND RIGHT$(zBuffer,2) <> ":\" THEN ' exclude system folders, allow root directories
       '    DIALOG SEND CBHNDL, %BFFM_ENABLEOK, %FALSE, %FALSE
       'END IF
   END IF
END FUNCTION

Patrice Terrier

Bud,

I am sorry, but so far i am only considering the SDK syntax, because i am checking with my own code.

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

Patrice Terrier

#78
The first post of this thread has been updated with the latest version.

It is provided with full source code, for those wanting to let it work with DDT or missing CALLBACK.

It is time now for new contributors to jump in, because my holiday's time left over  :D

The main section that should be enhanced/customized is in BuildSingleFile.

If you make some changes, please post them here with complete source code, for the benefit of the other members of this forum, thank you!

...


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

Patrice Terrier

Updated to version 1.09.

I have added a new checkbox: "Clean code", to produce either XREF only, or XREF + cleaned code.

The new version is attached to first post of this thread.

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

Jürgen Huhn

Hey Bud!
I just downloaded " zXref " the first Time for me and read about your Problem`s with the SDK-Style.
I will translate your callback "FUNCTION BrowseForFolderProc" from DDT to SDK, so you be able to use it without a Problem...

See ya-- 8)
.¸.•'´¯)¸.•'´¯)¸.•'´¯)¸.•'´¯)
¤ª"˜¨¨¯¯¨¨˜"ª¤....¤ ª"˜¨

Jürgen Huhn

#81
Bud!

Already done!

I changed only a few lines and leave the old DDT-Syntax in the Code for you to see the Difference!
you better remove these unused Lines when you`re ready to paste these Functions into your Codes.
Also added two Helper Functions and a new FUNCTION -JH_GetFolder- to fill the BROWSEINFO - Structure
and call your - BrowseForFolderProc - with it.

I think this resolve the Problem! - I didn`t test it with zXref, because i'm short in Time today.

Insert the next Lines on the rght Place into your - DlgProc - for PBMain DDT-Style or
into your - WndProc - FUNCTION for the use wth the WinMain SDK-Style.

I`m personally prefer the SDK and the Win-Api,  It`s hard work sometimes, but when it`s done, i have the
the Possibllty to translate the code easy into any other programming Language.
Because the flat Win-Api is always the same Syntax with minimal differences.

I hope you understand all - my English isn`t the Best but i work on it.
......

Paste this into WndProc or DlgProc:

    STATIC SzGetpath AS ASCIIZ * %MAX_PATH '// if %MAX_PATH not defined, use - ASCIIZ * 255 -
    LOCAL  SGetpath  AS STRING

         IF LEN(SzGetpath) = 0 THEN SzGetpath = JH_AppDir()  '// For "hWnd" use "CBHNDL" in DDT-Style
         CALL JH_GetFolder(hWnd,SzGetpath) TO SGetpath     '// <-- SGetpath = JH_GetFolder(hWnd,SzGetpath)
         IF LEN(SGetpath) and SGetpath <> SzGetpath THEN
            SzGetpath = SGetpath
         ELSE
            CALL ErrorMsg(("You don`t select a new Folderlocation!" + $CR + "The Current used FolderPath is:" + $CR + SzGetpath))
         END IF                                                                                                                 
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
FUNCTION ErrorMsg(BYVAL lpszMessage AS STRING)AS LONG
   MessageBox(0&,(lpszMessage), "Error", %MB_OK OR %MB_ICONERROR OR %MB_TOPMOST)
   FUNCTION = 0
END FUNCTION
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
' Get Applicaton's Folderpath - returned as String
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
FUNCTION JH_AppDir() AS STRING
   LOCAL sAppPath AS STRING
   LOCAL APPLIDir AS ASCIIZ * %MAX_PATH
   Call GetModuleFileName(BYVAL 0, APPLIDir, %MAX_PATH)            ' get path to program
   sAppPath = LEFT$(APPLIDir, INSTR(-1, APPLIDir, ANY "\/:"))      ' ExePath with "\"
   '//sAppPath = Left$(APPLIDir, InStr(-1, APPLIDir, Any "\/:")-1) ' ExePath without "\"
    FUNCTION = sAppPath
END FUNCTION
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
' Browse for folder
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
FUNCTION JH_GetFolder(BYVAL hwnd AS DWORD,BYVAL sPath AS STRING) AS STRING

    STATIC szPath AS ASCIIZ * %MAX_PATH
    STATIC idl AS DWORD
    LOCAL PathID AS DWORD
    LOCAL bInf AS BROWSEINFO

    ' Fill the BROWSEINFO - Structure and
    ' set some properties for the BFF_Dialog
    ' Store sPath in STATIC - Memory and set it as Staustext
    IF LEN(sPath) THEN szPath = sPath
    CALL SHGetSpecialFolderLocation(hwnd, %CSIDL_DESKTOP, idl)

    bInf.hWndOwner = hwnd
    bInf.ulFlags   = %BIF_USENEWUI  '//OR %BIF_RETURNONLYFSDIRS
    bInf.pidlRoot  = idl    '/ %CSIDL_DRIVES
    ' //bInf.pszDisplayName = VARPTR(szPath)  '//Staustext
    bInf.lpszTitle = VARPTR(szPath)           '//Staustext
    bInf.lpfnCallback = CODEPTR(BrowseForFolderProc)
    bInf.lparam = STRPTR(sPath)               '// lparam is the lpData

    PathID = SHBrowseForFolder(bInf) ' open the Browse-For-Folder Dialogbox

    IF PathID THEN                   ' returned id of Path
        IF SHGetPathFromIDList(BYVAL PathID, szPath) THEN
            szPath = EXTRACT$(szPath, CHR$(0))
           '//IF ASC(szPath, -1) <>  92 THEN sPath = szPath + "\"  '//  Asciicode 92 = \
            IF RIGHT$(szPath, 1) <> "\" THEN sPath = szPath + "\"  '//  Two ways.. Try out!!
            FUNCTION  = sPath
        END IF
      CoTaskMemFree PathID 'clear allocated memory from PathID
      CALL CoTaskMemFree(BYVAL idl)
    END IF

END FUNCTION
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
' Translated BrowseForFolder Callback - For the use in both Styles, SDK and also DDT-Applications
' need the - FUNCTION JH_GetFolder -
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
FUNCTION BrowseForFolderProc(BYVAL hWnd AS LONG, BYVAL wMsg AS LONG, BYVAL wParam AS LONG, BYVAL lpData AS LONG) AS LONG
   LOCAL zBuffer AS ASCIIZ * %MAX_PATH
   LOCAL Translevel AS DWORD

    Translevel= 226

    SELECT CASE wMsg

      '// IF wMsg = %BFFM_INITIALIZED THEN

      CASE  %BFFM_INITIALIZED
          '// A little ADDON.. remove next three Lines and the local Translevel Definition, if you don`t want this!
         CALL SetWindowLong(hWnd, (-20), GetWindowLong(hWnd, (-20)) OR &H80000)
         CALL SetLayeredWindowAttributes(hWnd, 0, Translevel, &H2)  '// %LWA_ALPHA = &H2
         CALL RedrawWindow(hWnd, BYVAL 0&, BYVAL 0&, %RDW_ERASE OR %RDW_INVALIDATE OR %RDW_FRAME OR %RDW_UPDATENOW OR %RDW_ALLCHILDREN)

        '// DIALOG SEND hWnd, %BFFM_SETSELECTION, %TRUE, lpData
         CALL Sendmessage(hWnd, %BFFM_SETSELECTION, %TRUE, BYVAL lpData)
        FUNCTION = 1

      '// ELSEIF wMsg = %BFFM_SELCHANGED THEN

      CASE %BFFM_SELCHANGED
         CALL SHGetPathFromIDList(BYVAL wParam, zBuffer)
         IF LEN(zBuffer) THEN
           zBuffer = EXTRACT$(zBuffer, CHR$(0))
           '//IF ASC(zBuffer, -1) <> 92 THEN zBuffer = zBuffer + "\"  '//  Asciicode 92 = \
           IF RIGHT$(zBuffer, 1) <> "\" THEN zBuffer = zBuffer + "\"  '//  Two ways.. Try out!!

           CALL Sendmessage(hWnd, %BFFM_SETSTATUSTEXT, 0, BYREF zBuffer)

          'IF ISFALSE CBWPARAM OR ISFALSE LEN(zBuffer) OR ISFALSE (GETATTR(zBuffer) AND %SUBDIR) OR MID$(zBuffer,2,1) <> ":" THEN  ' Not a local or mapped drive
          '    DIALOG SEND CBHNDL, %BFFM_ENABLEOK, %FALSE, %FALSE
          'ELSEIF (GETATTR(zBuffer) AND %SYSTEM) AND RIGHT$(zBuffer,2) <> ":\" THEN ' exclude system folders, allow root directories
          '    DIALOG SEND CBHNDL, %BFFM_ENABLEOK, %FALSE, %FALSE
          'END IF
        END IF
     END SELECT
FUNCTION = 0
END FUNCTION
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤



..
.¸.•'´¯)¸.•'´¯)¸.•'´¯)¸.•'´¯)
¤ª"˜¨¨¯¯¨¨˜"ª¤....¤ ª"˜¨

Patrice Terrier

PB9 ISFILE has been replaced with zExist to detect either files or folders.

The new zip file is attached to the first post of this thread.

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

Jürgen Huhn

Patrice,

for you Information...

I tested zXref (version 1.09) on "WinXP SP3" with a few SourceCodes!

It work`s good on my Sytem and i must say: "Thank you for this great Work!"
For me it's a really usefull Tool that i've missed sometimes.

Until now i used old Tools like "inClean or CheckIt" and so on, but with "zXref" and
the included SourceCode, i have much more Possibility`s!

E.g.: to stay up to Date by customizing the Code..

I will post any changes on the Code to you, if any changes need to do...

But in the moment zXref work`s well! Very Usefull!

Thank you...

:)
Ps.: I updated the "Browse for Folder Functions"...
I added three Lines, because i forgot to insert them the last Time.
But no Problem, the Function work also without them.

    CALL SHGetSpecialFolderLocation(hwnd, %CSIDL_DESKTOP, idl)
    bInf.pidlRoot  = idl    '/ %CSIDL_DRIVES


    CALL CoTaskMemFree(BYVAL idl)

.¸.•'´¯)¸.•'´¯)¸.•'´¯)¸.•'´¯)
¤ª"˜¨¨¯¯¨¨˜"ª¤....¤ ª"˜¨

James Klutho

Bob

I believe the xRef comes with the source code so people can tweak it to meet their needs.  Your request should not be that hard to do.


Jim

Andrea Mariani

Patrice,

I tried running zXref on my program, Monastero.Bas.

The generated output @monastero.bas and $Monastero.Bas, hare HUGE compared to the original.

I suspect that "Clean Code" does not work for me.

Directory di C:\Power Basic\Source files\Monastero

15/12/2009  18.09         1.122.357 $Monastero.bas
15/12/2009  18.09         1.192.001 @Monastero.bas
15/12/2009  17.16            31.219 Monastero.bas
               3 File      2.345.577 byte

With WinAPI_115 things get worse:
Directory di C:\Power Basic\Source files\Monastero

15/12/2009  18.24         3.750.533 $Monastero.bas
15/12/2009  18.24         3.763.145 @Monastero.bas
15/12/2009  17.16            31.219 Monastero.bas
               3 File      7.544.897 byte


Where am I going wrong?

Patrice Terrier

Did you try to compile $MONASTERO.BAS  :)
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

José Roca

 
Andrea,

The size of the include files has no direct relation with the size of the executable. Most of them is white space, equates and declares that don't increase the size of the compiled application. Compile it and look at the size of the resulting .EXE file.

Andrea Mariani

Okay...

I get the message...
Directory di C:\Power Basic\Source files\Monastero

15/12/2009  21.34            90.112 $Monastero.exe
15/12/2009  21.33           129.024 Monastero.exe
               2 File        219.136 byte

So once compiled one just gets rid of @whatever and $whatever, and renames $whatever,exe in whatever.exe.

But (IMVHO) InClean is neater: It achieves the same result but creates a neat 8K Monastero.Inc to include in Monastero.Bas.  :)

José Roca

Quote
But (IMVHO) InClean is neater: It achieves the same result but creates a neat 8K Monastero.Inc to include in Monastero.Bas.

But the problem is that is so outdated that it will only work with the outdated include files provided with the compiler. If you are never going to use COM, then it will be fine for you. Otherwise, tell me what happens.