Skip to content

Commit

Permalink
Keep set statements only in the endlocal block
Browse files Browse the repository at this point in the history
Currently the script uses code of the following format to return
values over the endlocal barrier:

    :function_name
        setlocal
        <function body>
        (
            endlocal
            <set statements>
            goto :eof
        )

Change this to the following format so that the endlocal command
aligns with the setlocal command.

    :function_name
        setlocal
        <function body>
        endlocal & (
            <set statements>
        )
        goto :eof

The new format has the additional benefit that all the set
statements used to return values are neatly separated into a
neat code block with an additional level of indentation. The
endlocal command and the goto statement remain at the same level
of indentation as that of the function body.

Currently this change in format applies to exactly one function
in the script, i.e. :string_length. Other functions in the
script do not return values.
  • Loading branch information
susam committed Jul 14, 2013
1 parent cd36ed9 commit 2c26f50
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions timebox.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,10 @@ rem OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
set str=!str:~%%i!
)
)
(
endlocal
endlocal & (
set %~2=%len%
goto :eof
)
goto :eof

:echo_newlines
for /l %%i in (1, 1, %~1) do (
Expand Down

0 comments on commit 2c26f50

Please sign in to comment.