Command Line


Use keywords to find the content you
are looking for with in the site.

Procedure Calls

Batch procedures allow a structured block of statements to be called from with in a Batch Program. Procedure declarations begin with a PROC statement and end with an ENDPROC statement, as follows :-

    PROC name

    REM Procedure body


Procedure declarations must begin on a new line and can not be declared with in the scope of command grouping using brackets or braces, however, command grouping may be used with in the procedure body. Procedures can not be declared with in another procedure declaration. Conceptually procedure declarations can be thought of as an embedded batch program with in a batch program. A procedure may be passed parameters, similarly to a standard batch program and like a standard batch program the replaceable parameters %0 to %9, %#, %* and %~ become local to the procedure declaration.

Procedures are called using the CALLPROC command and may be called recursively up to 16 levels deep. Consider the following example which prompts a user for a yes or no answer :-

    @ECHO off

    PROC yesno

      SET answer=


        GETSTR %1
        SUBSTR 1 1 %getstr%
        UPPER %substr%
        IF ("%upper%" != "Y" && "%upper%" != "N") GOTO again

        SET answer=%upper%


    CALLPROC yesno "Continue (Y/N) ?"
    ECHO answer is %answer%

WinOne® makes extensive use of procedures when using Dialog Box's.

Copyright © 1995-2018 Lucien Cinc, All Rights Reserved
WinOne® is an Australian registered trademark

Go to the Australian Command Line Software web site.