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

    Array doesn't work...

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 3 Posters 372 Views 3 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.
    • K Offline
      kiesewetter
      last edited by

      Hallo!
      You might laugh because of that post, but I'm not able to find the reason why it doesn't work...

      I just want to create an infobox and safe the input to some variables...

      Here is the code and Sketchup's comment in the debugger:

      prompts = ["Bildhöhe", "Bildbreite", "Bilder pro Sekunde", "Filmdauer in Sekunden", "Ausgabename"] 
      default = [  "800",         "800",           "25",                  "60",             "Ablauf" ]
      aufnahmebox = UI.inputbox prompts, default, "Ablaufsimulation mit statischer Ansicht"
      hoehe = aufnahmebox[0].to_i
      breite= aufnahmebox[1].to_i
      fps=aufnahmebox[2].to_i
      dauer = aufnahmebox[3].to_i
      name = aufnahmebox[4]
      

      load "C:/Users/tim/Desktop/array.rb"
      Error: #<SyntaxError: (eval):4:in `load': C:/Users/tim/Desktop/array.rb:1: syntax error, unexpected tCONSTANT, expecting ']'
      ...pts = ["Bildhöhe", "Bildbreite", "Bilder pro Sekunde", "Film...
      ^
      C:/Users/tim/Desktop/array.rb:1: syntax error, unexpected tCONSTANT, expecting $end
      ...ldhöhe", "Bildbreite", "Bilder pro Sekunde", "Filmdauer in S...
      ^>
      (eval):4
      (eval):4

      Thanks for your time.
      Tim

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

        Try this

        def test
            prompts = ["Bildhoehe; ", "Bildbreite; ", "Bilder pro Sekunde; ", "Filmdauer in Sekunden; ", "Ausgabename; "]
            defaults = [800, 800, 25, 60, "Ablauf" ]
            aufnahmebox = UI.inputbox(prompts, defaults, "Ablaufsimulation mit statischer Ansicht")
            hoehe = aufnahmebox[0]
            breite= aufnahmebox[1]
            fps=aufnahmebox[2]
            dauer = aufnahmebox[3]
            name = aufnahmebox[4]
        end
        

        See how I removed the accented letter 'ö' and used a 'oe'. Ruby/SUp isn't good with some 'accents' in some circumstances.
        'Bildhoehe' now works fine...
        Also note how I have removed the "" from the values you want as integers and made them integers initially - that way you can't try to use anything that isn't an integer as your input...
        I've also put the arguments for inputbox inside () - recommended but not fatal otherwise [yet]...

        TIG

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

          @tig said:

          See how I removed the accented letter 'ö' and used a 'oe'. Ruby/SUp isn't good with some 'accents' in some circumstances.
          'Bildhoehe' now works fine...

          That'd most likely be because different character encoding in the .rb file from SU. SU uses Unicode, UTF-8 encoded in it's interface. Should be find to pass on UTF-8 data, but it needs to be properly encoded.
          (though I'm not sure if you can run .rb files in UTF-8 - so one might need to write the strings in a UTF-8 file and change the encoding (don't convert, just change) in the editor - which should give you some extra funny looking characters.

          Might be easier to manage and reduce risk if you store them strings in an external UTF-8 encoded text file and load them from there.

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

          1 Reply Last reply Reply Quote 0
          • K Offline
            kiesewetter
            last edited by

            Works! 😄
            Thank you!

            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