sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Win32 output debugging

    Scheduled Pinned Locked Moved Developers' Forum
    9 Posts 4 Posters 2.9k Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J Offline
      Jim
      last edited by

      An alternative way for debugging on Windows machines using Win32API.so.

      You need a system debug viewer running such as DebugView and output goes to the debugger window. Also,

      @unknownuser said:

      If the application has no debugger and the system debugger is not active, OutputDebugString does nothing.

      This could also be used with Al's trace ruby messages technique so instead of output going to files ,it goes to the debugger.

      Come to think of it, something like this should be part of the api.

      
      OutputDebugString = Win32API.new("kernel32.dll", "OutputDebugString", ['P'], 'V')
      
      def opd(s="\0")
          s = s.to_s + "\0"
          OutputDebugString.call(s)
      end
      
      opd(Time.now)
      
      

      Hi

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        This is excellent! πŸ‘ πŸ‘

        @jim said:

        Come to think of it, something like this should be part of the api.

        Double Plus Good!

        Thomas Thomassen β€” SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • Chris FullmerC Offline
          Chris Fullmer
          last edited by

          How would I use this Jim? I add that code to a script while I'm writing it. And do do what with it? It just does everything on its own?

          Lately you've been tan, suspicious for the winter.
          All my Plugins I've written

          1 Reply Last reply Reply Quote 0
          • J Offline
            Jim
            last edited by

            In DebugView, you can clear the debugger window by outputting the string "DBGVIEWCLEAR"

            Hi

            1 Reply Last reply Reply Quote 0
            • tbdT Offline
              tbd
              last edited by

              Jim: are you working for Render Plus now ? πŸ˜‰

              SketchUp Ruby Consultant | Podium 1.x developer
              http://plugins.ro

              1 Reply Last reply Reply Quote 0
              • thomthomT Offline
                thomthom
                last edited by

                I think this thread should be sticky... or in the sticky thread...

                Thomas Thomassen β€” SketchUp Monkey & Coding addict
                List of my plugins and link to the CookieWare fund

                1 Reply Last reply Reply Quote 0
                • J Offline
                  Jim
                  last edited by

                  It turns out this OutputDebugString example is straight out of the Pickaxe book.

                  Hi

                  1 Reply Last reply Reply Quote 0
                  • thomthomT Offline
                    thomthom
                    last edited by

                    class CL_rps_console < Sketchup::Console

                    Sketchup::Console ❓ ❓

                    Thomas Thomassen β€” SketchUp Monkey & Coding addict
                    List of my plugins and link to the CookieWare fund

                    1 Reply Last reply Reply Quote 0
                    • J Offline
                      Jim
                      last edited by

                      Here's what I came up with. Just make sure it is alphabetically the first file in Plugins in order to capture the earliest output.

                      
                      require 'Win32API'
                      
                      class CL_rps_console < Sketchup;;Console
                          OutputDebugString = Win32API.new("kernel32.dll", "OutputDebugString", ['P'], 'V')
                          def write(smess="\0")
                              smess = smess.to_s + "\0"
                              OutputDebugString.call(smess)
                          end
                      end
                      
                      # redefine standard output to our new class
                      $old_stdout = $stdout # in case you want to turn off traces
                      $stdout = CL_rps_console.new
                      $stderr = $stdout
                      puts "-" * 40
                      puts Time.now
                      puts "Starting SketchUp"
                      puts "-" * 40
                      
                      
                      
                      

                      Hi

                      1 Reply Last reply Reply Quote 0
                      • 1 / 1
                      • First post
                        Last post
                      Buy SketchPlus
                      Buy SUbD
                      Buy WrapR
                      Buy eBook
                      Buy Modelur
                      Buy Vertex Tools
                      Buy SketchCuisine
                      Buy FormFonts

                      Advertisement