NSReceiverEvaluationScriptError: 4 (1)

NSReceiverEvaluationScriptError: 4 (1)

That’s the message I get whenever I press the Start Server button in my program.
Here’s the applescript:

-- AA ReServer.applescript
-- AA ReServer

--  Created by Daniel Kotowski on 10/20/05.
--  Copyright 2005 Daniel Kotowski. All rights reserved.

on clicked theObject
    tell window "Main"
        set theType to title of popup button "servertype"
        set theMap to contents of text field "mapname"
        tell application "Terminal"
            activate
            do script with command "cd //Applications/Army\\ Operations\\ 2.3.0.app/System; ./server-bin "
        end tell
        quit
    end tell
end clicked

on should quit after last window closed theObject
    return true
end should quit after last window closed

This is only the AppleScript part of an AppleScript Studio application.
This is the coding for files in English.lproj/MainMenu.nib:

classes.nib:{ IBClasses = ({CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }); IBVersion = 1; }
info.nib:[code]<?xml version="1.0" encoding="UTF-8"?>

IBDocumentLocation 483 379 356 240 0 0 1280 832 IBEditorPositions 29 90 666 338 44 0 0 1280 832 IBFramework Version 439.0 IBLockedObjects 200 202 204 199 209 IBOldestOS 2 IBOpenObjects 21 IBSystem Version 8C46 [/code] data.dependency:[code]<?xml version="1.0" encoding="UTF-8"?> IBPaletteDependency ASKPalette [/code] I would also include "keyedobjects.nib" but it's in binary format, so it would just take up lots of space. Hopefully you won't need that too badly...

I have no idea what’s going on…

Model: PowerBook G4 15" 1.33GHz 512MB RAM
AppleScript: 1.10
Browser: Safari 412.5
Operating System: Mac OS X (10.4)

Greetings, and welcome to macscripter.

Please note that this thread should be posted in the AppleScript Studio & Xcode forum.

The error you’re getting is caused by an incorrectly referenced or named object. At first glance, it may be caused by the nested tell blocks. Try something like this instead…

on clicked theObject
	if name of theObject is "startserver" then
		tell window "Main"
			set theType to title of popup button "servertype"
			set theMap to contents of text field "mapname"
		end tell
		tell application "Terminal"
			activate
			do script with command "cd //Applications/Army\\ Operations\\ 2.3.0.app/System; ./server-bin "
		end tell
		quit
	end if
end clicked

Logically, the window “Main” doesn’t have an application named “Terminal”. :stuck_out_tongue:

If that doesn’t help, make sure to double-check the names you have set in IB, making certain that they are exactly the same as those in your code. Also, make sure you are talking about the applescript name of each object (set in the ‘applescript’ pane in IB) and not the items’ title.

If you are certain that you’re referencing items correctly, then try commenting out lines of code, and then uncommenting them one-by-one to see which line is the culprit. or example…

on clicked theObject
	if name of theObject is "startserver" then
		tell window "Main"
			--set theType to title of popup button "servertype"
			--set theMap to contents of text field "mapname"
		end tell
		(*
		tell application "Terminal"
			activate
			do script with command "cd //Applications/Army\\ Operations\\ 2.3.0.app/System; ./server-bin "
		end tell
		*)
		quit
	end if
end clicked

Remove the “–” and “()” comments one set at time to see which line is referencing an item incorrectly. Also, make sure that you change the “startserver” to the actual applescriptname of the button being pressed. Doing it this way will allow you to use your ‘clicked’ handler later for more than just this one button.

Good luck,
j