'How to print a string from SketchUp Ruby into HTML

Good afternoon,

I have a piece of code here which you can run in SketchUp's Ruby console. When you do, you will get a popup which prints the letter 'a'. However in my code, you can see I have identified 'a' as a string '50.12'.

        dialog = UI::HtmlDialog.new(
    {
      :dialog_title => "Observation Information Plugin",
      :scrollable => true,
      :resizable => true,
      :width => 500,
      :height => 200,
      :left => 200,
      :top => 200,
      :min_width => 50,
      :min_height => 50,
      :max_width =>1000,
      :max_height => 500,
      :style => UI::HtmlDialog::STYLE_DIALOG
    })

a = 50.12
a = a.to_s

html = "
<!DOCTYPE html>
<html>
    <body>
        <script type = 'text/javascript'>
            document.write('<p>a</p>');
        </script>
    </body>
</html> 
"

dialog.set_html(html)
dialog.show

What can I do to modify the HTML portion of my code to get the script to print 50.12 to the screen instead of the letter 'a'?

Thanks for your help!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source