Announcement

Collapse
No announcement yet.

Using labels to debug

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

  • Using labels to debug

    The
    Code:
    #Debug Display On '<<<<<<<<<<<<<<< Remember to turn off for production code
    is really great for picking up Bounds and other errors. It tells which sub, function, etc the error occurred in. Far far better than the gpf's we used to get.

    However if the error occurs inside a long Sub, ... or deep within macros, or a long loop, or ... it can still be difficult to pin down. Not nearly as hard as before the Debug Display but still ...

    Anyway here's a handy tip for further narrowing down the vexious culprit: At various points in the suspect code put line numbers (or labels), then when the error msg comes up it will say " ## Error after Line 1000" (or whatever thelast label was.

    Code:
    Function Foo() As Long 'tip o the derby to 
    1000:     'Mile marker Id
      Call Complicated_Sub_Full_of_Macros
    After_Complicated:   'Mile marker Id
      Call Macro
    After_Macro:  'Mile marker Id
      Call Another_Sub
    1300:      'Mile marker Id
      Call Macro
    1400:  'Mile marker Id
    '...  
    End Function
    Now when the errror trips, it will say "## Error ocurred after "After_Complicated" or "after 1300" or whatever Mile Marker that has been inserted set. Rather than just "After Foo".

    ================================
    "You cannot depend on your eyes
    when your imagination
    is out of focus."
    Mark Twain
    ================================
    It's a pretty day. I hope you enjoy it.

    Gösta

    JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
    LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

  • #2
    Thank you sir, I'll be making use of that for sure I'd bet.

    Comment


    • #3
      Gösta,
      Code:
      At various points in the suspect code put line numbers
      Why not write a small program which inserts a line number in every line of your code:
      Code:
      'PBCC5 program
      FUNCTION PBMAIN () AS LONG
      
      OPEN "MyProg.bas" FOR BINARY AS #1 'could use COMMAND$ to get the name so the .BAS file can just be dropped on the exe
      GET$ 1,LOF(1),prog$                'get the source code
      CLOSE #1
      
      count&=PARSECOUNT(prog$,$CRLF)     'split into lines
      DIM a$(1 TO count&)
      PARSE  prog$, a$(), $CRLF
      
      FOR r& = 1 TO count&               'add a line number to each line
          a$(r&)=RIGHT$("     " + TRIM$(STR$(r&))+" ",6)+a$(r&)
      NEXT
      
      prog$=JOIN$( a$(),$CRLF)           'reassemble the program
      
      OPEN "MyProgX.bas" FOR BINARY AS #1
      PUT$ 1,prog$                       'save the new, line numbered source file
      SETEOF #1
      CLOSE #1
      
      END FUNCTION
      It could be rewritten to suit your own use.
      For example you could extract the file name to add the numbers to from COMMAND$ instead of specifying it in source code.
      That way you can drag and drop a source file onto the line numbering .EXE.
      You could also rewrite the same filename rather than giving it a new name.

      Paul.

      Comment


      • #4
        >Why not write a small program which inserts a line number in every line of your code:

        That's pretty much what compilers which support a integrated stepping debugger do. During compilation they build a table referencing source code line to generated code offset. Then when running, they check the current instruction pointer, look up the referenced source code line and change the user display to show that as the executing line.

        They also build a cross reference between user variables ("symbols") and the address of that variable, which allows for monitoring of "watch" items.

        Not terribly important to this problem but I thought someone might find it interesting.

        MCM
        Michael Mattias
        Tal Systems Inc. (retired)
        Racine WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          For anyone interested:

          Source Code - Add line numbers to a PB source

          I used it various time in the past. May require some minor modifications for the latests compilers versions.

          Bye!
          -- The universe tends toward maximum irony. Don't push it.

          File Extension Seeker - Metasearch engine for file extensions / file types
          Online TrID file identifier | TrIDLib - Identify thousands of file formats

          Comment


          • #6
            Originally posted by Paul Dixon View Post
            Gösta,
            Code:
            At various points in the suspect code put line numbers
            Why not write a small program which inserts a line number in every line of your code:
            l.
            Fine idea, Paul. Or mayb Marco's code. Not that I'd ever need it, of course {laughing}. But it seems for a long complicated program with a difficult bug a 'Mile Marker' could be inerted before every line, saved as "Bug_Zapp er.bas" (ditto DLL's) and then run. That way original code doesn't get all cluttered up.

            Thank you sir, I'll be making use of that for sure I'd bet.
            I just lucked on to it myself. Not a new idea though, I guess (see Marco's post).
            Last edited by Gösta H. Lovgren-2; 25 Jun 2009, 10:16 AM. Reason: Ditto Duh!
            It's a pretty day. I hope you enjoy it.

            Gösta

            JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
            LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

            Comment


            • #7
              For problems resulting in a protection fault or other program termination, TRACE is a tremendous tool. It tells you the last procedure your program entered before termination.

              Once you know WHERE the program got to, TRACE PRINT statements can be inserted to check the values of suspect variables.

              "Really big" procedures? Throw in some labels every ten lines. TRACE reports every time you pass a label, too.

              Better still, use 'many small' instead of 'few large' procedures. While I like to do this for maintenance and testing reasons, it is a boon when using TRACE to debug a problem.

              I guess what I am saying here is, sure seems some folks are spending a lot of time reinventing the TRACE wheel.

              I'm also saying, "How am I going to test and debug this application?" is something you should ask yourself - and answer - BEFORE you write that first line of code.

              MCM
              Michael Mattias
              Tal Systems Inc. (retired)
              Racine WI USA
              [email protected]
              http://www.talsystems.com

              Comment


              • #8
                >is really great for picking up Bounds and other errors

                How soon we^H^HI forget.... TRACE automatically shows your bounds violations without doing anything special...
                Code:
                ' test_trace.bas
                ' 06.25.09
                ' PB/WIN 9.0.1
                #COMPILE EXE
                #DIM     ALL
                #DEBUG    ERROR ON
                #TOOLS ON
                
                
                FUNCTION GetValue (Z() AS LONG) AS LONG
                    LOCAL UB AS LONG
                    LOCAL W  AS LONG, E AS LONG
                    
                    UB = UBOUND(Z,1)+ 1
                Get_W:
                    W  = Z(UB)
                ASSIGN_FUNCTION:
                    FUNCTION =  W
                END FUNCTION
                
                FUNCTION PBMAIN () AS LONG
                    
                  TRACE NEW "test_trace_log.txt"
                  
                  TRACE ON
                  
                  CALL RealMain
                
                  TRACE OFF
                  TRACE CLOSE
                END FUNCTION
                
                FUNCTION RealMain () AS LONG
                    LOCAL X() AS LONG, Q AS LONG
                   
                My_REDIM:
                    REDIM X(10)
                CALL_GetValue:
                    Q = GetValue (X())
                
                RealMain_Exit:
                    FUNCTION = Q 
                   
                END FUNCTION
                Code:
                Trace Begins...
                 REALMAIN()
                 MY_REDIM
                 CALL_GETVALUE
                  GETVALUE(1244496)
                  GET_W
                  Error 9 was generated in this thread
                  ASSIGN_FUNCTION
                  GETVALUE Exit
                 REALMAIN_EXIT
                 REALMAIN Exit
                PBMAIN Exit
                Michael Mattias
                Tal Systems Inc. (retired)
                Racine WI USA
                [email protected]
                http://www.talsystems.com

                Comment


                • #9
                  Trace and other debug tools usually do more than enough for me to find something I did not think of, and fix it.

                  However larger projects, errors found (As we all well know) could arise LONGGGGGggg after the actual code that caused the error.

                  Also, the debugger is of no help when code you compiled as exe, debugged, and then turned into a Dll because you can not debug the dll.

                  Thats why "Real Men" build their own debugging routines.
                  RunTime Debug and Error Handling Part I - Find that elusive bug
                  RunTime Debug and Error Handling Part II - Find that elusive bug
                  and soon to be Part III, but thats when I saw Gosta's post about line numbers (and although already implemented) it reminded me of an idea I had for inserting these unique (and yes each label has to be unique) label without needing to precompile (IE: "Compile" once to add line numbers, and then really compile). So I am holding off on Part III until I touch-base with line numbers again.

                  Overkill??? Maybe so, but sure is saving me with code I wrote YEARS ago and had no clue that I made a :doh:
                  Engineer's Motto: If it aint broke take it apart and fix it

                  "If at 1st you don't succeed... call it version 1.0"

                  "Half of Programming is coding"....."The other 90% is DEBUGGING"

                  "Document my code????" .... "WHYYY??? do you think they call it CODE? "

                  Comment


                  • #10
                    Also, the debugger is of no help when code you compiled as exe, debugged, and then turned into a Dll because you can not debug the dll.
                    I think you meant...
                    " Also, the stepping debugger is of no help when code you compiled as exe, debugged, and then turned into a Dll because you can not use the stepping debugger to debug the dll.
                    Please do not give 'newbies' the idea that that only way to 'debug' a program is to use the stepping debugger!

                    I'll leave out the obvious... no I won't:

                    I guess maybe that code in the EXE was not debugged all that well before it was moved to a DLL, huh?



                    MCM
                    Last edited by Michael Mattias; 25 Jun 2009, 06:30 PM.
                    Michael Mattias
                    Tal Systems Inc. (retired)
                    Racine WI USA
                    [email protected]
                    http://www.talsystems.com

                    Comment


                    • #11
                      It also brings up a thought of how PB shows you line #'s in the editor and if I can get those values at compile time to nail down the row????
                      Engineer's Motto: If it aint broke take it apart and fix it

                      "If at 1st you don't succeed... call it version 1.0"

                      "Half of Programming is coding"....."The other 90% is DEBUGGING"

                      "Document my code????" .... "WHYYY??? do you think they call it CODE? "

                      Comment


                      • #12
                        I think you meant...
                        Quote:
                        " Also, the stepping debugger is of no help when code you compiled as exe, debugged, and then turned into a Dll because you can not use the stepping debugger to debug the dll.
                        Please do not give 'newbies' the idea that that only way to 'debug' a program is to use the stepping debugger!
                        Ok, I will bite, and ask, just HOW do you debug a dll (either your own, or one mapped into your process???)

                        I will agree to the STEPPING part, but if there is a way to debug a dll itself, then call me a newbie

                        I guess maybe that code in the EXE was not debugged all that well before it was moved to a DLL, huh?
                        Well all I did was uncomment compiler code for DLL and comment out compiler code for EXE (so no copy-paste errors) so you tell me where I went wrong using the tools I had, and test as well as I could and no errors, so the DLL should ALSO have no errors????

                        Either wayz, Gosta's post was something that not many people know
                        Anyway here's a handy tip for further narrowing down the vexious culprit: At various points in the suspect code put line numbers (or labels), then when the error msg comes up it will say " ## Error after Line 1000" (or whatever thelast label was.
                        A helpful tip for both newbies and old warhorses alike (Heck even I missed this one till ripping my hair out over a "BUG" that I wrote 5 years ago, and about to give up when I found I could "Mark" my code to help me narrow in)

                        Maybe just "Good Timing" on Gosta's part, but it prompted me to research more on how to possibly debug what "You did NOT plan for, but it DID occur, and now I have to FIND it and fix it"

                        Thank you Gosta for a subtle nudge, it went a long way to something I would soon forget if I had not looked into it.
                        Engineer's Motto: If it aint broke take it apart and fix it

                        "If at 1st you don't succeed... call it version 1.0"

                        "Half of Programming is coding"....."The other 90% is DEBUGGING"

                        "Document my code????" .... "WHYYY??? do you think they call it CODE? "

                        Comment


                        • #13
                          Originally posted by Cliff Nichols View Post
                          Maybe just "Good Timing" on Gosta's part,
                          Rather than "good timing", I'd rather think the minds of real men travel in the same channel.

                          =======================================================
                          "A narcissist is someone better looking than you are."
                          Gore Vidal
                          =======================================================

                          Note - Gore Vidal disgusts me, but that was a good line.
                          It's a pretty day. I hope you enjoy it.

                          Gösta

                          JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
                          LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

                          Comment


                          • #14
                            The zTrace utiliity could also help debugging existing code.

                            ...
                            Patrice Terrier
                            www.zapsolution.com
                            www.objreader.com
                            Addons: GDImage.DLL 32/64-bit (Graphic library), WinLIFT.DLL 32/64-bit (Skin Engine).

                            Comment


                            • #15
                              Ok, I will bite, and ask, just HOW do you debug a [procedure in a] dll
                              Ok, I will bite back...
                              • Predict the output based on input and compare
                              • Write log files
                              • Send display messages to STDOUT or in a MSGBOX to check status codes or intermediate results
                              • TRACE PRINT
                              • Interrogate return codes from function calls; check system ERR and/or OBJRESULT values after perfoming operations which may result in same.

                              Works here.

                              Better still, have a plan to test and debug before writing the first line of code.
                              Michael Mattias
                              Tal Systems Inc. (retired)
                              Racine WI USA
                              [email protected]
                              http://www.talsystems.com

                              Comment


                              • #16
                                Ok, I will bite back...
                                • Predict the output based on input and compare
                                • Write log files
                                • Send display messages to STDOUT or in a MSGBOX to check status codes or intermediate results
                                • TRACE PRINT
                                • Interrogate return codes from function calls; check system ERR and/or OBJRESULT values after perfoming operations which may result in same.

                                Works here.

                                Better still, have a plan to test and debug before writing the first line of code.
                                And here I thought you might have some technique for debugging a DLL that had already been Debugged as an EXE. All of the above is what I already do.

                                There is no "Silver Bullet" but it sure would be nice to build a wooden one
                                Engineer's Motto: If it aint broke take it apart and fix it

                                "If at 1st you don't succeed... call it version 1.0"

                                "Half of Programming is coding"....."The other 90% is DEBUGGING"

                                "Document my code????" .... "WHYYY??? do you think they call it CODE? "

                                Comment


                                • #17
                                  And here I thought you might have some technique for debugging [a procedure in]a DLL that had already been Debugged [when in] an EXE
                                  If a procedure has been debugged, it does not make any difference if it is packaged into an EXE or DLL.

                                  This is an equation suitable for the new BIT variable type: either the procedure has been debugged or it hasn't.

                                  MCM
                                  Michael Mattias
                                  Tal Systems Inc. (retired)
                                  Racine WI USA
                                  [email protected]
                                  http://www.talsystems.com

                                  Comment


                                  • #18
                                    Wheel Reinvention

                                    Just for something to do today:

                                    '
                                    Code:
                                    '
                                    ' *******************************************************
                                    '
                                    'Adds line numbers to existing code and creates a new .bas file
                                    '  Useful if a program is GPF'ing. The error msg will indicate
                                    '  the last line number that executed okay.
                                    '
                                    '********* Notes  **************
                                    'Does not add line numbers to Macros (they don't like them)
                                    '  Yields a 'Duplicate Line number error if a Macro is referenced
                                    '  more than once  
                                    'Won't affect/change existing program. It creates a New program (See Destination File)
                                    '  Easiest to just Browse for a Source file and click Big Blue Button.
                                    '  Then load Destination file in your Editor (hope it's JFP) and run from
                                    '  there.
                                    'Doesn't do great deal of Error checking, so it's on you if you change defaults
                                    'Colors are due to an Italian/Mexican/Jamican mix girlfriend I had when young
                                    '  who "influenced" me. Change to taste.
                                    'Uses a font called "Bickley Script" you most likely don't have.
                                    '  Change to an appropriate font you do have (I like Bickley. I once dated a college 
                                    '  girl with nice handwriting.)
                                    '
                                    '
                                    '
                                    ' *******************************************************
                                    '
                                    'PBWIN 9.01 - WinApi 05/2008 - XP Pro SP3
                                    #Dim All 
                                    #Compile Exe  
                                    #Optimize SPEED
                                    #Debug Display On'off for production code
                                     
                                    ' Includes
                                    ' *******************************************************
                                    '
                                    #Include "WIN32API.INC"
                                    #Include "COMDLG32.INC"
                                    #Include "InitCtrl.inc"
                                     'these next included files needed for button colors can be found here: 
                                     'http://www.powerbasic.com/support/pbforums/showthread.php?t=38904
                                    #Include "C:\Only_My_Programs\Include Files\ButtonPlus.bas"
                                    #Resource "C:\Only_My_Programs\Include Files\ButtonPlusDemo.pbr"
                                     
                                    '
                                    ' Globals
                                    ' *******************************************************
                                    '
                                    Global hdlg As Dword                
                                    Global g_Dlg_ht, g_Dlg_Wd As Long 'Global in case want to use in Controls
                                    '
                                    ' Program Id's
                                    ' *******************************************************
                                    '
                                    %Source_File_Id = 1000     
                                    %Browse_for_Source_Id = 1002
                                    %Destination_File_Id = 1010
                                    %Browse_for_Destination_File_Id = 1012
                                    %Start_With_Number = 1014
                                    %Fire_Id = 1100
                                    %Exit_Btn_Id = 10000
                                    ' 
                                    'Macros
                                    ' *******************************************************
                                    '
                                    Macro Common_Locals 'Macro easier than retyping and maintains coding consistency
                                      Local clor, Text_color, tb_wd, Id, Stile, Row, col, ht, wd, Longest,ctr, ln, ln1, i As Long
                                      Local fnum, Starting_Number As Long
                                      Local  t, tmp(), src, dest, fil, l, s As String                                                           
                                      Local f_Script, f_Consolas As Dword
                                    '  Local Btn_Text_Color, Btn_Face_Color
                                      Font New "Bickley Script", 20 To f_Script
                                      Font New "Consolas", 12 To f_Consolas
                                    End Macro  
                                    '
                                    Macro Draw_Textbox
                                      Wd = 100
                                      Ht = 40
                                      Text_Color = %Black
                                      Select Case Id
                                        Case %Source_File_Id     
                                          clor = %Blue
                                         Text_Color = %White
                                        Case %Destination_File_Id
                                          clor = %Green
                                        Case %Start_With_Number
                                          Clor = %Yellow
                                      End Select
                                     
                                      Control Add Label, hdlg, Id + 1, s$ + "  ", col, Row, wd, ht, %ss_right       
                                      Control Set Font hdlg, Id + 1, f_Script
                                      Control Set Color hdlg, Id + 1, Text_Color, clor
                                     
                                      Control Add TextBox, hdlg, Id, s$, col + wd + 10, Row, tb_Wd, ht       
                                      Control Set Font hdlg, Id, f_Consolas
                                      If Id = %Source_File_Id Then Id = %Browse_for_Source_Id'add browse button
                                      If Id = %Destination_File_Id Then Id = %Browse_for_Destination_File_Id
                                      If Id <> %Start_With_Number Then
                                         Control Add Button, hdlg, Id, "Browse", col + wd + 10 + tb_wd + 10, Row, wd, ht       
                                         Control Set Font hdlg, Id, f_Script                 
                                         ButtonPlus hDlg, Id, %BP_Face_COLOR, Clor
                                      End If   
                                     
                                    '  End If
                                    End Macro 
                                    '
                                    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''   
                                    '
                                    '------------------------------------------------------------------------------
                                    ' Browse for start-folder
                                    ' taken from Examples\FileFind.bas
                                    '------------------------------------------------------------------------------
                                    Function GetFolder (ByVal hParent As Dword) As String
                                        Local PathID As Dword
                                        Local bInf As BROWSEINFO
                                        Local szPath As Asciiz * %MAX_PATH
                                        bInf.hWndOwner = hParent 'Set some properties for the BFF dialog
                                        bInf.ulFlags   = %BIF_RETURNONLYFSDIRS Or %BIF_DONTGOBELOWDOMAIN
                                        bInf.lpszTitle = VarPtr(szPath)
                                        PathID = SHBrowseForFolder(bInf) 'Show the Browse-For-Folder dialog
                                        If PathID Then
                                            If SHGetPathFromIDList(ByVal PathID, szPath) Then
                                                Local gStartPath$
                                                gStartPath  = Extract$(szPath, Chr$(0))
                                                Function   = gStartPath
                                            End If
                                            CoTaskMemFree PathID 'Free allocated memory
                                        End If
                                    End Function
                                    '------------------------------------------------------------------------------
                                    '
                                    Sub Add_Line_Numbers
                                       common_Locals                
                                       Control Get Text hdlg, %Source_File_Id To src$ 
                                       If src$ = "Source file" Then
                                         ? src$,, "Error - No source file chosen"
                                         Exit Sub
                                       End If
                                    '
                                       Control Get Text hdlg, %Destination_File_Id To dest$ 
                                       If Trim$(dest$) = "Destination" Then
                                         ? dest$,, "Error - No Destination file chosen"
                                         Exit Sub
                                       End If                             
                                    '
                                       Control Get Text hdlg, %Start_With_Number To s$ 
                                       Replace "," With "" In s$
                                       Starting_Number = Val(s$)
                                     
                                       fnum = FreeFile
                                        Open Src$ For Binary As fnum
                                         ln = Lof(fnum)   
                                       t$ = Space$(ln)'create a space to put the file
                                       Get fnum,,t$  'put the file in the space
                                       Close fnum 
                                        ctr = ParseCount(t$, $CrLf) 
                                          Dim tmp$(ctr)
                                        Parse t$, tmp$(), $CrLf 
                                        If Starting_Number + UBound(tmp$()) > 65500 Then
                                          ? s$,,"Error, Starting number too big"
                                          Exit Sub
                                        End If
                                     
                                        Open dest$ For Output As #fnum 
                                        Local macro_flag, Continuation_Flag As Long
                                        For ctr = 1 To UBound(tmp$())
                                    '      If Left$(Trim$(tmp$(ctr)), 1) = "'" Then Iterate For 'skip remarks
                                    '      If Trim$(tmp$(ctr)) = "" Then Iterate For 'skip blank lines
                                    '      Print #fnum, tmp$(ctr)    
                                          s$ = Trim$(tmp$(ctr))                        
                                     'No line numbers on macro definitions 
                                          If Left$(s$, 5) = "Macro" Then  macro_flag = 1
                                          If Left$(s$, 9) = "End Macro" Then 
                                             macro_flag = 0
                                            Print #fnum, tmp$(ctr)
                                            Iterate For
                                          End If           
                                     
                                          If macro_flag = 1 Then 
                                            Print #fnum, tmp$(ctr)
                                            Iterate For
                                          End If  
                                     
                                          s$ =  Using$("######  ", Starting_Number)
                                          If Continuation_Flag = 0 then
                                             Print #fnum, s$ & tmp$(ctr)
                                            Else 
                                             Print #fnum, tmp$(ctr)
                                          End If   
                                          Control Set Text hdlg, %Source_File_Id, s$ & tmp$(ctr) 'just to watch
                                          Incr Starting_Number
                                     
                                          Continuation_Flag = InStr(tmp$(ctr), " _")
                                        Next ctr 
                                        Close #fnum
                                    End Sub
                                    '
                                    ' Callbacks
                                    ' *******************************************************
                                    '
                                    CallBack Function PBMain_Processor              
                                      Common_Locals                                           
                                      Select Case CbMsg     'This is TO determine the message TYPE 
                                         '       
                                         Case %WM_INITDIALOG'<- Initialiaton when the program loads 
                                         '
                                         Case %WM_SYSCOMMAND 'Traps Any Alt key but only F4 closes              
                                         '
                                         Case %WM_COMMAND  'This processes command messages
                                           Select Case CbCtl
                                         '    Case %Id_Show_Result_Btn 
                                         '       Control Get Text CbHndl, %Id_Sample_Textbox To l$
                                         '         ? l$, , FuncName$
                                             '
                                             Case %Source_File_Id
                                             '
                                             Case %Browse_for_Source_Id', %Browse_for_Destination_File_Id
                                                 OpenFileDialog (hdlg, _            ' parent window
                                                             "Choose the File to add line numbers to", _       ' caption
                                                             fil$, _            ' filename
                                                             "", _    ' start directory
                                                             "", _        ' filename filter
                                                             "bas", _  ' default extension
                                                             ctr _    ' flags
                                                             )
                                                Control Set Text hdlg, %Source_File_Id, fil$          
                                                     i = InStr(-1, fil$, "\") 'Create temporary file name
                                                     If i Then
                                                       fil$ = Left$(fil$, i) & _
                                                              "Numbered_" & _
                                                             Right$(fil$, Len(fil$) - i)
                                    '                 ? fil$         
                                                     End If
                                                Control Set Text hdlg, %Destination_File_Id, fil$          
                                             '
                                             Case %Fire_Id
                                               Call Add_Line_Numbers
                                     
                                             '
                                             Case %Exit_Btn_Id
                                               Select Case CbCtlMsg        
                                                  Case 0
                                                    Dialog End CbHndl 'Applikation beenden
                                               End Select
                                           End Select
                                      End Select
                                    End Function
                                    '                           
                                    '
                                    ' *******************************************************
                                    '
                                    Function PBMain
                                      Common_Locals
                                     'starting values
                                       Stile = Stile Or %WS_CAPTION
                                       Stile = Stile Or %WS_SYSMENU
                                       Stile = Stile Or %WS_THICKFRAME 
                                       Stile = Stile Or %WM_HELP 
                                       Stile = Stile Or %WS_Border  'doesn't do anything
                                      g_Dlg_ht = 300
                                      g_Dlg_Wd = 1000
                                      tb_wd = g_Dlg_Wd - 250
                                      'Dialog Font "Consolas", 72 ' Big Unicodes
                                      Dialog New Pixels, hdlg, "Line Numbering Addition", , , g_Dlg_Wd, g_Dlg_ht, Stile To hdlg 'centered
                                      Dialog Set Color hdlg, -1, &hff00ff
                                      '
                                      Row = 10
                                      col = 10
                                      Id = %Source_File_Id
                                      s$ = "Source file"
                                      Draw_Textbox
                                      '
                                      Row = Row + ht + 10
                                      s$ = "Destination"
                                      Id = %Destination_File_Id
                                      Draw_Textbox
                                      '
                                      Row = Row + ht + 10
                                      Id = %Start_With_Number
                                      s$ = "Starting #"
                                      Draw_Textbox
                                       Control Set Text hdlg, Id, Using$(" ###,### ",10000)
                                       ht = 50   
                                       Wd = g_Dlg_wd - 40
                                       col =  (g_Dlg_wd - wd) \ 2 
                                       Row = g_Dlg_ht - (Ht * 2.7) 'Just off bottom 
                                      Id = %Fire_Id 
                                      Control Add Button, hdlg, Id, _
                                         "Browse/Choose or Enter a Source file "  & $CrLf & _
                                         "and Click Here to create a Line Numbered file", _
                                          col, row, Wd, Ht * 1.5
                                         ButtonPlus  hdlg, Id, %BP_FACE_BLEND, 255 'truer color
                                         ButtonPlus hDlg, Id, %BP_Face_COLOR, %Blue
                                         ButtonPlus hDlg, Id, %BP_Text_COLOR, %White
                                        Control Set Font hdlg, Id, f_Script
                                       Row = g_Dlg_ht - Ht - 2 'Just off bottom
                                       Id =  %Exit_Btn_Id
                                      Control Add Button, hdlg, Id, "Abandon Ship", col, row, Wd, Ht
                                         ButtonPlus  hdlg, Id, %BP_FACE_BLEND, 255 'truer color
                                         ButtonPlus hDlg, Id, %BP_Face_COLOR, %Red
                                         ButtonPlus hDlg, Id, %BP_Text_COLOR, %White
                                     
                                        Control Set Font hdlg, Id, f_Script
                                     
                                         Dialog Show Modal hDlg   Call PBMain_Processor
                                    End Function  'Applikation beenden
                                    '
                                    ==================================
                                    "A man with a new idea is a crank
                                    until the idea succeeds."
                                    Mark Twain
                                    ==================================
                                    Last edited by Gösta H. Lovgren-2; 5 Aug 2009, 07:02 PM.
                                    It's a pretty day. I hope you enjoy it.

                                    Gösta

                                    JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
                                    LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

                                    Comment

                                    Working...
                                    X