[Gambas-user] Unexecuted Orphan Code or Something?

Fabien Bodard gambas.fr at ...626...
Tue Nov 5 17:00:56 CET 2013


this

Return "Today" &
             Format(Date(Year(Now), Month(Now), iTp1), "dddd") &
            ", the " &
              Format(Date(Year(Now), Month(Now), iTp1), "d") &
              fuFormatSuffix(iTp1)
              ' "Of" &
             Format(Date(Year(Now), Month(Now), iTp1), "mmmm, yyyy")


can be rewritted this way to understanbd what happen :

1:/   Return Format(Date(Year(Now), Month(Now), iTp1), "dddd") & ", the " &
Format(Date(Year(Now), Month(Now), iTp1), "d") & fuFormatSuffix(iTp1)

2:/   Format(Date(Year(Now), Month(Now), iTp1), "mmmm, yyyy")


The line 2 is not executed because the programme leave on line 1

I think this code is more easy to read :

Dim hDate as Date

hDate = Date(Year(Now), Month(Now), iTp1)

Return subst("Today &1, the &1&2 &4",  Format(hDate, "dddd")
,format(hDate,"d"), fuFormatSuffix(iTp1), Format(hDate, "mmmm, yyyy"))



2013/11/5 Bruce <bbruen at ...2308...>

> On Tue, 2013-11-05 at 06:34 -0800, 2aq9j93b7s wrote:
> > thank you for the replies I appreciate them
> >
> > Unfortunately you are missing the point of the post! I have an
> uncommeneted
> > line of code that is not and cannot be executed
> >
> > bruce
> > "Now do you see why that last line is not executed."
> > My point exactly but when is it executed if at all?
> >
> To put it plainly, it will never be executed because it is after the
> quite valid Return command.
>
>
> Private $aChar as String="a"
>
> Private Sub DoNothing()
>
>   Dim bChar As String= "b"
>
>   Return
>
>   $aChar=bCar
>
> ' plus a whole bunch of further code that will
> ' never  be executed because this Sub has
> ' already Returned, like
>   Format(Now(),"yy-mm-dd")
>   Now()
> ' etc
>
>
> End
>
>
> Public Sub Main()
>
>   DoNothing
>
>   Print $aChar
>
> End
>
>
> What you appear to have fallen for is the old
> putting a comment in the middle of a multiline
> command. As soon as you do that you have terminated the
> command and the "lines of code" after that are never executed
> because you have already got a valid Return command.
>
> Secondly, don't forget that all Gambas functions can be
> used as subs. So, the things that look like dangling functions
> in the code above aren't. They are functions used as subs.
>
> Bruce
>
>
>
>
>
>
> ------------------------------------------------------------------------------
> November Webinars for C, C++, Fortran Developers
> Accelerate application performance with scalable programming models.
> Explore
> techniques for threading, error checking, porting, and tuning. Get the most
> from the latest Intel processors and coprocessors. See abstracts and
> register
> http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



-- 
Fabien Bodard



More information about the User mailing list