• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

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 29 Oct 2013, 23:39

    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
    • J Offline
      jolran
      last edited by 30 Oct 2013, 08:12

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

      1 Reply Last reply Reply Quote 0
      • T Offline
        TIG Moderator
        last edited by 30 Oct 2013, 09:36

        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
        • A Offline
          AdamB
          last edited by 30 Oct 2013, 11:27

          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 30 Oct 2013, 16:00

            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
            • D Offline
              Dan Rathbun
              last edited by 2 Nov 2013, 05:30

              Read the Pick-Axe book.

              I'm not here much anymore.

              1 Reply Last reply Reply Quote 0
              • M Offline
                mptak
                last edited by 3 Nov 2013, 03:42

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

                1 Reply Last reply Reply Quote 0
                • D Offline
                  Dan Rathbun
                  last edited by 3 Nov 2013, 03:45

                  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 3 Nov 2013, 04:51

                    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
                    1 / 1
                    • First post
                      9/9
                      Last post
                    Buy SketchPlus
                    Buy SUbD
                    Buy WrapR
                    Buy eBook
                    Buy Modelur
                    Buy Vertex Tools
                    Buy SketchCuisine
                    Buy FormFonts

                    Advertisement