Thanks for the quick reply. That part of the code works now, as it does not crash anymore, however it does not solve the problem because:
-when the file is actually loaded, it does not go "back" and check that if statement in order to execute that block of code.
Upon startup, it goes through the script and obviously at that time @logPath is nil as nothing has yet been loaded into it, and so that if statement is not executed.
But: Now, that sketchup has started up and everything is loaded, I now click on my open file button, choose a file to be opened (sample.txt for example) and once I click open, @logPath holds the path to that file. (ie, if I open the ruby console, and print it, it actually stores that path...which is good news, almost)
But, the issue is here: Now, that @logPath actually HAS a value, I now want it to check the if statement, and execute that block of code. (since now @logPath is valid). But it does not do that! I do not know how the script is read and if I had a debugger I'd be able to see exactly where it is going. I am pasting that block of code to make it easier to see:
def gui()
plugins = Sketchup.find_support_file("Plugins")
icon = File.join(plugins, "pictures", "log.jpg")
icon2 = File.join(plugins, "pictures", "ma.jpg")
icon3 = File.join(plugins, "pictures", "execute.jpg")
tb = UI::Toolbar.new("CD++")
log = UI::Command.new("Load log file") { @logPath = UI.openpanel("Open Log File")}
###(the above line is the one I am referring to...once I open a file, @logPath
### holds the path, and I expect it then to check the condition below here
if @logPath
x = File.join(@logPath.split('\'))
readLog(File.join(@logPath.split('\')))
end
log.large_icon = icon
#File.join(@logPath.split('\'))
#ma = UI::Command.new("Load MA file") { maPath = UI.openpanel("Open Ma File")}
#ma.large_icon = icon2
#execute= UI::Command.new("Execute event") {UI.messagebox("This will execute")}
#execute.large_icon = icon3
tb.add_item(log)
#tb.add_item(ma)
#tb.add_item(execute)
tb.show
end