Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Suggestions ➜ Ruby revisted

Ruby revisted

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1  2  3 

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #30 on Wed 16 May 2007 03:01 AM (UTC)
Message
So you would write:


$eOK = 0 # No error
$eWorldOpen = 30001 # The world is already open
$eWorldClosed = 30002 # The world is closed, this action cannot be performed 


... and so on?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Ariesroyaal   (20 posts)  Bio
Date Reply #31 on Wed 16 May 2007 12:00 PM (UTC)
Message
yep
Top

Posted by Ariesroyaal   (20 posts)  Bio
Date Reply #32 on Thu 31 May 2007 01:17 PM (UTC)
Message
No globals joy!
Top

Posted by Ayon   (6 posts)  Bio
Date Reply #33 on Fri 15 Oct 2010 10:50 AM (UTC)
Message
As a general rule with ruby, there is always what is called the Default Receiver, everything is an object, or maybe an object context. ActiveRuby doesn't seem to obey this in the strictest sense.

Normally, if you just create a ruby file and type def some_method, those methods are auto added to this kind of global class object. Obviously, through some magic, it isn't happening when you are using ActiveRuby so a better shorcut is to just use:

class << self
  def hello_world
    @world.note('Hello World!')
  end
end

...

hello


This worked for me fine in the latest version.

If I were to take a stab, I would say that some disconnect has happened in the way ruby falls back to the default receiver.

for instance, this works:

class << self
  def hello(friend)
   @world.note(friend)
  end
end

hello @world.inspect

#=> #<WIN32OLEEX:0x1f0ce40>

Meaning world is added to the global class' instance variables, we can access all over the place, so there's no real need for changing it to a global variable.

We cant inspect the global class a bit and see what it has, like:

self.methods.each do |m|
  @world.note(m)
end

self.instance_variables.each do |iv|
  @world.note(iv)
end

@world.note(self.class.to_s) #=> Module aha! Normally this would be: #=> Object

At this point scripting completely stopped working,when I tried to list out the ole_methods etc.

You can list out all global variables like so, this took a lot of time to track down:

$testy = 'x'
Kernel.global_variables.each do |m|
	@world.note(m)
end


You'll notice that $testy will appear in there.

Now, I tried a random function call, WindowCreate, doesn't work, neither windowCreate, windowcreate, window_create etc.

I also tried @world.GetInfo and various cases, it also returns method_missing...

If I try to get the ole_methods from the object it returns:

Immediate execution
fail to GetTypeInfo
    HRESULT error code:0x80004001
      Not implemented


This also happens with ole_method_help etc.

I can't seem to call anything, except note, I am probably just missing some obvious piece of information, I am a little dense sometimes. Can anyone point me in the right direction?

/Jason




Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


123,283 views.

This is page 3, subject is 3 pages long:  [Previous page]  1  2  3 

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.