• Login
sketchucation logo sketchucation
  • Login
Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
🫛 Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

Array doesn't work...

Scheduled Pinned Locked Moved Developers' Forum
4 Posts 3 Posters 391 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 8 Jan 2011, 09:53

    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
    • T Offline
      TIG Moderator
      last edited by 8 Jan 2011, 12:03

      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
      • T Offline
        thomthom
        last edited by 8 Jan 2011, 12:59

        @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 8 Jan 2011, 19:12

          Works! 😄
          Thank you!

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

          Advertisement