This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's Calculator Programming subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. General Coding and Design => Calculator Programming
Author Message

Active Member

Joined: 25 Jul 2006
Posts: 700

Posted: 02 Apr 2009 10:35:48 pm    Post subject:

I've written a batch file to run a program written in Python, but I've run into a problem (this particular program is a Brainfuck interpreter but the problem persists on any program that uses the command line window). I have Python 2.5 and Windows XP (BF=batch file, PP=Python program):

:1) Whenever execution of PP is broken with Ctrl-C or Ctrl-Break it gives the prompt "Terminate batch job (Y/N)?". Is there some way to prevent this message from appearing? I'm pretty sure the problem has something to do with Windows' CMD than with Python. Here's what I've tried so far:
- Execute PP as the last line of BF. (Didn't work as expected, but was worth a try)
- Handling the break inside PP with a Try/Catch block. (The prompt only appeared after all program cleanup was done)
- Explicitly calling an exit function instead of execute to EOF (sys.exit(), os._exit(), and raise SystemExit). Also tried adding the optional "Exit code" argument as zero and one. (I still believe a non-zero value of ERRORLEVEL is responsible for the prompt, since I doubt this is what (if anything) is returned as ERRORLEVEL)
- Using START to run PP. This did fix the problem with the prompt, but this is the root of my next problem.

2) The START command executes PP in a new command line window, which I'm not too fond of. One of its additional options is "/B" (Start application without creating a new window). However, when I use that the command line keeps running and so any input that's meant for PP is directed to the console. Then I tried the option "/wait" (Start application and wait for it to terminate). The command line waits just like it's supposed to, PP works fine, but problem (1) is back again, with that prompt (GOTO 1) Cool

I realize that this is a relatively stupid thing to care about, and the easiest fix is to either avoid the break commands or not even use a batch file. The problem, however, is that after repeated failed attempts, this is really starting to piss me off :roll:

Here's a list of valid command-line commands for Windows XP.

Last edited by Guest on 02 Apr 2009 10:36:55 pm; edited 1 time in total
Back to top

Active Member

Joined: 23 Feb 2006
Posts: 564

Posted: 03 Apr 2009 06:47:49 am    Post subject:

The obvious solution is, as you said, to not use a batch file (or, given that we're using Windows, not DOS, even a command file). Wink That said, I'm not sure what the problem is - why do you need a batch file at all? Is Python not set up correctly? (Not allowing you to double-click on a file or type its name on the command-line to execute it?)

If you need to use some sort of scripting that everyone on Windows will be able to use, consider using a JScript (.js) or VBScript (.vbs) file. These run when double-clicked, and have the advantage of being "real" programming languages.
Back to top

Active Member

Joined: 25 Jul 2006
Posts: 700

Posted: 03 Apr 2009 04:12:22 pm    Post subject:

benryves wrote:
That said, I'm not sure what the problem is - why do you need a batch file at all?

For the hell of it.
Back to top

Super Elite (Last Title)

Joined: 11 Apr 2005
Posts: 3500

Posted: 03 Apr 2009 08:33:43 pm    Post subject:

you can trap signals, iirc with the signals package. just remember that *nix and Windows have slightly differently named signals, so if you want multiplatformitude, you'll have to adjust your code to check for OS name.
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours