Disappearing functions

Jul 1, 2008
81
0
74
Montreal
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

setlocal
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
enddo

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.
--
Peter
 

rconn

Administrator
Staff member
May 14, 2008
12,345
150
Peter Bratton wrote:


> 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
>
> setlocal
> 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.

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


> 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.

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

Rex Conn
JP Software
 
Similar threads
Thread starter Title Forum Replies Date
T aliases disappearing Support 22
J Files Disappearing During Batch Execution Support 4
A Problem with functions @int @decimal and identifying Powershell as a shell. Support 12
Joe Caverly "Functions" in cmd.exe batch files Support 6
vefatica Library functions and line continuations? Support 4
Charles Dye Documentation Help Nits Forever: Checksum functions Support 0
Joe Caverly SETLOCAL removes Aliases and Functions Support 3
Joe Caverly @NAME supports library functions Support 2
Charles Dye Functions which no-one has ever tried to use.... Support 5
vefatica WHICH and @functions Support 2
vefatica Two @FUNCTIONs/aliases with the same name Support 4
M Keywords for commands, functions, internal variables Support 3
C Documentation near or fully obsolete functions Support 7
Charles Dye Optional F parm in checksum functions Support 0
C coding functions and subroutines Support 9
rps Functions @year[date] @isowyear[date] help Support 7
mikea How to? TCC and XMLnodes/XMLxpath functions Support 0
Dan Glynhampton Are these two functions the same? Support 2
M How to? Logic in functions... Support 5
A WAD function return values with parentheses prevent evaluation of additional functions Support 31
M "History" command not giving me what I want when executed by @Exec... functions... Support 6
Charles Dye Web help on functions Support 2
samintz Help examples for the @ISxxx functions Support 3
R specific functions for number conversion Support 2
C Unsuppressable errors from XML functions Support 5
nikbackm Checksum functions Support 4
J TCC Out of memory with aliases and functions Support 5
A I dont see anything in the alias/functions/batchvariables tabs in IDE Support 13
dcantor Comments and suggestions on functions for binary buffers Support 4

Similar threads