PDA

View Full Version : Unused Local Variables



Bob Worsley
11-Mar-2008, 12:41 PM
If you've ever wanted to locate and remove all of those unused local
variables in your code, vdf-guidance has just posted a small application I
wrote to do just that - show them to you so you can remove them.
Bob Worsley

Mark Rutherford
11-Mar-2008, 04:23 PM
Cool!
Thanks :)

IMHO, the compiler should do this but.... it does not.

Bob Worsley wrote:
> If you've ever wanted to locate and remove all of those unused local
> variables in your code, vdf-guidance has just posted a small application I
> wrote to do just that - show them to you so you can remove them.
> Bob Worsley
>
>
>

Marco
11-Mar-2008, 04:57 PM
Hi Mark,

In the VDF Tools plugin for Eclipse, the unused local variables are
underlined, and shown in the parser window.

There is a lot of smart stuff in there.

You should check it out. http://resheim.no/

Cheers,
Marco

Mark Rutherford wrote:
> Cool!
> Thanks :)
>
> IMHO, the compiler should do this but.... it does not.
>
> Bob Worsley wrote:
>> If you've ever wanted to locate and remove all of those unused local
>> variables in your code, vdf-guidance has just posted a small
>> application I
>> wrote to do just that - show them to you so you can remove them.
>> Bob Worsley
>>
>>
>>

Hans van de Laar
11-Mar-2008, 05:58 PM
It even finds unused local vars in its own source<g>

Thanks Bob!

Regards,

Hans

Bob Worsley wrote:

> If you've ever wanted to locate and remove all of those unused local
> variables in your code, vdf-guidance has just posted a small
> application I wrote to do just that - show them to you so you can
> remove them. Bob Worsley

DavidMartinko
11-Mar-2008, 06:36 PM
Those must have been there for testing purposes, right bob?

--
David Martinko
Custom Software Developer
Redeemed Software Company
www.RedeemedSoftware.com
248-535-7495
"Hans van de Laar" <hvdlaar@conclusion.nl> wrote in message
news:xn0fnklzpeh53a000@news.dataaccess.com...
> It even finds unused local vars in its own source<g>
>
> Thanks Bob!
>
> Regards,
>
> Hans
>
> Bob Worsley wrote:
>
>> If you've ever wanted to locate and remove all of those unused local
>> variables in your code, vdf-guidance has just posted a small
>> application I wrote to do just that - show them to you so you can
>> remove them. Bob Worsley

DavidMartinko
11-Mar-2008, 07:43 PM
Why yes I do have an idea...

The first thing I would do is this:

// Remove Comments
If (Pos("//", sLine)>0) Begin
Move (Left(sLine, (Pos("//", sLine)-1))) to sLine
End


--
David Martinko
Custom Software Developer
Redeemed Software Company
www.RedeemedSoftware.com
248-535-7495
"Bob Worsley" <rlworsley@gmail.com> wrote in message
news:MMM1Gh9gIHA.5276@dacmail.dataaccess.com...
> Smack! I actually ran it over it's own source late in the development,
> but
> obviously not late enough as I didn't see that. Actually those two
> variables are used in the code but the usage of "END_" seems to be
> confusing
> the program, the parsing stops whereever that syntax is encountered. I've
> run many programs through the process and this is a new one. I also
> noticed
> that the checking for comments doesn't work but that I'm actually not
> completely surprised at, I seem to remember something long ago about
> trying
> to deal with embedded "//" characters.
>
> The problem with comments being included might show up if variables aren't
> uniquely named and could show in the comments and not in the actual code.
> For example if I declared a variable "again" and didn't use it but did
> have
> a comment that says "// not that again". Oh well, I'll have to work on
> it.
>
> Maybe someone has some ideas?
> Bob
>
> "Hans van de Laar" <hvdlaar@conclusion.nl> wrote in message
> news:xn0fnklzpeh53a000@news.dataaccess.com...
>> It even finds unused local vars in its own source<g>
>>
>> Thanks Bob!
>>
>> Regards,
>>
>> Hans
>>
>> Bob Worsley wrote:
>>
>> > If you've ever wanted to locate and remove all of those unused local
>> > variables in your code, vdf-guidance has just posted a small
>> > application I wrote to do just that - show them to you so you can
>> > remove them. Bob Worsley
>>
>
>
>

Bob Worsley
11-Mar-2008, 08:30 PM
Smack! I actually ran it over it's own source late in the development, but
obviously not late enough as I didn't see that. Actually those two
variables are used in the code but the usage of "END_" seems to be confusing
the program, the parsing stops whereever that syntax is encountered. I've
run many programs through the process and this is a new one. I also noticed
that the checking for comments doesn't work but that I'm actually not
completely surprised at, I seem to remember something long ago about trying
to deal with embedded "//" characters.

The problem with comments being included might show up if variables aren't
uniquely named and could show in the comments and not in the actual code.
For example if I declared a variable "again" and didn't use it but did have
a comment that says "// not that again". Oh well, I'll have to work on it.

Maybe someone has some ideas?
Bob

"Hans van de Laar" <hvdlaar@conclusion.nl> wrote in message
news:xn0fnklzpeh53a000@news.dataaccess.com...
> It even finds unused local vars in its own source<g>
>
> Thanks Bob!
>
> Regards,
>
> Hans
>
> Bob Worsley wrote:
>
> > If you've ever wanted to locate and remove all of those unused local
> > variables in your code, vdf-guidance has just posted a small
> > application I wrote to do just that - show them to you so you can
> > remove them. Bob Worsley
>

Bob Worsley
11-Mar-2008, 08:50 PM
My approach was a little different.

Define gsComments for "//"

If (Left(trim(sLine), 2) <> gsComments...

This works for lines starting with comments, but not for removing trailing.
But, it could. I'll play with it a bit, thanks.
Bob

"David Martinko" <DavidM@RedeemedSoftware.com> wrote in message
news:tVI9vo9gIHA.3748@dacmail.dataaccess.com...
> Why yes I do have an idea...
>
> The first thing I would do is this:
>
> // Remove Comments
> If (Pos("//", sLine)>0) Begin
> Move (Left(sLine, (Pos("//", sLine)-1))) to sLine
> End
>
>
> --
> David Martinko
> Custom Software Developer
> Redeemed Software Company
> www.RedeemedSoftware.com
> 248-535-7495
> "Bob Worsley" <rlworsley@gmail.com> wrote in message
> news:MMM1Gh9gIHA.5276@dacmail.dataaccess.com...
> > Smack! I actually ran it over it's own source late in the development,
> > but
> > obviously not late enough as I didn't see that. Actually those two
> > variables are used in the code but the usage of "END_" seems to be
> > confusing
> > the program, the parsing stops whereever that syntax is encountered.
I've
> > run many programs through the process and this is a new one. I also
> > noticed
> > that the checking for comments doesn't work but that I'm actually not
> > completely surprised at, I seem to remember something long ago about
> > trying
> > to deal with embedded "//" characters.
> >
> > The problem with comments being included might show up if variables
aren't
> > uniquely named and could show in the comments and not in the actual
code.
> > For example if I declared a variable "again" and didn't use it but did
> > have
> > a comment that says "// not that again". Oh well, I'll have to work on
> > it.
> >
> > Maybe someone has some ideas?
> > Bob
> >
> > "Hans van de Laar" <hvdlaar@conclusion.nl> wrote in message
> > news:xn0fnklzpeh53a000@news.dataaccess.com...
> >> It even finds unused local vars in its own source<g>
> >>
> >> Thanks Bob!
> >>
> >> Regards,
> >>
> >> Hans
> >>
> >> Bob Worsley wrote:
> >>
> >> > If you've ever wanted to locate and remove all of those unused local
> >> > variables in your code, vdf-guidance has just posted a small
> >> > application I wrote to do just that - show them to you so you can
> >> > remove them. Bob Worsley
> >>
> >
> >
> >
>
>
>

Richard Hogg
6-Apr-2008, 10:05 PM
Hi Bob,

Very nice and useful utility you have written. One thing that I found
catches it out is if you have a variable that is something like end_ (e.g.
sWeekend_Adjustment) because it mistakes it for END_PROCEDURE or
END_FUNCTION.

I got around it by changing the code
from Until (uppercase(sLine) contains "END_")
to Until (uppercase(sLine) contains "END_PROCEDURE") or
(uppercase(sLine) contains "END_FUNCTION"))

Cheers
Richard


"Bob Worsley" <rlworsley@gmail.com> wrote in message
news:XE8D4a5gIHA.4596@dacmail.dataaccess.com...
> If you've ever wanted to locate and remove all of those unused local
> variables in your code, vdf-guidance has just posted a small application I
> wrote to do just that - show them to you so you can remove them.
> Bob Worsley
>
>
>

Bob Worsley
7-Apr-2008, 10:04 AM
Ok, I figured there would be things like this popping up. I'll make the
change, thanks.
Bob

"Richard Hogg" <richard@barcomp.com.au> wrote in message
news:lxIjvwFmIHA.5016@dacmail.dataaccess.com...
> Hi Bob,
>
> Very nice and useful utility you have written. One thing that I found
> catches it out is if you have a variable that is something like end_ (e.g.
> sWeekend_Adjustment) because it mistakes it for END_PROCEDURE or
> END_FUNCTION.
>
> I got around it by changing the code
> from Until (uppercase(sLine) contains "END_")
> to Until (uppercase(sLine) contains "END_PROCEDURE") or
> (uppercase(sLine) contains "END_FUNCTION"))
>
> Cheers
> Richard
>
>
> "Bob Worsley" <rlworsley@gmail.com> wrote in message
> news:XE8D4a5gIHA.4596@dacmail.dataaccess.com...
> > If you've ever wanted to locate and remove all of those unused local
> > variables in your code, vdf-guidance has just posted a small application
I
> > wrote to do just that - show them to you so you can remove them.
> > Bob Worsley
> >
> >
> >
>
>

Dave Robinson
7-Apr-2008, 11:56 AM
Haven't investigated, but end_object and end_class too?

>>> Bob Worsley<rlworsley@gmail.com> 4/7/2008 10:04:14 AM >>>
Ok, I figured there would be things like this popping up. I'll make the
change, thanks.
Bob

"Richard Hogg" <richard@barcomp.com.au> wrote in message
news:lxIjvwFmIHA.5016@dacmail.dataaccess.com...
> Hi Bob,
>
> Very nice and useful utility you have written. One thing that I found
> catches it out is if you have a variable that is something like end_ (e.g.
> sWeekend_Adjustment) because it mistakes it for END_PROCEDURE or
> END_FUNCTION.
>
> I got around it by changing the code
> from Until (uppercase(sLine) contains "END_")
> to Until (uppercase(sLine) contains "END_PROCEDURE") or
> (uppercase(sLine) contains "END_FUNCTION"))
>
> Cheers
> Richard
>
>
> "Bob Worsley" <rlworsley@gmail.com> wrote in message
> news:XE8D4a5gIHA.4596@dacmail.dataaccess.com...
> > If you've ever wanted to locate and remove all of those unused local
> > variables in your code, vdf-guidance has just posted a small application
I
> > wrote to do just that - show them to you so you can remove them.
> > Bob Worsley
> >
> >
> >
>
>

Bob Worsley
7-Apr-2008, 07:21 PM
You shouldn't run into that. The way it's constructed it will ignore those
particular "end" items and only deal with what's inside the methods.
Bob

"Dave Robinson" <dr at kirkfreeport.net> wrote in message
news:3NlbDBNmIHA.1988@dacmail.dataaccess.com...
> Haven't investigated, but end_object and end_class too?
>
> >>> Bob Worsley<rlworsley@gmail.com> 4/7/2008 10:04:14 AM >>>
> Ok, I figured there would be things like this popping up. I'll make the
> change, thanks.
> Bob
>
> "Richard Hogg" <richard@barcomp.com.au> wrote in message
> news:lxIjvwFmIHA.5016@dacmail.dataaccess.com...
> > Hi Bob,
> >
> > Very nice and useful utility you have written. One thing that I found
> > catches it out is if you have a variable that is something like end_
(e.g.
> > sWeekend_Adjustment) because it mistakes it for END_PROCEDURE or
> > END_FUNCTION.
> >
> > I got around it by changing the code
> > from Until (uppercase(sLine) contains "END_")
> > to Until (uppercase(sLine) contains "END_PROCEDURE") or
> > (uppercase(sLine) contains "END_FUNCTION"))
> >
> > Cheers
> > Richard
> >
> >
> > "Bob Worsley" <rlworsley@gmail.com> wrote in message
> > news:XE8D4a5gIHA.4596@dacmail.dataaccess.com...
> > > If you've ever wanted to locate and remove all of those unused local
> > > variables in your code, vdf-guidance has just posted a small
application
> I
> > > wrote to do just that - show them to you so you can remove them.
> > > Bob Worsley
> > >
> > >
> > >
> >
> >
>
>
>
>
>
>

Ditte
11-Jun-2008, 10:48 AM
Hi,

very nice tool. Much to do for me.
A little problem ich you check more than 9 source files.
The channel will be increment but never setting back.

Regards

Dittmar

"Richard Hogg" <richard@barcomp.com.au> schrieb im Newsbeitrag
news:lxIjvwFmIHA.5016@dacmail.dataaccess.com...
> Hi Bob,
>
> Very nice and useful utility you have written. One thing that I found
> catches it out is if you have a variable that is something like end_ (e.g.
> sWeekend_Adjustment) because it mistakes it for END_PROCEDURE or
> END_FUNCTION.
>
> I got around it by changing the code
> from Until (uppercase(sLine) contains "END_")
> to Until (uppercase(sLine) contains "END_PROCEDURE") or
> (uppercase(sLine) contains "END_FUNCTION"))
>
> Cheers
> Richard
>
>
> "Bob Worsley" <rlworsley@gmail.com> wrote in message
> news:XE8D4a5gIHA.4596@dacmail.dataaccess.com...
>> If you've ever wanted to locate and remove all of those unused local
>> variables in your code, vdf-guidance has just posted a small application
>> I
>> wrote to do just that - show them to you so you can remove them.
>> Bob Worsley
>>
>>
>>
>

Bob Worsley
22-Jun-2008, 04:14 PM
I just fixed that buglet, not sure how I missed that one, but it was there.
Thanks Dittmar...
Bob

"Dittmar Stiebitz" <pankow@kus-bau.de> wrote in message
news:9Jl%23Pu9yIHA.4964@dacmail.dataaccess.com...
> Hi,
>
> very nice tool. Much to do for me.
> A little problem ich you check more than 9 source files.
> The channel will be increment but never setting back.
>
> Regards
>
> Dittmar
>
> "Richard Hogg" <richard@barcomp.com.au> schrieb im Newsbeitrag
> news:lxIjvwFmIHA.5016@dacmail.dataaccess.com...
> > Hi Bob,
> >
> > Very nice and useful utility you have written. One thing that I found
> > catches it out is if you have a variable that is something like end_
(e.g.
> > sWeekend_Adjustment) because it mistakes it for END_PROCEDURE or
> > END_FUNCTION.
> >
> > I got around it by changing the code
> > from Until (uppercase(sLine) contains "END_")
> > to Until (uppercase(sLine) contains "END_PROCEDURE") or
> > (uppercase(sLine) contains "END_FUNCTION"))
> >
> > Cheers
> > Richard
> >
> >
> > "Bob Worsley" <rlworsley@gmail.com> wrote in message
> > news:XE8D4a5gIHA.4596@dacmail.dataaccess.com...
> >> If you've ever wanted to locate and remove all of those unused local
> >> variables in your code, vdf-guidance has just posted a small
application
> >> I
> >> wrote to do just that - show them to you so you can remove them.
> >> Bob Worsley
> >>
> >>
> >>
> >
>
>
>

Ditte
18-Jul-2008, 03:38 AM
Hi Bob,

where can I find the updated file?

Regards Dittmar

"Bob Worsley" <rlworsley@gmail.com> schrieb im Newsbeitrag
news:im9TnzK1IHA.5016@dacmail.dataaccess.com...
>I just fixed that buglet, not sure how I missed that one, but it was there.
> Thanks Dittmar...
> Bob
>
> "Dittmar Stiebitz" <pankow@kus-bau.de> wrote in message
> news:9Jl%23Pu9yIHA.4964@dacmail.dataaccess.com...
>> Hi,
>>
>> very nice tool. Much to do for me.
>> A little problem ich you check more than 9 source files.
>> The channel will be increment but never setting back.
>>
>> Regards
>>
>> Dittmar
>>
>> "Richard Hogg" <richard@barcomp.com.au> schrieb im Newsbeitrag
>> news:lxIjvwFmIHA.5016@dacmail.dataaccess.com...
>> > Hi Bob,
>> >
>> > Very nice and useful utility you have written. One thing that I found
>> > catches it out is if you have a variable that is something like end_
> (e.g.
>> > sWeekend_Adjustment) because it mistakes it for END_PROCEDURE or
>> > END_FUNCTION.
>> >
>> > I got around it by changing the code
>> > from Until (uppercase(sLine) contains "END_")
>> > to Until (uppercase(sLine) contains "END_PROCEDURE") or
>> > (uppercase(sLine) contains "END_FUNCTION"))
>> >
>> > Cheers
>> > Richard
>> >
>> >
>> > "Bob Worsley" <rlworsley@gmail.com> wrote in message
>> > news:XE8D4a5gIHA.4596@dacmail.dataaccess.com...
>> >> If you've ever wanted to locate and remove all of those unused local
>> >> variables in your code, vdf-guidance has just posted a small
> application
>> >> I
>> >> wrote to do just that - show them to you so you can remove them.
>> >> Bob Worsley
>> >>
>> >>
>> >>
>> >
>>
>>
>>
>
>
>

Bob Worsley
3-Sep-2008, 09:25 AM
Dittmar, I just saw this posting from back in July, I assume you found the
update on vdf-guidance? I had updated the file there.
Bob

"Dittmar Stiebitz" <pankow@kus-bau.de> wrote in message
news:uVAk7GL6IHA.5016@dacmail.dataaccess.com...
> Hi Bob,
>
> where can I find the updated file?
>
> Regards Dittmar
>
> "Bob Worsley" <rlworsley@gmail.com> schrieb im Newsbeitrag
> news:im9TnzK1IHA.5016@dacmail.dataaccess.com...
> >I just fixed that buglet, not sure how I missed that one, but it was
there.
> > Thanks Dittmar...
> > Bob
> >
> > "Dittmar Stiebitz" <pankow@kus-bau.de> wrote in message
> > news:9Jl%23Pu9yIHA.4964@dacmail.dataaccess.com...
> >> Hi,
> >>
> >> very nice tool. Much to do for me.
> >> A little problem ich you check more than 9 source files.
> >> The channel will be increment but never setting back.
> >>
> >> Regards
> >>
> >> Dittmar
> >>
> >> "Richard Hogg" <richard@barcomp.com.au> schrieb im Newsbeitrag
> >> news:lxIjvwFmIHA.5016@dacmail.dataaccess.com...
> >> > Hi Bob,
> >> >
> >> > Very nice and useful utility you have written. One thing that I
found
> >> > catches it out is if you have a variable that is something like end_
> > (e.g.
> >> > sWeekend_Adjustment) because it mistakes it for END_PROCEDURE or
> >> > END_FUNCTION.
> >> >
> >> > I got around it by changing the code
> >> > from Until (uppercase(sLine) contains "END_")
> >> > to Until (uppercase(sLine) contains "END_PROCEDURE") or
> >> > (uppercase(sLine) contains "END_FUNCTION"))
> >> >
> >> > Cheers
> >> > Richard
> >> >
> >> >
> >> > "Bob Worsley" <rlworsley@gmail.com> wrote in message
> >> > news:XE8D4a5gIHA.4596@dacmail.dataaccess.com...
> >> >> If you've ever wanted to locate and remove all of those unused local
> >> >> variables in your code, vdf-guidance has just posted a small
> > application
> >> >> I
> >> >> wrote to do just that - show them to you so you can remove them.
> >> >> Bob Worsley
> >> >>
> >> >>
> >> >>
> >> >
> >>
> >>
> >>
> >
> >
> >
>
>
>