on run argv

	set my_path to (system attribute "PWD") & "/"
	set my_test to item 1 of argv

	tell application "Virtual ]["
		activate
		delay 0.5
		-- Close all open machines
		close every machine saving no
		-- Create a standard Apple //els 
		set theMachine to (make new AppleIIe)
		tell theMachine
			-- Change to a color screen
			-- set monochrome screen to false
			set speaker volume to 0.25
			insert my_path & my_test into device "S6D1"
			-- Now wait for the startup screen
			delay 0.5
			reset
	
			repeat until the last line of the compact screen text = "]"
				delay 0.5
			end repeat

			type line "LOAD"
			play my_path & "test.aif" on device "cassette recorder"
			set speed to maximum

			try
				with timeout of 30 seconds
					-- repeat until the last line of the compact screen text = "DONE. PRESS [RETURN] TO REBOOT."
					-- 	delay 0.5
				 	-- end repeat
					waiting until screen equals imagefile POSIX path of (my_path & "done.tiff")
				end timeout
			on error
				return "\nIMAGE WRITE TIMEOUT!!!  Check Virtual ][ screen.  Test aborted.\n\n"
			end try

			-- short test of image, not necessary, next 3 lines can be removed
			-- delay 0.5
			-- type line ""
			-- delay 3

		end tell
		close every machine saving no
		quit
	end tell
end run
