[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Function to flush the variable

Amit Agarwal

1/2/2009 11:38:00 AM

Hi,
Is there any function to flush the value from a variable. I am facing
problem while assiging a value to Ruby variable.
--
Posted via http://www.ruby-....

5 Answers

Andrew Timberlake

1/2/2009 11:43:00 AM

0

[Note: parts of this message were removed to make it a legal post.]

On Fri, Jan 2, 2009 at 1:37 PM, Amit Agarwal <amitjhs2000@gmail.com> wrote:

> Hi,
> Is there any function to flush the value from a variable. I am facing
> problem while assiging a value to Ruby variable.
> --
> Posted via http://www.ruby-....
>
>
What do you mean by flush? Remove the current value?
my_var = nil
should do that

--
Andrew Timberlake
http://rumblingso...

Amit Agarwal

1/2/2009 11:50:00 AM

0

I am trying to use following code

Status=sheet1.getCellByPosition(5, I).Formula
ie.text_field(:name, "FieldName").value =Status


and it works fine, but On itetrating this piece of code for multiple I/
Ps, variable 'name', retains its old value for some of the cases. I
identified this as a cache problem. Please suggest if there any flush
() type function or action in Ruby/watir to clear the garbage value.

actually there is function in C, i.e. flush which clears the garbage
value.


Andrew Timberlake wrote:
> On Fri, Jan 2, 2009 at 1:37 PM, Amit Agarwal <amitjhs2000@gmail.com>
> wrote:
>
>> Hi,
>> Is there any function to flush the value from a variable. I am facing
>> problem while assiging a value to Ruby variable.
>> --
>> Posted via http://www.ruby-....
>>
>>
> What do you mean by flush? Remove the current value?
> my_var = nil
> should do that

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

Andrew Timberlake

1/2/2009 12:03:00 PM

0

[Note: parts of this message were removed to make it a legal post.]

On Fri, Jan 2, 2009 at 1:49 PM, Amit Agarwal <amitjhs2000@gmail.com> wrote:

> I am trying to use following code
>
> Status=sheet1.getCellByPosition(5, I).Formula
> ie.text_field(:name, "FieldName").value =Status
>
>
> and it works fine, but On itetrating this piece of code for multiple I/
> Ps, variable 'name', retains its old value for some of the cases. I
> identified this as a cache problem. Please suggest if there any flush
> () type function or action in Ruby/watir to clear the garbage value.
>
> actually there is function in C, i.e. flush which clears the garbage
> value.
>
>
> Andrew Timberlake wrote:
> > On Fri, Jan 2, 2009 at 1:37 PM, Amit Agarwal <amitjhs2000@gmail.com>
> > wrote:
> >
> >> Hi,
> >> Is there any function to flush the value from a variable. I am facing
> >> problem while assiging a value to Ruby variable.
> >> --
> >> Posted via http://www.ruby-....
> >>
> >>
> > What do you mean by flush? Remove the current value?
> > my_var = nil
> > should do that
>
> --
> Posted via http://www.ruby-....
>
>
A 'variable' with an uppercase first letter is actually a constant in ruby
and you can only assign to it once.
Change 'Status' to 'status' and you should see it work

--
Andrew Timberlake
http://ramblingso...
http://www.linkedin.com/in/andrew...

"I have never let my schooling interfere with my education" - Mark Twain

Sebastian Hungerecker

1/2/2009 12:10:00 PM

0

Amit Agarwal wrote:
> actually there is function in C, i.e. flush which clears the garbage
> value.

In ruby there is a method IO#flush which flushes an output stream the same way
flush in C does. This has nothing to do with variables, however.

HTH,
Sebastian
--
Jabber: sepp2k@jabber.org
ICQ: 205544826

Michael Libby

1/2/2009 2:07:00 PM

0

>> Andrew Timberlake wrote:

> A 'variable' with an uppercase first letter is actually a constant in ruby
> and you can only assign to it once.
> Change 'Status' to 'status' and you should see it work

In Ruby you can assign to a constant as many times as you like. You
will be scolded for it, but it's allowed.

irb(main):001:0> IMA_CONST = "foo"
=> "foo"
irb(main):002:0> IMA_CONST = "bar"
(irb):2: warning: already initialized constant IMA_CONST
=> "bar"
irb(main):003:0> IMA_CONST = "baz"
(irb):3: warning: already initialized constant IMA_CONST
=> "baz"
irb(main):004:0> IMA_CONST
=> "baz"

-Michael


--
Michael C. Libby
www.mikelibby.com