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

    Learning Ruby by Writing a Working Shell?

    Scheduled Pinned Locked Moved Developers' Forum
    9 Posts 6 Posters 348 Views 6 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
      matt.gordon320
      last edited by

      Hi Devs,

      A while back, I tried to start working on a script to create spot elevation markers here http://sketchucation.com/forums/viewtopic.php?f=180&t=51558, which turned out to be far too ambitious for my limited knowledge of ruby. So here's what I'd figuring I'll start doing to write my plugin(s).

      I'm going to start by creating the menus, the organization, and extension information, and get that working in SketchUp first, essentially just as a proof of concept. If I can just get the plugin working as a working "shell" as it were, I can then replace the methods calling Messages Boxes with actual working methods.

      So as my first question: What is causing the script to only return "You clicked YES!" instead of the expected response? [Line 24-29]

      Here's the GIT for those of you that want it:https://github.com/mattgordon320/GB_Tools.git

      Let me know what you think and that'll get me a start!

      Thanks gents!

      -Matt


      GB_Tools.rb

      1 Reply Last reply Reply Quote 0
      • jolranJ Offline
        jolran
        last edited by

        It could be the if statement your using assignment instead of comparison ?
        = to ==

        1 Reply Last reply Reply Quote 0
        • TIGT Offline
          TIG Moderator
          last edited by

          As has been said - your tests do not use the correct syntax.

          Using if x = 6 is ALWAYS going to return true... because using that syntax you have simply set x to be 6: the = 'assigns' values.
          Using if x **==** 6 will only return true if x IS 6: the == 'compares' values.

          πŸ˜’

          TIG

          1 Reply Last reply Reply Quote 0
          • AdamBA Offline
            AdamB
            last edited by

            In order to avoid using assignment rather than comparison, software devs often put the constant on the left side of the expression because it cannot be "assigned to" (properly, its not an "lvalue") so you avoid this common typo.

            ie write it as:

            if 6 == x

            whereas (mistakenly) typing:

            if 6 = x

            will cause your programming language to bark at you.

            Developer of LightUp Click for website

            1 Reply Last reply Reply Quote 0
            • M Offline
              matt.gordon320
              last edited by

              Ah, I see. Fixed. I've definitely got more digging and learning to do. I don't understand the ruby syntax very well yet. Thanks guys! I'll post whenever I update more/have another question.

              1 Reply Last reply Reply Quote 0
              • Dan RathbunD Offline
                Dan Rathbun
                last edited by

                Read the Pick-Axe book.

                I'm not here much anymore.

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

                  Pick Axe book...you mean the Ruby Newbie's Guide....?

                  1 Reply Last reply Reply Quote 0
                  • Dan RathbunD Offline
                    Dan Rathbun
                    last edited by

                    I mean:

                    [doc] Programming Ruby (The "Pick-Axe" Book)

                    πŸ’­

                    I'm not here much anymore.

                    1 Reply Last reply Reply Quote 0
                    • M Offline
                      matt.gordon320
                      last edited by

                      Thanks Dan, coincidentally I just bought the pick axe. I'll be hammering though my way through that starting this weekend πŸ˜„

                      Sent from my Galaxy Nexus using Tapatalk

                      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