GeneralTeXnicCenter DDE stops working after 127 uses

General information and discussion about TeXnicCenter
Post Reply
pelli
Posts: 1
Joined: Fri May 04, 2012 4:17 pm

TeXnicCenter DDE stops working after 127 uses

Post by pelli »

Hi everyone,

I've been having this problem for the last few years, that after using TXC normally for a long while, suddenly I get the infamous "Cannot execute the command." error message when attempting to ForwardSearch. I then have to restart TXC to get it to work again.

I've searched the forums for this but I haven't found a post where the DDE command works at the start of a session but then suddenly stops working mid-session without anything else having changed. I guess it's not a big deal, but I'd be interested in hearing whether this has been observed before, whether you can reproduce it, and whether there is a fix.

Here's a minimalistic way to reproduce the problem on my system (TeXnicCenter 1.0 RC 1, MiKTeX 2.9, pdfTeX 3.1415926-1.40.11, SumatraPDF 2.0.1):
1. Make a minimal document, e.g.

Code: Select all

\documentclass{article}\begin{document}a\end{document}
2. Compile it once, so that there is a pdf file to view.
3. Repeat: {Press F5 in TXC to view output with SumatraPDF. Switch back to TXC.} 127 times
4. Press F5 for the 128th time. "[Open("%sbm.pdf",0,1,1)] Cannot execute the command."

This works with a variety of settings, e.g.
Path of executable: C:\Program Files\SumatraPDF\SumatraPDF.exe
View project's output: [Open("%sbm.pdf",0,1,1)]//SUMATRA//control
No Forward search
(For completeness, basic compilation options "C:\Program Files\MiKTeX 2.9\miktex\bin\pdflatex.exe", "-interaction=nonstopmode "%pm"", no bibtex/makeindex)

After the error occurs, that instance of TXC can no longer execute any DDE commands, even if I close all TXC tabs and open a new file, recompile, close SumatraPDF, or change to another output profile. (I haven't tried changing to a profile with a different viewer, because Adobe Reader crashes on me.) The only "solution" I've found is to close that instance of TXC and open a new one / use another that's already open.

Here's an Autohotkey script I wrote to test the behaviour automatically:

Code: Select all

; Repeatedly presses F5 in TeXnicCenter until SumatraPDF no longer pops up within a second. 
; Displays the number of successful F5's in a MsgBox. 
; Preparation: Make a test file called test.tex and compile it to test.pdf . Run the script and switch to the TXC window. 
; Make sure not to have any other windows open with title beginning with "TeXnicCenter" or "test.pdf"
n := 0
WinWaitActive, TeXnicCenter
Sleep, 1000
Loop 1000 ; Make max 1000 attempts
{
	WinActivate, TeXnicCenter
	Send, {F5}
	WinWaitActive, test.pdf, ,1 ; Wait for max 1 second
	If ErrorLevel
		Break
	n := n + 1
}
MsgBox, %n%
Exit

#space::  ; Emergency pause -- Win+space
Pause
Return

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Post Reply