Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I am reading this right.</p> <p>you get a message "Are you ok"</p> <p>The script response is "I am fine sir, are you ok?"</p> <p>you get a message back "yes" or "no"</p> <p>But the part of the script that is waiting for the "yes" or "no" message is buried inside the if block for "I am fine sir, are you ok?". So it will never get trigged.</p> <p>**UPDATE</p> <p>Here is a way to test your logic.</p> <p>create two scripts.</p> <p>The first one will be the one with the logic. And you will run it in Applescript editor.</p> <pre><code>property lastMessage : "" set theMessage to load script "/PATH/TO/SECOND/SCRIPT/secondScript.scpt" run theMessage if theMessage is "hello" then helloresponse() end if if theMessage contains "Are you ok" then areyouok() end if if theMessage is "yes" and lastMessage is "I am fine sir, are you ok?" then happyResponse() else if theMessage is "no" and lastMessage is "I am fine sir, are you ok?" then unhappyResponse() end if if theMessage contains "hello world" then helloworldresponse() end if on helloresponse() say "Hey sir!" end helloresponse on happyResponse() say "you said yes, yey!" set lastMessage to "" end happyResponse on unhappyResponce() say "You said no, thats a shame!" set lastMessage to "" end unhappyResponce on areyouok() say "I am fine sir, are you ok?" set lastMessage to "I am fine sir, are you ok?" end areyouok on helloworldresponse() say "World replies: Hello." end helloworldresponse </code></pre> <p>Take note of the <strong>property</strong> I have given it. Any variable passed into a property is stored there. And can be accessed when the script is run again later.</p> <p>In this case I have set it to store the last response/message if that response was "I am fine sir, are you ok?"</p> <p>I have also split your <strong>if</strong> blocks so that the happyResponse and unhappyResponse response will be triggered only with the "yes" or "no" message and as long as the last response stored in the property lastMessage is "I am fine sir, are you ok?".</p> <p>In the first script is a line to load and run the second script.</p> <p>The second script is used to give the messages. This script is edited and then saved.</p> <p>for example the second script will just contain;</p> <pre><code>set theMessage to "Are you ok" </code></pre> <p>the second script is saved. And then you run the first script to pick up its theMessage and respond. <em>which should be "I am fine sir, are you ok?</em></p> <p>You then edit and save the second script with;</p> <pre><code>set theMessage to "yes" </code></pre> <p>And run the first script again. The response should be; <em>"you said yes, yey!"</em></p> <p>You will get the response you are expecting</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload