[wtr-general] using Trim

2011-07-05 Thread JohnH
Hello,

Can you tell me how to use correctly Trim?

I'm reading a numeric value from an excel file and I need to trim that
(in order to obtain '4' instead of '4.0').

var = worksheet2.Range(cell number)['Value']

how do I use trim correctly?

it's something likevar = trim(var) ?



thanks,

John

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


[wtr-general] Re: using Trim

2011-07-05 Thread JohnH
Thanks for clearing this out, Željko!


On Jul 5, 11:18 am, Željko Filipin zeljko.fili...@wa-research.ch
wrote:
 On Tue, Jul 5, 2011 at 10:10 AM, JohnH ictodo...@gmail.com wrote:
  I'm reading a numeric value from an excel file and I need to trim that
  (in order to obtain '4' instead of '4.0').

 Fromhttp://en.wikipedia.org/wiki/Trim_(programming)

 In programming, trim or strip is a common string manipulation
 function which removes leading and trailing whitespace from a string.

 If 4.0 is a string:

 4.0.split(.)[0]
  = 4

 If 4.0 is a float:

 4.0.to_i
  = 4

 Željko
 --
 watir.com - community manager
 watir.com/book - author
 watirpodcast.com - host

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


[wtr-general] Re: set (variable) issue

2011-06-23 Thread JohnH
Hi orde,

That was one of the first things I tried. It didn't work the first
time, but it was my mistake. It's working fine now with converting
into the string.

I've found out what's with the changing of the form's position - the
scrolbar gets activated, which is weird.

Thanks

On 22 iun., 19:52, orde ohil...@gmail.com wrote:
 Are you converting the amount var into a string before passing it to
 the .setmethod?

 orde

 On Jun 22, 7:45 am, JohnH ictodo...@gmail.com wrote:







  I'm reading an integer value from an xls. file and save it in a
 variablecalled amount.

  Afterwards, I'm trying to send thatvariablevalue into a text field
  from a website, but I'm having some problems there.

  Here is the code:
  begin
  sleep 1
  counter = counter + 1
  browser.text_field(:name, name).set(amount)
  rescue
          if counter  10
          retry
          end
  end

  If I use a direct value (like 5) instead or the amountvariableit
  all works fine, but when trying in this form the form where the text
  field starts to change its position in the page :O

  I've tried as well with .value(variable) instead of .set(variable) but
  in this case nothing happens - the value is not sent.

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


[wtr-general] Re: set (variable) issue

2011-06-23 Thread JohnH
Hi orde,

That was one of the first things I tried. It didn't work the first
time, but it was my mistake. It's working fine now with converting
into the string.

I've found out what's with the changing of the form's position - the
scrolbar gets activated, which is weird.

Thanks

On 22 iun., 19:52, orde ohil...@gmail.com wrote:
 Are you converting the amount var into a string before passing it to
 the .setmethod?

 orde

 On Jun 22, 7:45 am, JohnH ictodo...@gmail.com wrote:







  I'm reading an integer value from an xls. file and save it in a
 variablecalled amount.

  Afterwards, I'm trying to send thatvariablevalue into a text field
  from a website, but I'm having some problems there.

  Here is the code:
  begin
  sleep 1
  counter = counter + 1
  browser.text_field(:name, name).set(amount)
  rescue
          if counter  10
          retry
          end
  end

  If I use a direct value (like 5) instead or the amountvariableit
  all works fine, but when trying in this form the form where the text
  field starts to change its position in the page :O

  I've tried as well with .value(variable) instead of .set(variable) but
  in this case nothing happens - the value is not sent.

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


[wtr-general] set (variable) issue

2011-06-22 Thread JohnH
I'm reading an integer value from an xls. file and save it in a
variable called amount.

Afterwards, I'm trying to send that variable value into a text field
from a website, but I'm having some problems there.

Here is the code:
begin
sleep 1
counter = counter + 1
browser.text_field(:name, name).set(amount)
rescue
if counter  10
retry
end
end

If I use a direct value (like 5) instead or the amount variable it
all works fine, but when trying in this form the form where the text
field starts to change its position in the page :O

I've tried as well with .value(variable) instead of .set(variable) but
in this case nothing happens - the value is not sent.

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com