How To: Pause Avenue code while system.execute() is running


The information in this article applies to ArcView GIS versions 3.x only. The instructions described apply to the Avenue programming language, which is specific to the ArcView GIS application.

Information provided are the instructions to pause an Avenue application while system.execute() runs another process.


  1. Start a text editor, such as Notepad or WordPad.
  2. Copy the following code into the text editor:
REM Example.bat
echo ------------------------------------------------- 
echo This portion of the program must: 
echo 1. Run an application or commands of your choice.
echo 2. Create the flag file when finished No. 1.
echo ------------------------------------------------- 
REM Incser application or commands to run here:
The application or commands will run while the calling Avenue application is paused.
  1. Save the file as c:\temp\example.bat and exit the text editor.
  2. Open a new script window in ArcView.
    1. Activate the Project window.
    2. Click the Scripts icon.
    3. Click New.
  3. Copy this code into the new window:
'-- Test_Flag
'-- Wait for an external process launched with
'-- System.Execute() to complete before continuing. 
'-- Calls: Example.bat 

'-- Check for the existence of the flag file.
'-- When found, remove the script that av.DelayedRun() is using.
_count = 0
theFlagFile = "c:\temp\finished.txt".AsFileName 
msgbox.info("Starting the test-for-flag-file" ++ _count.asstring,"") 
if (File.Exists(theFlagFile)) then 
 msgbox.info("Flag file found. Moving on...","") 
' av.run("MyScript_Part2","") 
 _count = _count + 1 
 msgbox.info("File not found. Starting loop again" ++ _count.asstring,"") 
  1.  Name the script Test_Flag.
    1. Select Properties from the Script menu.
    2. Type in a new name in the Name field.
    3. Click OK.
  2. Select Compile from the Script menu.
  3. Open a second script window.
  4. Copy this code into the second script window:
'-- MyScript_Part1
'-- This section should go at the top of your script.
'-- Check for the existence of the flag file and delete if needed. 
theFlagFile = "c:\temp\finished.txt".AsFileName 
msgbox.Info(File.Exists(theFlagFile).AsString,"Is the Flag File There?") 
if (File.Exists(theFlagFile)) then 

'-- Start your code here
For each i in 0..5
  myAnswer = MsgBox.YesNo( "Continue?", "ArcView", TRUE )
  If (myanswer = false) then
  '-- Create the flag file and run process

'-- Issue the Delayed.Run() request to loop and wait for the
'-- flag file to appear. If it appears, then finish,
'-- else, run av.delayed again from within the called script.
  1. Name this script MyScript_Part1.
The Avenue application must be divided into two scripts. There is no method to pause a single avenue script and continue later in the middle of the script. 
  1. Select Compile from the Script menu.
  2. Open a third script window.
  3. Copy this code into the new window.
'-- MyScript_Part2
MsgBox.info("Process Finished","")
'-- Continue code here. 
  1.  Name this script MyScript_Part2.
  2. Open MyScript_Part1 and select Run from the Script menu.

MyScript_Part1 deletes a flag file that may have been left by a previous run. Then, the application code runs. When you reach the point where you need to pause the application, that is when you answer No to the Continue prompt, the Flag_Test script is executed and the Example.bat file is run. The Flag_Test loops every 5 seconds testing for the flag file. Once it detects the flag file, the script executes the remainder of the application by running MyScript_Part2.