Best way to brake up a string within FXruby?

View: New views
12 Messages — Rating Filter:   Alert me  

Best way to brake up a string within FXruby?

by dglnz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi I have a string inside a FXList that is seperated into columns by spaces.

I will have a need to put this data into editable controls when ever the user clicks on a line.
I thought of using the ruby split(' ') command.

The way i was going to do this was to have it setup like this...

control.text, control.text... = ALine.split(' ')

but i got a error referring to split as being private!
Is there a better way of doing this?

I have googled but for the present i have not found anything meaningful.

anyone able to help?

dave.

Reading this email at work? Make a change with Yahoo!Xtra Jobs
_______________________________________________
fxruby-users mailing list
fxruby-users@...
http://rubyforge.org/mailman/listinfo/fxruby-users

Re: Best way to brake up a string within FXruby?

by David MacMahon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Aug 25, 2009, at 3:56 , dave L wrote:

> The way i was going to do this was to have it setup like this...
>
> control.text, control.text... = ALine.split(' ')
>
> but i got a error referring to split as being private!

Are you sure ALine is a String?

Dave

_______________________________________________
fxruby-users mailing list
fxruby-users@...
http://rubyforge.org/mailman/listinfo/fxruby-users

Parent Message unknown Re: Best way to brake up a string within FXruby?

by dglnz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Nataraj S Narayan & David MacMahon,
Thanks for your quick reply.

David,
Yes Aline is a string as it is actually obtained from fxlist and has data like Job No, Date, Time (PC system obtained) plus other entries but i am wanting to ADD to the list.

Nataraj,

Didn't think of doing this!
as i'd just thought these would be in as a system function of FXruby.
Lession learnt :)
many thanks to you both.

Dave
--- On Wed, 26/8/09, David MacMahon <<a
*** snipped ***


     
_______________________________________________
fxruby-users mailing list
fxruby-users@...
http://rubyforge.org/mailman/listinfo/fxruby-users

Parent Message unknown Re: Best way to brake up a string within FXruby?

by dglnz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Right still not able to import String functionality into FXruby!

the error i get is this...

C:/Ruby1.8/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- string (LoadError)
    from C:/Ruby1.8/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from mymainwin.rb:5
>Exit code: 1


sample of code is this ...

require 'time'
require 'string'

' a method to break a line of text into words that are passed onto texfields for editting.

def breakWord (theword)
  @atextfield.text, @btextfield.text, @ctextfield.text, @Dtextfield.text = theword.split(' ')
end

the data being passed into the above method *IS* text so for example string...

"the fox jumped over" would be passed into breakWord and each control will get each word put into.

I do have other requires and they work okay.
I am using ruby 1.8.x on winXP and know the there isn't any problems with ruby.

pointers?
Is there a FXruby function that could be used?

Dave.

PS got the date/time issue sorted

Need mail bonding? Bring all your contacts to Yahoo!Xtra with TrueSwitch
_______________________________________________
fxruby-users mailing list
fxruby-users@...
http://rubyforge.org/mailman/listinfo/fxruby-users

Re: Best way to brake up a string within FXruby?

by Lyle Johnson-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Aug 27, 2009, at 6:12 AM, dave L wrote:

Right still not able to import String functionality into FXruby!

You don't have to import string functionality into FXRuby, or into any other Ruby program. It's built in to the Ruby language, e.g.

"the fox jumped over".split    # => ["the", "fox", "jumped", "over"]

When you ask questions like this, or your previous questions about how to determine the date or time, it indicates to me that you might want to step back a bit and get more comfortable with basic Ruby programming. These questions have nothing at all to do with FXRuby.

_______________________________________________
fxruby-users mailing list
fxruby-users@...
http://rubyforge.org/mailman/listinfo/fxruby-users

Re: Best way to brake up a string within FXruby?

by Bartosz Dz. :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Maybe it's stupid, but did you try to just make *sure* it's string by
calling its to_s method?

--
Matma Rex - http://matma-rex.prv.pl/
_______________________________________________
fxruby-users mailing list
fxruby-users@...
http://rubyforge.org/mailman/listinfo/fxruby-users

Parent Message unknown Re: Best way to brake up a string within FXruby?

by dglnz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Lye and Bartosz Dz,

Thanks for your replies.

Firstly I'd be the first to admit I'm not the best programmer.
And this highlights it but I DO try to resolve my issues before posting by googling, searching the Rdocs and reading your (Lye) good book for clues on dealing my issue.

I have solved my current problem through using puts in the method to see what i was getting passed into it.

so i had this what i had further down in my code and didn't suspect it as being at fault
breakWord @CRlist3.currentItem Now i have done this breakWord @CRlist3.getItemText(@CRlist3.currentItem)

Lo and behold i got the text associated with the line i had clicked broken down using split(' ').

I must have done a search for a way to capture text when the list was clicked and come across the currentItem method (but it doesn't show up on the list for FXlist in the Rdoc's but setcurrentItem does anyway i can only say i miss understood what it was doing and I did not put in any put's statements prior to today to see what I was getting as this would've shown me my problem).

I hope this posting may help others who are new to FXruby and aren't the best with FXruby/ruby but want to try using this GUI toolkit.

know the volume of traffic isn't high but hope I am not putting people off me.

Rgds,

Dave.


--- On Fri, 28/8/09, Lyle Johnson <lyle@...> wrote:

> From: Lyle Johnson <lyle@...>
> Subject: Re: [fxruby-users] Best way to brake up a string within FXruby?
> To: fxruby-users@...
> Received: Friday, 28 August, 2009, 1:26 AM
>
> On Aug 27, 2009, at 6:12 AM, dave L
> wrote:
> Right still
> not able to import String functionality into
> FXruby!
> You don't have to import
> string functionality into FXRuby, or into any other Ruby
> program. It's built in to the Ruby language,
> e.g.
>     "the fox jumped
> over".split    # => ["the",
> "fox", "jumped",
> "over"]
> When you ask questions like
> this, or your previous questions about how to determine the
> date or time, it indicates to me that you might want to step
> back a bit and get more comfortable with basic Ruby
> programming. These questions have nothing at all to do with
> FXRuby.
> -----Inline Attachment Follows-----
>
> _______________________________________________
> fxruby-users mailing list
> fxruby-users@...
> http://rubyforge.org/mailman/listinfo/fxruby-users

Need mail bonding? Bring all your contacts to Yahoo!Xtra with TrueSwitch
_______________________________________________
fxruby-users mailing list
fxruby-users@...
http://rubyforge.org/mailman/listinfo/fxruby-users

Is it possible to create a pane dynamically

by Soumyanath Chatterjee :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi!

I am new to FXRuby so excuse me for this stupid question. I need to
enter many different data and trying to create a vertical pane
dynamically using response from a SQL query.

I want these input form to appear in my main window. Created a class
based on FXMainWindow.

--------------- Code snippet ------------
class DbFace < FXMainWindow
    attr_writer \
    :title,

  def addNew
    vPane = FXVerticalFrame.new(@hWnd)
    dTitle = FXLabel.new(vPane,@title,nil,LAYOUT_FILL_ROW)
  end

  def initialize(app, pane)
    @hWnd = pane
    @hApp  = app
  end
end
----------- End -----------------

I use this class from inside my program. As:

  book = DbFace.new(app, @frame)
        book.title = "Add new record"
        book.addNew


The new dialog fields do not show up with this. Please tell me if I am
doing something wrong. Any example will be great.
_______________________________________________
fxruby-users mailing list
fxruby-users@...
http://rubyforge.org/mailman/listinfo/fxruby-users

Re: Is it possible to create a pane dynamically

by Lyle Johnson-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Aug 28, 2009 at 6:55 AM, Soumyanath<soumyanath.c@...> wrote:

> I am new to FXRuby so excuse me for this stupid question.

It is not a stupid question.

> I need to enter many different data and trying to create a vertical pane
> dynamically using response from a SQL query.
>
> I want these input form to appear in my main window. Created a class
> based on FXMainWindow.
>
> --------------- Code snippet ------------
> class DbFace < FXMainWindow
>    attr_writer \
>    :title,
>
>  def addNew
>    vPane = FXVerticalFrame.new(@hWnd)
>    dTitle = FXLabel.new(vPane,@title,nil,LAYOUT_FILL_ROW)
>  end
>
>  def initialize(app, pane)
>    @hWnd = pane
>    @hApp  = app
>  end
> end
> ----------- End -----------------
>
> I use this class from inside my program. As:
>
>        book = DbFace.new(app, @frame)
>        book.title = "Add new record"
>        book.addNew
>
>
> The new dialog fields do not show up with this. Please tell me if I am
> doing something wrong. Any example will be great.

I think you're just leaving out a call to create() for the
newly-constructed widgets. What happens if you add a call to
vPane.create() at the end of your addNew() method?

    def addNew
      vPane = FXVerticalFrame.new(@hWnd)
      dTitle = FXLabel.new(vPane,@title,nil,LAYOUT_FILL_ROW)
      vPane.create
    end

Let me know if that does the trick. For more background on this, see:

    http://www.fox-toolkit.org/faq.html#CREATELATER

Or, even better, buy the FXRuby book and read Chapter 7. ;)

Hope this helps,

Lyle
_______________________________________________
fxruby-users mailing list
fxruby-users@...
http://rubyforge.org/mailman/listinfo/fxruby-users

Re: Is it possible to create a pane dynamically

by Soumyanath Chatterjee-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Lyle,

Thank you for the excellent observation!

Adding a create did the trick. Now the code is working fine.


On Tue, Sep 1, 2009 at 3:42 AM, Lyle Johnson<lyle@...> wrote:

> On Fri, Aug 28, 2009 at 6:55 AM, Soumyanath<soumyanath.c@...> wrote:
>
>> I am new to FXRuby so excuse me for this stupid question.
>
> It is not a stupid question.
>
>> I need to enter many different data and trying to create a vertical pane
>> dynamically using response from a SQL query.
>>
>> I want these input form to appear in my main window. Created a class
>> based on FXMainWindow.
>>
>> --------------- Code snippet ------------
>> class DbFace < FXMainWindow
>>    attr_writer \
>>    :title,
>>
>>  def addNew
>>    vPane = FXVerticalFrame.new(@hWnd)
>>    dTitle = FXLabel.new(vPane,@title,nil,LAYOUT_FILL_ROW)
>>  end
>>
>>  def initialize(app, pane)
>>    @hWnd = pane
>>    @hApp  = app
>>  end
>> end
>> ----------- End -----------------
>>
>> I use this class from inside my program. As:
>>
>>        book = DbFace.new(app, @frame)
>>        book.title = "Add new record"
>>        book.addNew
>>
>>
>> The new dialog fields do not show up with this. Please tell me if I am
>> doing something wrong. Any example will be great.
>
> I think you're just leaving out a call to create() for the
> newly-constructed widgets. What happens if you add a call to
> vPane.create() at the end of your addNew() method?
>
>    def addNew
>      vPane = FXVerticalFrame.new(@hWnd)
>      dTitle = FXLabel.new(vPane,@title,nil,LAYOUT_FILL_ROW)
>      vPane.create
>    end
>
> Let me know if that does the trick. For more background on this, see:
>
>    http://www.fox-toolkit.org/faq.html#CREATELATER
>
> Or, even better, buy the FXRuby book and read Chapter 7. ;)
>
> Hope this helps,
>
> Lyle
> _______________________________________________
> fxruby-users mailing list
> fxruby-users@...
> http://rubyforge.org/mailman/listinfo/fxruby-users
>



--
--
Regards

Soumyanath Chatterjee
http://www.soumya.name
Let's map the world, use http://www.wikimap.biz
_______________________________________________
fxruby-users mailing list
fxruby-users@...
http://rubyforge.org/mailman/listinfo/fxruby-users

Re: Is it possible to create a pane dynamically

by Soumyanath Chatterjee-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi!

Thanks to Lyle's pointer - .create method has solved the pane creation
problem. But there are other problem - how do I get rid of the pane.
Multiple calls to this class keeps stacking the pane over the old one.

In C++, I would have destroyed the old object - what do I do in FXRuby?

vPane.hide - looks to be a work around; but I think this will keep the
old objects in memory. Please suggest a good way to close the screen.



On Tue, Sep 1, 2009 at 3:42 AM, Lyle Johnson<lyle@...> wrote:

> On Fri, Aug 28, 2009 at 6:55 AM, Soumyanath<soumyanath.c@...> wrote:
>
>> I am new to FXRuby so excuse me for this stupid question.
>
> It is not a stupid question.
>
>> I need to enter many different data and trying to create a vertical pane
>> dynamically using response from a SQL query.
>>
>> I want these input form to appear in my main window. Created a class
>> based on FXMainWindow.
>>
>> --------------- Code snippet ------------
>> class DbFace < FXMainWindow
>>    attr_writer \
>>    :title,
>>
>>  def addNew
>>    vPane = FXVerticalFrame.new(@hWnd)
>>    dTitle = FXLabel.new(vPane,@title,nil,LAYOUT_FILL_ROW)
>>  end
>>
>>  def initialize(app, pane)
>>    @hWnd = pane
>>    @hApp  = app
>>  end
>> end
>> ----------- End -----------------
>>
>> I use this class from inside my program. As:
>>
>>        book = DbFace.new(app, @frame)
>>        book.title = "Add new record"
>>        book.addNew
>>
>>
>> The new dialog fields do not show up with this. Please tell me if I am
>> doing something wrong. Any example will be great.
>
> I think you're just leaving out a call to create() for the
> newly-constructed widgets. What happens if you add a call to
> vPane.create() at the end of your addNew() method?
>
>    def addNew
>      vPane = FXVerticalFrame.new(@hWnd)
>      dTitle = FXLabel.new(vPane,@title,nil,LAYOUT_FILL_ROW)
>      vPane.create
>    end
>
> Let me know if that does the trick. For more background on this, see:
>
>    http://www.fox-toolkit.org/faq.html#CREATELATER
>
> Or, even better, buy the FXRuby book and read Chapter 7. ;)
>
> Hope this helps,
>
> Lyle
> _______________________________________________
> fxruby-users mailing list
> fxruby-users@...
> http://rubyforge.org/mailman/listinfo/fxruby-users
>



--
--
Regards

Soumyanath Chatterjee
http://www.soumya.name
Let's map the world, use http://www.wikimap.biz
_______________________________________________
fxruby-users mailing list
fxruby-users@...
http://rubyforge.org/mailman/listinfo/fxruby-users

Re: Is it possible to create a pane dynamically

by Melton, Ryan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Try using removeChild with the pane's parent.

-----Original Message-----
From: fxruby-users-bounces@... [mailto:fxruby-users-bounces@...] On Behalf Of Soumyanath Chatterjee
Sent: Tuesday, September 01, 2009 8:10 AM
To: fxruby-users@...
Subject: Re: [fxruby-users] Is it possible to create a pane dynamically

Hi!

Thanks to Lyle's pointer - .create method has solved the pane creation problem. But there are other problem - how do I get rid of the pane.
Multiple calls to this class keeps stacking the pane over the old one.

In C++, I would have destroyed the old object - what do I do in FXRuby?

vPane.hide - looks to be a work around; but I think this will keep the old objects in memory. Please suggest a good way to close the screen.



On Tue, Sep 1, 2009 at 3:42 AM, Lyle Johnson<lyle@...> wrote:

> On Fri, Aug 28, 2009 at 6:55 AM, Soumyanath<soumyanath.c@...> wrote:
>
>> I am new to FXRuby so excuse me for this stupid question.
>
> It is not a stupid question.
>
>> I need to enter many different data and trying to create a vertical
>> pane dynamically using response from a SQL query.
>>
>> I want these input form to appear in my main window. Created a class
>> based on FXMainWindow.
>>
>> --------------- Code snippet ------------ class DbFace < FXMainWindow
>>    attr_writer \
>>    :title,
>>
>>  def addNew
>>    vPane = FXVerticalFrame.new(@hWnd)
>>    dTitle = FXLabel.new(vPane,@title,nil,LAYOUT_FILL_ROW)
>>  end
>>
>>  def initialize(app, pane)
>>    @hWnd = pane
>>    @hApp  = app
>>  end
>> end
>> ----------- End -----------------
>>
>> I use this class from inside my program. As:
>>
>>        book = DbFace.new(app, @frame)
>>        book.title = "Add new record"
>>        book.addNew
>>
>>
>> The new dialog fields do not show up with this. Please tell me if I
>> am doing something wrong. Any example will be great.
>
> I think you're just leaving out a call to create() for the
> newly-constructed widgets. What happens if you add a call to
> vPane.create() at the end of your addNew() method?
>
>    def addNew
>      vPane = FXVerticalFrame.new(@hWnd)
>      dTitle = FXLabel.new(vPane,@title,nil,LAYOUT_FILL_ROW)
>      vPane.create
>    end
>
> Let me know if that does the trick. For more background on this, see:
>
>    http://www.fox-toolkit.org/faq.html#CREATELATER
>
> Or, even better, buy the FXRuby book and read Chapter 7. ;)
>
> Hope this helps,
>
> Lyle
> _______________________________________________
> fxruby-users mailing list
> fxruby-users@...
> http://rubyforge.org/mailman/listinfo/fxruby-users
>



--
--
Regards

Soumyanath Chatterjee
http://www.soumya.name
Let's map the world, use http://www.wikimap.biz _______________________________________________
fxruby-users mailing list
fxruby-users@...
http://rubyforge.org/mailman/listinfo/fxruby-users



This message and any enclosures are intended only for the addressee.  Please  
notify the sender by email if you are not the intended recipient.  If you are  
not the intended recipient, you may not use, copy, disclose, or distribute this  
message or its contents or enclosures to any other person and any such actions  
may be unlawful.  Ball reserves the right to monitor and review all messages  
and enclosures sent to or from this email address.
_______________________________________________
fxruby-users mailing list
fxruby-users@...
http://rubyforge.org/mailman/listinfo/fxruby-users