1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Disappearing functions

Discussion in 'Support' started by Peter Bratton, Apr 24, 2009.

  1. Peter Bratton

    Jul 1, 2008
    Likes Received:
    Windows XP SP 3, TCC 10.00 build 67, registered to Peter Bratton

    When I ran this batch file today for the first time in a loong time, I was surprised to discover a new "feature": disappearing functions. If it's not just me, you'll see it right away by stepping through this snippet in the debugger while watching the functions window

    function divnum=`%@instr[%@index[125,%@left[1,%1]],1,xno]`
    function divname=`%@instr[%@eval[6 * %@index[xno,%1]],6,FX Natur Outlet]`
    type %listdir\adresses.lst | tr -d ! > %tmp\adresses.lst

    As the functions are declared, they are displayed in the watch window, but they both vanish the moment the pipe is executed.

    Removing the setlocal command does not change the behaviour.
    Moving the setlocal command below the function declarations does not change the behaviour.
    A third function, not shown here but declared in 4start.btm, is not affected.

    If I change the last line to

    do txt in @%listdir\adresses.lst
    echo %@strip[!,%txt] >> %tmp\adresses.lst

    the functions remain, which suggests that something is amiss in the transfer of information between shells.

    To get around the glitch I put the function declarations after the pipe.

    A final observation, setlocal/endlocal fails to clear the functions. I have to "unfunction divnum divname" before quitting the batch file, otherwise the functions live on into the primary shell.
  2. rconn

    rconn Administrator
    Staff Member

    May 14, 2008
    Likes Received:
    Peter Bratton wrote:

    Not reproducible here. Do you have a TCSTART (which will be invoked by
    the child pipe process)?

    WAD - SETLOCAL does not affect functions (see the help).

    Rex Conn
    JP Software

Share This Page