Announcement

Collapse
No announcement yet.

Tool for creating INC file?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Tool for creating INC file?

    Does anyone have a tool that will read my .BAS file and create a declaration file?

    I've got a DLL file that I created, I've modified it so many times and may have forgot to remove declarations from it, or put some back in.....

    It's not neat and organized like I like to be..

    If there is no tool out there would anyone be INTERESTED in a tool?
    I'll write it in PB/CC if so..

    Scott

    ------------------
    Scott
    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

  • #2
    I'm currently writing a tool for removing unused (unreferenced)
    Sub's and Functions from a source code file and its include files,
    but this is probably not what you need...?
    Kind regards
    Eddy


    ------------------
    Eddy

    Comment


    • #3
      Scott
      I posted some code in the Source code forum that will do a little
      of what you wanted - I did have exactly what you wanted in an earlier
      version. I will dig it out if want it
      Iain

      ------------------
      “None but those who have experienced them can conceive of the enticements of science” - Mary Shelley

      Comment


      • #4
        I started writing another, I will likely read the BAS file into an array that way I can scan for the FUNCTION word and the AS Long (Or As String) and not pick up the Function = problem Like I did before....
        Probably have this done tonight and will scan it.
        It won't remove unwanted declarations, but it will create a new declaration file....
        I'll take a look at any code that would make it easier though, thanks!


        Scott

        ------------------
        Scott
        Scott Turchin
        MCSE, MCP+I
        http://www.tngbbs.com
        ----------------------
        True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

        Comment


        • #5
          Scott,

          I have got a tool that will do exactly what you want, the syntax looks like this...

          Code:
          Function PbMain()
            ScanExports "C:\PBDLL\PB5 COMDLL", "COMDLL.DLL", "C:\DECS.INC"
          End Function
          Param 1 is the location to search, Param 2 is the DLL import name and Param 3 is the output file.

          E-Mail me or post your mail address here if you want it.

          Mine is: mailto:[email protected][email protected]</A>

          Regards,

          ------------------
          Kev G Peel
          KGP Software, Bridgwater, UK.
          http://www.kgpsoftware.com

          [This message has been edited by Kev Peel (edited April 03, 2001).]
          kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

          Comment


          • #6
            I wouldn't mind having a copy of that! I have a tool that does SOMETHING like that but puts it in a GUI...

            However, the tool I will write will do it all pre-pb-compiled, on the actual BAS file, BUT I'd still love to look at that tool!

            [email protected]

            Thanks!

            Scott

            ------------------
            Scott
            Scott Turchin
            MCSE, MCP+I
            http://www.tngbbs.com
            ----------------------
            True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

            Comment


            • #7
              Scott, I've got a dumb one I did a while back here when I wanted
              the same thing. It makes some assumptions, like functions and
              subs start at column zero.

              http://www.katravax.org/bheader.zip

              I have the source somewhere; I can find it if you want.
              run the exe for the params, or :
              BHeader.exe /iinputfile [/ooutputfile] [/ccommentlines]
              inputfile is the file to be read
              outputfile is the header file to create
              commentlines is the number of lines of comments to place before each declare

              On just /i it defaults to filename.bh for the include file.


              ------------------
              Troy King
              [email protected]
              Troy King
              katravax at yahoo dot com

              Comment


              • #8
                Thanks guys!

                Column zero is a good assumption, when I write code mine DO start at column zero.

                I guess that's the thing, each tool should work around each person's coding style

                I'll post the source/EXe when I'm done!

                Scott

                ------------------
                Scott
                Scott Turchin
                MCSE, MCP+I
                http://www.tngbbs.com
                ----------------------
                True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

                Comment


                • #9

                  scott & all,

                  sorry 'bout the late reply, see this thread if you are still interested...

                  http://www.powerbasic.com/support/pb...ad.php?t=25674

                  regards,


                  ------------------
                  kev g peel
                  kgp software, bridgwater, uk.
                  http://www.kgpsoftware.com
                  kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

                  Comment


                  • #10
                    Maybe not exactly what you are looking for, but I use the following
                    little tool to list all subs and functions in a file, after which I
                    simply copy the result and paste it into the declaration section of
                    same file. Has saved me a lot of work lately. Can easily be expanded
                    to parse a bunch of files, etc. Whatever. This is a slightly enhanced
                    version of code I posted before in some other thread - this one with
                    Open file dialog to select what file to parse.
                    Code:
                    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
                    ' Sub/Function lister for PB code. Parses given file and creates a
                    ' "DECLARE" style result, for easy copy and paste into your code.
                    ' Should handle all aspects, including trailing comments in lines,
                    ' broken with an underscore ("_") character. Can be optimized for
                    ' better speed, but works fine and pretty fast as it is, so..
                    '
                    ' April 14 - added EXPORT keyword handler in DlgProc after tips from
                    ' Scott Turchin. Thank you Scott - seldom use EXPORT myself so forgot that one..
                    '
                    ' Public Domain, March 2001 by Borje Hagsten
                    ' ..but as always, use at your own responsibility..   
                    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
                    #COMPILE EXE
                    #INCLUDE "WIN32API.INC"
                    #INCLUDE "COMDLG32.INC"
                     
                    %ID_TEXT     = 20
                    %ID_TEXT2    = 21
                     
                    GLOBAL TheArray() AS STRING, SubStr() AS STRING, SubCount AS LONG
                     
                    DECLARE CALLBACK FUNCTION DlgProc() AS LONG
                    DECLARE FUNCTION FileToArray(BYVAL TheFile AS STRING) AS LONG
                    DECLARE FUNCTION MakeFontEx(BYVAL Font AS STRING, BYVAL PointSize AS LONG, BYVAL fBold AS LONG, _
                                                BYVAL fItalic AS LONG, BYVAL fUnderline AS LONG) AS LONG
                    DECLARE SUB GetSubs
                     
                    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
                    ' Create dialog and controls, etc
                    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
                    FUNCTION PBMAIN () AS LONG
                      LOCAL hDlg AS LONG, hFontEdit AS LONG
                     
                      DIALOG NEW 0, "Sub/Function lister",,,  360, 200, %WS_SYSMENU, 0 TO hDlg
                     
                      CONTROL ADD BUTTON, hDlg, 10, "&Copy",   250, 166,  50,  14
                      CONTROL ADD BUTTON, hDlg, 11, "E&xit",   302, 166,  50,  14
                      CONTROL ADD BUTTON, hDlg, 12, "&File..", 210, 168,  30,  12
                      CONTROL ADD TEXTBOX, hDlg, %ID_TEXT, "",   4,   4, 348, 152, _
                                           %WS_CHILD OR %ES_MULTILINE OR %ES_WANTRETURN OR %ES_NOHIDESEL OR _
                                           %WS_HSCROLL OR %ES_AUTOHSCROLL OR %WS_VSCROLL OR %ES_AUTOVSCROLL, _
                                           %WS_EX_CLIENTEDGE
                     
                      CONTROL ADD LABEL, hDlg, -1, "Scanned file:",  4, 158, 50, 10
                      CONTROL ADD TEXTBOX, hDlg, %ID_TEXT2, "", 4, 168, 200, 12, _
                                           %WS_CHILD OR %ES_AUTOHSCROLL, %WS_EX_CLIENTEDGE
                     
                      hFontEdit = MakeFontEx("Courier New", 9, %FW_NORMAL, 0, 0)
                      SendMessage GetDlgItem(hDlg, %ID_TEXT), %WM_SETFONT, hFontEdit, 0
                     
                      DIALOG SHOW MODAL hDlg CALL DlgProc
                     
                      IF hFontEdit THEN DeleteObject hFontEdit
                    END FUNCTION
                     
                    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
                    ' Main callback
                    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
                    CALLBACK FUNCTION DlgProc() AS LONG
                      LOCAL I AS LONG, J AS LONG, txt AS STRING
                     
                      SELECT CASE CBMSG
                         CASE %WM_COMMAND
                            IF CBCTL = 10 THEN 'copy listed subs/functions
                              CONTROL SEND CBHNDL, %ID_TEXT, %EM_SETSEL, 0, -1
                              CONTROL SEND CBHNDL, %ID_TEXT, %WM_COPY, 0, 0
                              CONTROL SEND CBHNDL, %ID_TEXT, %EM_SETSEL, 0, 0
                     
                            ELSEIF CBCTL = 11 THEN
                               DIALOG END CBHNDL
                     
                            ELSEIF CBCTL = 12 THEN
                               LOCAL Style AS DWORD
                               LOCAL f     AS STRING
                               LOCAL Path  AS STRING
                               Path  = CURDIR$
                               f     = "*.BAS;*.INC"
                               Style = %OFN_ENABLEHOOK OR %OFN_FILEMUSTEXIST OR %OFN_ENABLESIZING OR _
                                       %OFN_HIDEREADONLY  OR %OFN_EXPLORER
                               IF OpenFileDialog(CBHNDL, "", f, Path, _
                                                "PB Files (*.BAS, *.INC)|*.BAS;*.INC|Resource Files (*.RC)|*.RC|All Files|*.*", "BAS" , Style) THEN
                     
                                  IF LEN(f) = 0 THEN EXIT FUNCTION                   'if no length, leave
                                  IF (GETATTR(f) AND %ATTR_DIR) THEN EXIT FUNCTION   'if directory, leave
                                  CONTROL SET TEXT CBHNDL, %ID_TEXT2, f
                     
                                  IF DIR$(f, 55) <> "" THEN                          'if file exist, work
                                     FileToArray f                                   'load file into array
                                     GetSubs                                         'parse out subs/functions to array
                                     ARRAY SORT SubStr(), COLLATE UCASE              'sort result (if you don't want to - uncomment)
                     
                                     txt = ""
                                     FOR I = 0 TO UBOUND(SubStr)
                                        IF LEN(SubStr(I)) THEN
                                           J = INSTR(UCASE$(SubStr(I)), " EXPORT")
                                           IF J THEN SubStr(I) = LEFT$(SubStr(I), J) + MID$(SubStr(I), J + 8) + " ' EXPORTED"
                                           J = INSTR(UCASE$(SubStr(I)), ")EXPORT")
                                           IF J THEN SubStr(I) = LEFT$(SubStr(I), J) + MID$(SubStr(I), J + 8) + " ' EXPORTED"
                    
                                           txt = txt & "DECLARE " & SubStr(I) & $CRLF   'create declare string
                                        END IF
                                     NEXT
                                     CONTROL SET TEXT CBHNDL, %ID_TEXT, txt          'show result
                                  END IF
                               BEEP
                               END IF
                            END IF
                      END SELECT
                     
                    END FUNCTION
                     
                    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
                    ' Load a text file into an array
                    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
                    FUNCTION FileToArray(BYVAL TheFile AS STRING) AS LONG
                      LOCAL c AS LONG, NumRecs AS LONG, Buf AS STRING
                     
                      OPEN TheFile FOR BINARY AS #1
                         GET$ #1, LOF(1), Buf
                      CLOSE #1
                     
                      Numrecs = TALLY(Buf, $CRLF)            '<- line feed count
                      IF Numrecs = 0 THEN EXIT FUNCTION
                     
                      REDIM TheArray(Numrecs)                '<- reset arrays
                      REDIM SubStr(0) : SubCount = 0
                     
                      OPEN TheFile FOR INPUT AS #1 LEN = 32767
                         FOR c = 0 TO Numrecs - 1
                           LINE INPUT #1, TheArray(c)        '<- read line by line into array
                         NEXT
                      CLOSE #1
                     
                      FUNCTION = c - 1                       '<- if we ever should need it..
                    END FUNCTION
                     
                    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
                    ' Get subs and functions from an array, into another array
                    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
                    SUB GetSubs
                      LOCAL I AS LONG, J AS LONG, K AS LONG, sFlag AS LONG, txt AS STRING
                     
                      FOR I = 0 TO UBOUND(TheArray)
                         TheArray(I) = TRIM$(TheArray(I), CHR$(9))        'remove eventual tabs
                         K = INSTR(TheArray(I), "'")
                         IF K THEN                                        'if trailing comment
                            txt = LEFT$(TheArray(I), K - 1)               'only use text up to comment
                            txt = TRIM$(txt)                              'trim away leading/ending spaces
                         ELSE
                            txt = TRIM$(TheArray(I))                      'trim away leading/ending spaces
                         END IF
                     
                         IF sFlag = 0 THEN                                'if we are looking for start
                            IF LEFT$(UCASE$(txt), 9) = "FUNCTION " THEN   'if start is found
                               sFlag = 2 : J = I                          'set flag and store I in J
                            ELSEIF LEFT$(UCASE$(txt), 4) = "SUB " THEN
                               sFlag = 1 : J = I
                            ELSEIF LEFT$(UCASE$(txt), 18) = "CALLBACK FUNCTION " THEN
                               sFlag = 2 : J = I
                            END IF
                     
                         ELSE
                            SELECT CASE sFlag                             'what kind of end?
                            CASE 1
                               IF LEFT$(UCASE$(txt), 7) = "END SUB" THEN  'proper end is found
                                  REDIM PRESERVE SubStr(SubCount)         'redim target
                                  GOSUB GetProperString                   'get properly formatted compare string
                                  DO WHILE RIGHT$(txt, 1) = "_"           'enter loop if..
                                     SubStr(SubCount) = SubStr(SubCount) + TheArray(J) + $CRLF + SPACE$(8) 'add some for line feed, etc..
                                     INCR J                               'next line
                                     GOSUB GetProperString                'get properly formatted compare string
                                  LOOP
                                  SubStr(SubCount) = SubStr(SubCount) + TheArray(J) 'get stored element, J
                                  INCR SubCount                                  'increase counter
                                  sFlag = 0                                      'reset flag and search for next
                               END IF
                     
                            CASE 2
                               IF LEFT$(UCASE$(txt), 12) = "END FUNCTION" THEN 'same as above, but for functions
                                  REDIM PRESERVE SubStr(SubCount)
                                  GOSUB GetProperString
                                  DO WHILE RIGHT$(txt, 1) = "_"
                                     SubStr(SubCount) = SubStr(SubCount) + TheArray(J) + $CRLF + SPACE$(8)
                                     INCR J
                                     GOSUB GetProperString
                                  LOOP
                                  SubStr(SubCount) = SubStr(SubCount) + TheArray(J)
                                  INCR SubCount
                                  sFlag = 0
                               END IF
                            END SELECT
                         END IF
                      NEXT
                    EXIT SUB
                     
                    GetProperString :
                      K = INSTR(TheArray(J), "'")
                      IF K THEN                               'if trailing comment
                         txt = LEFT$(TheArray(J), K - 1)      'only use text up to comment
                         txt = TRIM$(txt)                     'trim away leading/ending spaces
                      ELSE
                         txt = TRIM$(TheArray(J))             'trim away leading/ending spaces
                      END IF
                      RETURN
                     
                    END SUB
                     
                    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
                    ' Create a desirable font and return its handle. Original code by Dave Navarro
                    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
                    FUNCTION MakeFontEx(BYVAL Font AS STRING, BYVAL PointSize AS LONG, BYVAL fBold AS LONG, _
                                        BYVAL fItalic AS LONG, BYVAL fUnderline AS LONG) AS LONG
                      LOCAL hDC AS LONG, CyPixels AS LONG
                     
                      hDC = GetDC(%HWND_DESKTOP)
                      CyPixels  = GetDeviceCaps(hDC, %LOGPIXELSY)
                      ReleaseDC %HWND_DESKTOP, hDC
                      PointSize = 0 - (PointSize * CyPixels) \ 72
                     
                      FUNCTION = CreateFont( _
                                 PointSize, 0, _        'height, width(default=0)
                                 0, 0, _                'escapement(angle), orientation
                                 fBold, _               'weight (%FW_DONTCARE = 0, %FW_NORMAL = 400, %FW_BOLD = 700)
                                 fItalic, _             'Italic
                                 fUnderline, _          'Underline
                                 %FALSE, _              'StrikeThru
                                 %ANSI_CHARSET, %OUT_TT_PRECIS, _
                                 %CLIP_DEFAULT_PRECIS, %DEFAULT_QUALITY, _
                                 %FF_DONTCARE , BYCOPY Font)
                     
                    END FUNCTION

                    ------------------


                    [This message has been edited by Borje Hagsten (edited April 14, 2001).]

                    Comment


                    • #11
                      Thanks, Borje... Very nice utility to have.

                      ------------------

                      Comment


                      • #12
                        THanks, your GUI version is VERY nice!!!!
                        My version could learn a thing from yours as far as the Collate Ucase array statement, I use the scalar variable that Lance mentioned and handle everything in lcase...

                        But also note, yours does not remove the Export from the Declare line, which returns and error during compilation of the module that the return is added to...

                        The RemoveExport function here seems to remove it from all instances....

                        This is a PB/CC version I wrote, the LIB part seems to work OK but has occasional issues with removing a character....
                        Otherwise works good, also removes pbmain,libmain, winmain from the declares...


                        Code:
                        #Register None
                        #Include "WIN32API.INC"
                        DefInt a-z
                        
                        Type MyApp
                          title As String * 10
                          ver As String * 4
                          creator As String * 27
                          copyrite As String * 19
                          rights As String * 20
                        End Type
                        
                        Declare Function RemoveExport(sTmp As String) As String
                        Declare Function DrawCC() As Long
                        Declare Function Exist(Filespec As String)  As Long
                        
                        Function WinMain (ByVal hCurInstance As Long, _
                                          ByVal hPrevInstance As Long, _
                                          lpCmdLine As Asciiz Ptr, _
                                          ByVal nCmdShow As Long) As Long
                        
                        Dim App         As Global MyApp
                        Dim InputFile   As Global String
                        Dim OutputFile  As Global String
                        Dim hInFile     As Global Long
                        Dim hOutFile    As Global Long
                        Dim IncLineCount As Global Long
                        Dim BasData(1 To 65535) As String
                        Dim IncData(1 To 8192)  As String 'Not likely to be as big
                        Local sTmp      As String
                        
                        Local lLoop     As Long
                        Local lCount    As Long
                        Local LibFile   As String
                        Local UseLib    As Long
                        
                        app.creator = "Computer Creations Software"
                        app.ver = "v1.1"
                        app.title = "Make-Inc"
                        app.copyrite = "Copyright (c) 2001"
                        app.rights = "All rights reserved."
                        
                        If IsFalse Len(Trim$(Command$)) Or Instr(Trim$(Command$),"?") Then
                           DrawCC
                           Exit Function
                        End If
                        
                        InputFile = Parse$(Command$," ",1)
                        Outputfile = Parse$(Command$," ",2)
                        libfile    = Parse$(Command$," ",3)
                        
                        'Assume a .BAS input if no extention
                        If IsFalse Instr(InputFile,".") Then InputFile = InputFile & ".bas"
                        'Assume a .INC output if no extention given
                        'If no output filename given assume the bas file name
                        If IsFalse Len(Outputfile) Then
                           Outputfile = Left$(InputFile,Instr(InputFile,".") -1 ) & ".inc"
                        ElseIf IsFalse Instr(Outputfile,".") Then
                           Outputfile = Outputfile & ".inc"
                        End If
                        
                        If Len(LibFile) Then
                           UseLib = %TRUE
                           LibFile = UCase$(LibFile)
                           If Right$(LCase$(LibFile),4) <> ".dll" Then LibFile = LibFile & ".DLL"
                        End If
                        
                        
                        If IsFalse Exist(Inputfile) Then
                           StdOut InputFile & " does not exist."
                           Exit Function
                        Else
                           'Read the file!
                           hInFile = FreeFile
                           Open InputFile For Input As #hInFile
                           Do Until Eof(hInFile)
                              Incr lCount
                              Line Input #hInFile,BasData(lCount)
                           Loop
                           Close #hInFile
                        End If
                        '=================================<Parse each line for function, callback function, sub headers>=============================
                        For lLoop = 1 To lCount
                           'Use sTmp as a scalar string to clean up
                            sTmp = Rtrim$(BasData(lLoop))
                        '    Replace "export" With "" In sTmp
                            If Instr(sTmp,"'") Then 'Gotta remove remarks or we can't see the end of the line
                               sTmp = Left$(sTmp,Instr(sTmp,"'") -1)
                            End If
                        
                                      'Safety precaution
                            If Left$(LCase$(sTmp),9) = "function=" Then Iterate 'Prevent next part from executing on this code
                            If Left$(LCase$(sTmp),10) = "function =" Then Iterate '""
                        
                        '   CallBack Function
                            If LCase$(Left$(sTmp,8)) = "callback" Then 'can only be one line or they are really bad coders
                               Incr IncLineCount
                               IncData(IncLineCount) = "Declare " & BasData(lLoop)
                               Iterate
                            End If
                        
                        
                        '   Function/Sub
                            If LCase$(Left$(sTmp,8)) = "function" Or LCase$(Left$(sTmp,3)) = "sub" Then
                               If Left$(Parse$(LCase$(sTmp)," ",2),6) = "pbmain" Then Iterate
                               If Left$(Parse$(LCase$(sTmp)," ",2),7) = "libmain" Then Iterate
                               If Left$(Parse$(LCase$(sTmp)," ",2),7) = "winmain" Then Iterate
                        '       If Parse$(LCase$(sTmp)," ",2) = "libmain" Or Parse$(LCase$(sTmp)," ",2) = "winmain" Then Iterate
                               'Should be an actual function now. Function = and function= were removed
                               If IsTrue UseLib Then
                                  sTmp = Left$(sTmp,Instr(sTmp,"(")-1) & " Lib " & Chr$(34) & LibFile & Chr$(34) & "(" & Right$(sTmp,Len(sTmp) - Instr(sTmp,"("))
                        '          Mid$(sTmp,Instr(sTmp,"(")) = " Lib " & Chr$(34) & LibFile & Chr$(34) & "("
                        
                               End If
                        
                               sTmp = RemoveExport(sTmp) 'Remove the EXPORT from the Declare Function/Sub line
                               
                               Incr IncLineCount 'We added a line
                               IncData(IncLineCount) = "Declare " & sTmp
                        
                               If Right$(Rtrim$(sTmp),1) = "_" Then 'Multi-line function header
                                  Do
                                      Incr lLoop
                                      Incr IncLineCount
                                      sTmp = Rtrim$(BasData(lLoop)) 'Scalar again
                                      If Instr(sTmp,"'") Then 'Gotta remove remarks or we can't see the end of the line
                                         sTmp = Left$(sTmp,Instr(sTmp,"'") -1)
                                         'Trim again
                                         sTmp = Rtrim$(sTmp) 'Scalar again
                                      End If
                        
                                      'To preserve case in the INC file, look for variations
                                      sTmp = RemoveExport(sTmp)
                                      IncData(IncLineCount) = sTmp 'Do not Trim$ or Ltrim$ this, just Rtrim$
                                      If Right$(sTmp,1) <> "_" Then  Exit Loop
                                  Loop
                               End If
                               Iterate
                            End If
                        Next
                        
                        'Add The Lib "CCS.DLL" if UseLib = %TRUE and Write the output file:
                        hOutFile = FreeFile
                        Open OutPutFile For Output As #hOutFile
                        For lLoop = 1 To IncLineCount
                            Print #hOutFile,IncData(lLoop)
                        Next
                        Close #hOutFile
                        End Function
                        '------------------------------------------------------------------------------
                        Function RemoveExport(sTmp As String) As String
                              'To preserve case in the INC file, look for variations
                               Replace "export" With "" In sTmp
                               Replace "Export" With "" In sTmp
                               Replace "EXPORT" With "" In sTmp
                               Replace ")export" With ")" In sTmp
                               Replace ")Export" With ")" In sTmp
                               Replace ")EXPORT" With ")" In sTmp
                        Function = sTmp
                        End Function
                        '------------------------------------------------------------------------------
                        Function DrawCC() As Long
                        Page 1,2
                        Local X As Integer
                        Local Y As Integer
                        Color 9,0
                        '1st row of "C1"
                        StdOut String$(5,32)+Chr$(220)+ Chr$(219)+ Chr$(223)+ Chr$(220)+ Chr$(219)
                        '2nd row of "C1"
                        StdOut String$(4,32)+Chr$(222)+Chr$(219)+Chr$(221)+String$(2,32)+Chr$(219)
                        '3rd row of "C1"
                        StdOut String$(4,32)+String$(2,219)+String$(3,32);
                        Color 11,0
                        '1st row of "C2"
                        StdOut Chr$(220)+ Chr$(219)+ Chr$(223)+ Chr$(220)+ Chr$(219)
                        '4th row of "C1"
                        Color 9,0
                        StdOut String$(4,32)+Chr$(222)+Chr$(219)+Chr$(221)+Chr$(32);
                        Color 11,0
                        '2nd row of "C2"
                        StdOut Chr$(222)+Chr$(219)+Chr$(221)+String$(2,32)+Chr$(219)
                        '5th row of "C1"
                        Color 9,0
                        StdOut String$(5,32)+Chr$(223)+Chr$(219)+Chr$(220);
                        '3rd row of "C2"
                        Color 11,0
                        StdOut String$(2,219)+String$(3,32);
                        Color 9,0:StdOut 'Left$(App.Creator,8)
                        '4th row of "C2"
                        Color 11,0
                        StdOut String$(8,32)+Chr$(222)+Chr$(219)+Chr$(221)+String$(3,32);
                        Color 9,0
                        StdOut "  " + App.Creator
                        Color 11,0
                        '5th row of "C2"
                        StdOut String$(9,32)+Chr$(223)+Chr$(219)+Chr$(220)+Chr$(220)+Chr$(223);
                        
                        Color 14,0: StdOut"  " + App.title + " " + App.Ver + " 32 bit"
                        Y=CursorX
                        X=CursorY
                        If Y < 25 Then Locate X,17 Else StdOut:Locate X,17
                        Color 11,0
                        StdOut app.copyrite;
                        StdOut " " + app.rights
                        If Y < 25 Then Locate X + 1,17 Else StdOut:Locate X + 1,17
                        Color 15,0:StdOut "http://www.tngbbs.com"
                        Color 15,0
                        StdOut "Useage:"
                        StdOut "Makeinc <InputFile> <Outputfile> <LibName>"
                        StdOut "If Inputfile has no extention "".bas"" will be appended."
                        StdOut "If Outputfile has no extention "".inc"" will be appended."
                        StdOut "<LibName> specifies  Lib ""LIBNAME.DLL"" is Appended To each Function/Sub"
                        Color 7,0
                        StdOut
                        Page 1,1
                        End Function
                        '------------------------------------------------------------------------------
                        Function Exist(Filespec As String) Export As Long
                          Local hDir     As Long
                          Local FindData As WIN32_FIND_DATA
                        
                          FindData.dwFileAttributes = %FILE_ATTRIBUTE_DIRECTORY
                          hDir = FindFirstFile(ByVal StrPtr(filespec), FindData)
                          If hDir = %INVALID_HANDLE_VALUE Then
                            Exit Function     'file not found
                          End If
                          Function = %TRUE
                          FindClose hDir
                        End Function
                        '------------------------------------------------------------------------------


                        [This message has been edited by Scott Turchin (edited April 14, 2001).]
                        Scott Turchin
                        MCSE, MCP+I
                        http://www.tngbbs.com
                        ----------------------
                        True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

                        Comment


                        • #13
                          Ah, thanks Scott. Seldom do DLL's or need to export anything so I
                          forgot about that one. I have added the following to the DlgPoc
                          in the code above:
                          Code:
                            J = INSTR(UCASE$(SubStr(I)), " EXPORT")
                            IF J THEN SubStr(I) = LEFT$(SubStr(I), J) + MID$(SubStr(I), J + 8) + " ' EXPORTED"
                            J = INSTR(UCASE$(SubStr(I)), ")EXPORT")
                            IF J THEN SubStr(I) = LEFT$(SubStr(I), J) + MID$(SubStr(I), J + 8) + " ' EXPORTED"
                          Think that should cover it. Added commented out "EXPORTED" to the
                          end, so one can see if it was declared like that in code. BTW - a
                          small tip: Not that it matters much in these little routines, but
                          UCASE compare is usually about 20-25% faster than LCASE..


                          ------------------

                          Comment


                          • #14
                            Cool, I will mix your code with mine and have a PBCC Version that puts it on the clipboard.

                            I especially LOVE how you put the text on the clipboard without having ot use a clipboard function, that is way cool (WM_COPY)...


                            Scott

                            ------------------
                            Scott
                            Scott Turchin
                            MCSE, MCP+I
                            http://www.tngbbs.com
                            ----------------------
                            True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

                            Comment


                            • #15
                              Borje,

                              In compiling your utility get error on %OFN_ENABLESIZING.

                              Looked in both include files and could not find.

                              I'm a novice at this. Am I missing something?

                              Thanks,

                              Larry

                              ------------------
                              Larry Coleman
                              [email protected]
                              Larry Coleman
                              Savannah, Ga USA

                              Comment


                              • #16
                                You probably need the current commctrl.inc file...

                                Think you can download that from this site, check the file section under support...

                                ------------------
                                Scott
                                Scott Turchin
                                MCSE, MCP+I
                                http://www.tngbbs.com
                                ----------------------
                                True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

                                Comment


                                • #17
                                  %OFN_ENABLESIZING = &H00800000???
                                  Is in latest update of COMDLG32.INC. You can find the latest updated
                                  include files at: http://www.powerbasic.com/files/pub/pbwin/win32api.zip

                                  Note: you can remove the style too, if you like. Only makes the open
                                  dialog resizeable..


                                  ------------------

                                  Comment


                                  • #18
                                    Borje,

                                    Downloaded the latest win32api. Utility works great.
                                    Has already saved considerable time.

                                    Thanks,

                                    Larry

                                    ------------------
                                    Larry Coleman
                                    [email protected]
                                    Larry Coleman
                                    Savannah, Ga USA

                                    Comment

                                    Working...
                                    X