sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    The Bug from Hell, Redux

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 2 Posters 270 Views 2 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.
    • M Offline
      MartinRinehart
      last edited by

      An odd bug bit me, and bit hard, on my way to releasing my first serious Ruby.

      The bug was in the communication from JS to Ruby to JS. The problem was that a JS-built WebDialog prepared before the body of the HTML holding the JS was complete had a bug. It could not execute_script().

      The full-length version of The Bug from Hell, including two cameo appearances of Monty, my pet python, is here: http://21st-century-languages.blogspot.com/2009/08/bug-from-hell.html

      Now my Ruby is ready for release except that it does not pass my last test: run successfully on a larger model (two-dozen layers, three-dozen scenes, 3MB .skp). The basic idea is this:

      In Ruby get-the-data callback, assemble JSON data based on model; assemble script to call JS function with JSON data; puts script (it's fine); WebDialog.execute_script( script ).

      The first line of the JS receiver is an alert, showing the JSON. Same as in the Bug from Hell, it never gets there. Unlike the Bug from Hell, which reported nothing, IE reports an error at line 119993461, character 828, "Expected ')'".

      The only (really?) difference between the test cases and the final test is size. The script to be executed was about 2KB. I cut out half the scenes, reducing the script to about 1100B. Same problem.

      Anyone else been here?

      Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

      1 Reply Last reply Reply Quote 0
      • M Offline
        MartinRinehart
        last edited by

        Progress?

        Added this, at the beginning of the Ruby callback:

        
        		script = 'rubyReturned( "Hi, JS, how ya doin\'" )'
        		js_wd.execute_script( script )
        
        

        The JS 'rubyReturned' function popped the message up in an alert box, so it was called and executed correctly. Then got an error on the next line of JS (reasonable, since "Hi, JS, how ya doin'" is not valid JSON).

        The troubling error, at the ridiculous line number, pops next. This is the offending script:

        rubyReturned( "{ layers;[ 'Layer0', 'basement', 'basement_ceiling', 'ground_floor', 'apartment_floor', 'apartment_built_ins', 'hidden', 'apartment_furniture', 'apartment_inside_walls', 'outside_wall_front', 'outside_wall_right', 'outside_wall_back', 'outside_wall_left', 'attic', 'roof_front', 'roof_back' ], scenes;[ '01 start', '02 outside, back-left', '03 outside, back-right', '04 outside, front-right', '05 outside, zoom out', '06 outside, closer, no apartment', '07 outside, close, no apartment floor', '08 outside, close, no ground floor', '09 above, basement', '10 above, basement w/ceiling', '11 above, carriage garage', '12 outside apartment door', '13 outside, apartment added', '14 above apartment, wo roof_front', '15 outside apartment, wo outside_wall_front', '16 outside, facing dinette and attic', '17 outside "ladder", w outside_wall_front', '18 outside facing livingroom, roof_front replaces roof_back', '19 zoom in to livingroom' ], vis;'VVVVVVVVVVVVVVVVVVVIIIIIIIVVVVVVVVVVVVVVVVVVVVIVVVVVVVVVVVVVVVVVIIIVVVVVVVVVVVVVVVIIIIIIVVVVVVVVVVVVIIIIIIIVVVVVVVIIIIIIIIIIIIIIIIIIIVVVVVIIIIIIIVVVVVVVVVVVVIIIIIIIVVVVVVVVVVVVIIIIIIIVVIIVVVVVVVVIIIIIIIVVVVVVVVVVVVIIIIIIIVVVVVIIVVVVVIIIIIIIVVVIIIIIIIIIIIIIIIIIVVVIIIVVVVVIIIIIIIVIIIIVVVVVVVIIIIIIIVVVVVII' }" );
        
        

        Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

        1 Reply Last reply Reply Quote 0
        • M Offline
          MSP_Greg
          last edited by

          Martin,

          When writing a component stepper and a layer stepper, I had to escape () both single and double quotes everywhere when used in string data passed to a JS function using execute_script.

          Greg

          1 Reply Last reply Reply Quote 0
          • M Offline
            MartinRinehart
            last edited by

            @msp_greg said:

            When writing a component stepper and a layer stepper, I had to escape () both single and double quotes everywhere ...

            Thanks! Bug gone.

            Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

            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