I have a problem using the Windows “Inputbox” function.
I’m trying to do what I sometimes do in VBScript to create a
multiple-choice scenario within a windowless application. Via the
various built-in messagebox / inputbox functions of Windows. The way to
do this is to pass newlines into the inputbox message, allowing for
multiple lines, each with a numbered option.
I have attached the module I wrote (mostly plagiarised) to facilitate
this in Ruby.
This works fine in VBScript:
inputbox “1 - Test” & Chr(13) & “2 - Testy” & vbCrLf & “3 - Testa”
However, this fails in Ruby:
irb(main):001:0> load ‘WinBoxes.rb’
=> true
irb(main):002:0> include WinBoxes
=> Object
irb(main):003:0> inputbox “1 - Test\n2 - Testy\n3 - Testa”
WIN32OLERuntimeError: (in OLE method eval': ) OLE error code:800A0409 in Microsoft VBScript compilation error Unterminated string constant HRESULT error code:0x80020009 Exception occurred. from C:/Users/Joel/Desktop/Files/Projects/bin/WinBoxes.rb:29:in
method_missing’
from C:/Users/Joel/Desktop/Files/Projects/bin/WinBoxes.rb:29:in
inputbox' from (irb):3 from C:/Ruby200/bin/irb:12:in
’
I’ve tried this with “\r”, “\r\n”, 10.chr, and 13.chr as well. I’m at a
loss as to how to get around this without having to package a full GUI
into my program, something I’m reluctant to do because of the size
increase.