In my external software program (Lazarus Pascal) I have this call to AA:
AASendCommand(AA_SCRIPT_RUN, PChar('Image.ClosePrevious'));
AASendCommand(AA_SCRIPT_RUN, PChar('Image.Open("' + theImage + '")'));
The intent is to close the last opened image and replace it with a new image. When I do this the script editor displays only the second command but does not execute either of these. I am guessing the first call to AA_SCRIPT_RUN opened the editor, inserted the line but did not execute because the second command came in, overwrote the first script and then did not execute because it was confused.
But if I only do this:
AASendCommand(AA_SCRIPT_RUN, PChar('Image.Open("' + theImage + '")'));
Then it does open the new image.
My question then is, does successive calls to AA_SCRIPT_RUN require some sort of delay, or a 'RUN' command of some type in the script?
Craig
Successive Script commands question
Re: Successive Script commands question
An update, I changed the Image.ClosePrevious to Image.Close and now the previously opened image does close but the subsequent open new image does not. If I click Run in the script editor it then opens the new image. So it looks like the second command is not Run but is loaded into the script editor.
Craig
Craig
Re: Successive Script commands question
I found a solution:
AASendCommand(AA_SCRIPT_RUN, PChar('Image.Close'));
while (AASendCommand(AA_SCRIPT_GetStatus,nil) <> AAS_IDLE) do
Sleep(50);
AASendCommand(AA_SCRIPT_RUN, PChar('Image.Open("' + theImage + '")'));
To keep the program from hanging, this would be better:
AASendCommand(AA_SCRIPT_RUN, PChar('Image.Close'));
n := 0;
while (AASendCommand(AA_SCRIPT_GetStatus,nil) <> AAS_IDLE) do
begin
Sleep(50);
inc(n);
if n > 100 then break;
end;
AASendCommand(AA_SCRIPT_RUN, PChar('Image.Open("' + theImage + '")'));
The program will wait a maximum of 5 seconds before giving up.
Craig
AASendCommand(AA_SCRIPT_RUN, PChar('Image.Close'));
while (AASendCommand(AA_SCRIPT_GetStatus,nil) <> AAS_IDLE) do
Sleep(50);
AASendCommand(AA_SCRIPT_RUN, PChar('Image.Open("' + theImage + '")'));
To keep the program from hanging, this would be better:
AASendCommand(AA_SCRIPT_RUN, PChar('Image.Close'));
n := 0;
while (AASendCommand(AA_SCRIPT_GetStatus,nil) <> AAS_IDLE) do
begin
Sleep(50);
inc(n);
if n > 100 then break;
end;
AASendCommand(AA_SCRIPT_RUN, PChar('Image.Open("' + theImage + '")'));
The program will wait a maximum of 5 seconds before giving up.
Craig
Re: Successive Script commands question
Yes, there should be some delay between executing a script and a newer one.
Actually it's much better to send complete scripts, so I would join commands when possible:
script = 'Image.ClosePrevious' + <cr> + 'Image.Open("' + theImage + '")'
AASendCommand(AA_SCRIPT_RUN, PChar(script))
between scripts, I would also empty the message queue: <Application.ProcessMessages>
Actually it's much better to send complete scripts, so I would join commands when possible:
script = 'Image.ClosePrevious' + <cr> + 'Image.Open("' + theImage + '")'
AASendCommand(AA_SCRIPT_RUN, PChar(script))
between scripts, I would also empty the message queue: <Application.ProcessMessages>