Hello,
I running the below code and get "exception object expected" every time. If I click OK, the Amiquote will exit immediately; If I remove RunEvery(60), it amiquote will as soon as it is started.
I wanna run amiquote silently without interrupting my working.
Is there anything wrong with my code?
Thanks!
AQ = new ActiveXObject("AmiQuote.Document");
try
{
while ( AQ.DownloadInProgress) WScript.Sleep( 500 ); // check IsBusy every 0.5 second
while ( AQ.ImportInProgress) WScript.Sleep( 500 ); // check IsBusy every 0.5 second
AQ.Open( "C:\\Users\\Administrator\\OneDrive\\Watchlist\\Watchlist\\symbols.tls" );
AQ.Download();
AQ.AutoImport;
RunEvery(60);
}
catch ( err )
{
WScript.echo( "Exception: " + err.message ); // display error that may occur
}
Should I change AQ.AutoImport = 1 too? I changed the code as following, but everytime, it open amiquote and close it immediately. The symbol list is 120 symbols so it should take longer time.
AQ = new ActiveXObject("AmiQuote.Document");
try
{
while ( AQ.DownloadInProgress) WScript.Sleep( 500 ); // check IsBusy every 0.5 second
while ( AQ.ImportInProgress) WScript.Sleep( 500 ); // check IsBusy every 0.5 second
AQ.Open( "C:\\Users\\Administrator\\OneDrive\\Watchlist\\Watchlist\\symbols.tls" );
AQ.Download();
AQ.AutoImport = 1;
AQ.RunEvery() = 60;
}
catch ( err )
{
//WScript.echo( "Exception: " + err.message ); // display error that may occur
}
The order of function calls in your script is incorrect. You should first call AQ.Download and LATER wait for completion, not the other way round as you are doing now.
Actually this code isn't correct because you have set all settings PRIOR to actions. And you are still NOT reading my posts carefully and make the same error over again.
AQ = new ActiveXObject("AmiQuote.Document");
try
{
AQ.Open( "C:\\Users\\Administrator\\OneDrive\\Watchlist\\Watchlist\\symbols.tls" );
// settings FIRST!
AQ.AutoImport = 1;
AQ.RunEvery = 60;
// after everything is set do the ACTION
AQ.Download();
while ( AQ.DownloadInProgress || AQ.ImportInProgress) WScript.Sleep( 500 ); // check IsBusy every 0.5 second
}
catch ( err )
{
//WScript.echo( "Exception: " + err.message ); // display error that may occur
}
i got the below error after i run the code and it failed to update any data.
Looks like you are wrong this time After moving the AQ.AutoImport = 1 and AQ.RunEvery() = 60 at the end, it can update data but still show the above exception.
AQ = new ActiveXObject("AmiQuote.Document");
try
{
AQ.Open( "C:\\Users\\Administrator\\OneDrive\\Watchlist\\Watchlist\\symbols.tls" );
// after everything is set do the ACTION
AQ.Download();
while ( AQ.DownloadInProgress || AQ.ImportInProgress) WScript.Sleep( 500 ); // check IsBusy every 0.5 second
// settings FIRST!
AQ.AutoImport = 1;
AQ.RunEvery() = 60;
}
catch ( err )
{
WScript.echo( "Exception: " + err.message ); // display error that may occur
}
I gave you the answer A COUPLE OF POSTS ago. But you did not read that answer carefully and did not copy-paste it properly.
As I earlier pointed out, your code is wrong. You are using RunEvery as function while it is PROPERTY. REMOVE all that try-catch because it is misleading you into thinking that the code is good. But is not. Your modified code has SYNTAX ERROR. You are modifying the code without knowing what you are doing. Property is not a function. RunEvery must be used as property, i.e. WITHOUT braces. If you can't program with JScript, don't use it.