[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

uninitialized constant error

Zhao Yi

1/30/2009 12:19:00 PM

I have three ruby classes, see below:

1. base_cls.rb

File.dirname(__FILE__)+'/cls_factory'
class BaseCls

def self.say
ClsFactory.say
end
end
BaseCls.say

2. sub_cls.rb

require File.dirname(__FILE__)+'/base_cls'

class SubCls < BaseCls
end

3. cls_factory.rb

require File.dirname(__FILE__)+'/sub_cls'

class ClsFactory
def self.get_cls
SubCls.new
end
end

When I run base_cls.rb, I got this error:

base_cls.rb:5:in `say': uninitialized constant BaseCls::ClsFactory
(NameError)

I don't understand why this error happens? Can anyone help me on this?

thanks.
--
Posted via http://www.ruby-....

3 Answers

Stefan Lang

1/30/2009 6:23:00 PM

0

2009/1/30 Zhao Yi <youhaodeyi@gmail.com>:
> I have three ruby classes, see below:
>
> 1. base_cls.rb
>
> File.dirname(__FILE__)+'/cls_factory'
> class BaseCls
>
> def self.say
> ClsFactory.say
> end
> end
> BaseCls.say
>
> 2. sub_cls.rb
>
> require File.dirname(__FILE__)+'/base_cls'
>
> class SubCls < BaseCls
> end
>
> 3. cls_factory.rb
>
> require File.dirname(__FILE__)+'/sub_cls'
>
> class ClsFactory
> def self.get_cls
> SubCls.new
> end
> end
>
> When I run base_cls.rb, I got this error:
>
> base_cls.rb:5:in `say': uninitialized constant BaseCls::ClsFactory
> (NameError)
>
> I don't understand why this error happens? Can anyone help me on this?

Maybe you meant to prefix the first line in base_cls.rb with "require"?

Stefan

Zhao Yi

1/31/2009 6:07:00 AM

0

Stefan Lang wrote:
> Maybe you meant to prefix the first line in base_cls.rb with "require"?
>
> Stefan

Oh, sorry, I forgot to type the 'require'. But the problem is still
there.
--
Posted via http://www.ruby-....

Tim Williams (Theravance)

12/22/2009 12:10:00 AM

0

Maybe one of those cells doesn't have a hyperlink.

Tim

On Dec 18, 9:10 pm, Doug <D...@discussions.microsoft.com> wrote:
> Now it is giving me a runtime error 9
> Subscript out of range
>
> Private Sub Worksheet_SelectionChange(ByVal Target As Range)
>
> Const RNGS As String =
> "A2,A3,A4,A6,A7,A9,A10,A13,A14,A15,A20,A21,A24,A27,A28,A29"
> Dim x As Integer, arrRngs
> Dim c As Range
>
> arrRngs = Split(RNGS, ",")
> 'If you select A30
> If Not Intersect(Target, Range("A30")) Is Nothing Then
> For x = LBound(arrRngs) To UBound(arrRngs)
> Me.Range(arrRngs(x)).Hyperlinks(1).Follow
> Next x
> End If
>
> End Sub
> --
>
>
>
> "Tim Williams" wrote:
>
> > my bad:
>
> > Tim
>
> > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
>
> > Const RNGS As String = "A2,A3,A4"
> > Dim x As Integer, arrRngs
> > Dim c As Range
>
> >     arrRngs = Split(RNGS, ",")
> >     'If you select A30
> >     If Not Intersect(Target, Range("A30")) Is Nothing Then
> >         For x = LBound(arrRngs) To UBound(arrRngs)
> >             Me.Range(arrRngs(x)).Hyperlinks(1).Follow
> >         Next x
> >     End If
>
> > End Sub
>
> > On Dec 17, 2:09 pm, Doug <D...@discussions.microsoft.com> wrote:
> > > I am recieving a runtime error 438
> > > Object doesn't support this property or method
> > > --
> > > Thank you!
>
> > > "Tim Williams" wrote:
> > > > Try this.
>
> > > > Tim
>
> > > > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
>
> > > > Const RNGS As String = "A2,A3,A4,A6,A7,A9,A10,A13,A14," & _
> > > >                        "A15,A20,A21,A24,A27,A28,A29"
> > > > Dim x As Integer, arrRngs
>
> > > >     arrRngs = Split(RNGS, ",")
> > > >     'If you select A30
> > > >     If Not Intersect(Target, Range("A30")) Is Nothing Then
> > > >         For x = LBound(arrRngs) To UBound(arrRngs)
> > > >             ActiveSheet.Range(arrRngs(x)).Hyperlink.Follow True
> > > >         Next x
> > > >     End If
>
> > > > End Sub- Hide quoted text -
>
> > > - Show quoted text -
>
> > .- Hide quoted text -
>
> - Show quoted text -