所以基本上我已经宣布了所有内容,但不知怎的,它们仍未能作为一种类型被解析。有任何想法吗? JAVA screenshot
int main() {
int pid, stat_loc;
printf("\nmy pid = %d\n", getpid());
pid = fork();
if (pid == -1) {
perror("error in fork");
return 0;
}
else if (pid ==0 ) {
printf("\nI am the child process, my pid = %d\n\n", getpid());
sleep(5);
exit(0);/* sending child status */
}
else {
int status = 0;
int ret = wait(&status);/* wait() returns pid of the child for which its waiting */
printf("\nThe %d is done\n\n", ret);
printf("\nI am the parent process, my pid = %d\n\n", getpid());
}
printf("\nThe %d is done\n\n", getpid());/* getpid() returns pid of the process */
return 0;
}
答案 0 :(得分:1)
在声明之后,你不能引用一个对象,除非它是一个字段。尝试将您的声明移动到您的动作监听器:
from Foundation import NSAppleScript
textOfMyScript = """
tell application "SpeechRecognitionServer"
set theResponse to listen for {"good", "bad", "weather"}
end tell
"""
myScript = NSAppleScript.initWithSource_(NSAppleScript.alloc(), textOfMyScript)
results, err = myScript.executeAndReturnError_(None)
myWord = results.stringValue()
if myWord == "good":
print ("OK")
您可能还想查看Oracle Creating Objects的教程 和Using Objects。如果您不熟悉字段的工作原理,那么您会发现另一个非常方便的教程:Declaring Member Variables