Here is a code snippet that behaves incorrectly.
SRT>ProcessCR
Let>TimeLCV=0
Let>datalen=0
repeat>datalen
Gosub>NavigateMGB
VBEval>GetCell(%ACCTNUM%,%CURR_EXCEL_ROW%),cAcctData
Length>cAcctData,datalen
if>{(%datalen%>0)}
VBEval>GetCell(%CREDITRATE%,%CURR_EXCEL_ROW%),crrate
VBRun>HostSend,MGB
VBRun>HostSend,%cAcctData%@E
Gosub>CheckProcess
if>{(%WaitResponseStatus%="SUCCESS")}
Let>stat=SUCCESS
VBRun>HostSend,@T@T@T@T%crrate%@E
Let>WaitText=GENERAL DATA CHANGED
Gosub>WaitResponse
if>{(%WaitResponseStatus%="SUCCESS")}
//validate the update
Gosub>NavigateMGB
VBRun>HostSend,MGB%cAcctData%@E
Let>WaitText=CREDIT RATING %crrate%
Gosub>WaitResponse
//if we found the response on the screen it means the update was successful
Let>stat=SUCCESS
else
VBEval>GetRow(24),stat
endif
else
VBEval>GetRow(24),stat
endif
//On 2nd pass When datalen = 0 we hit this code!!!! OUCH!!!
VBRun>PutCell,%RESULTS%,%CURR_EXCEL_ROW%,%stat%
//navigate to the account balance screen
Gosub>ProcessBalance
Let>crPos=0
Position>C,tAcctBal,1,crPos
if>crPos>0
Gosub>ProcessOpenToBuy
endif
endif
Gosub>SaveTime
Add>CURR_EXCEL_ROW,1
until>datalen,0
END>ProcessCR
I am using version 7.3.08 registered
On the first time through the above code, datalen=16
On the second time through this code,datalen=0
WaitResponseStatus always equals "SUCCESS"
On the second pass, when datalen=0, code gets executed that should not, there is a problem with the nested if else end ifs!
If I change the code to as follows it works just fine...
SRT>ProcessCRData
VBEval>GetCell(%CREDITRATE%,%CURR_EXCEL_ROW%),crrate
VBRun>HostSend,MGB
VBRun>HostSend,%cAcctData%@E
Gosub>CheckProcess
if>{(%WaitResponseStatus%="SUCCESS")}
Let>stat=SUCCESS
VBRun>HostSend,@T@T@T@T%crrate%@E
Let>WaitText=GENERAL DATA CHANGED
Gosub>WaitResponse
if>{(%WaitResponseStatus%="SUCCESS")}
//validate the update
Gosub>NavigateMGB
VBRun>HostSend,MGB%cAcctData%@E
Let>WaitText=CREDIT RATING %crrate%
Gosub>WaitResponse
//if we found the response on the screen it means the update was successful
Let>stat=SUCCESS
else
VBEval>GetRow(24),stat
endif
else
VBEval>GetRow(24),stat
endif
VBRun>PutCell,%RESULTS%,%CURR_EXCEL_ROW%,%stat%
//navigate to the account balance screen
Gosub>ProcessBalance
Let>crPos=0
Position>C,tAcctBal,1,crPos
if>crPos>0
Gosub>ProcessOpenToBuy
endif
END>ProcessCRData
//**********************************
//ProcessCR
//**********************************
SRT>ProcessCR
Let>TimeLCV=0
Let>datalen=0
repeat>datalen
Gosub>NavigateMGB
VBEval>GetCell(%ACCTNUM%,%CURR_EXCEL_ROW%),cAcctData
Length>cAcctData,datalen
if>{(%datalen%>0)}
Gosub>ProcessCRData
endif
Gosub>SaveTime
Add>CURR_EXCEL_ROW,1
until>datalen,0
END>ProcessCR
Does anyone see anythig wrong with this code?
If else endif nested issue - Yes I read the other posts!
Moderators: JRL, Dorian (MJT support)
Hi jsg,
The best way to debug this complicated script would be Macro scheduler's debugger. The problem here is that the script you supplied did work but didn't meet your expectation. Macro Scheduler's debugger save innumerable hours in my script development.
To use Macro Scheduler's debugger, follow the steps:
1. Fire up the main window of Macro Scheduler;
2. Select the script in question;
3. Press Ctrl+S to pop up the Edit;
4. Press Alt+D,W to monitor value changes of variables;
5. Press F8, one step at a time.
This routine alone will answer a lot of why and how questions (90%).
Good luck. Happy Chinese New Year!
The best way to debug this complicated script would be Macro scheduler's debugger. The problem here is that the script you supplied did work but didn't meet your expectation. Macro Scheduler's debugger save innumerable hours in my script development.
To use Macro Scheduler's debugger, follow the steps:
1. Fire up the main window of Macro Scheduler;
2. Select the script in question;
3. Press Ctrl+S to pop up the Edit;
4. Press Alt+D,W to monitor value changes of variables;
5. Press F8, one step at a time.
This routine alone will answer a lot of why and how questions (90%).
Good luck. Happy Chinese New Year!
If else endif nested issue - Yes I read the other posts!
I am familiar wih MacroScript and how to use the debugger. I have written several rather complex scripts in the last 5 months.
I will see if I can reproduce the error with a less complex example.
I was hoping someone would spot a syntax or other simple error!
I will see if I can reproduce the error with a less complex example.
I was hoping someone would spot a syntax or other simple error!
Hi jsg,
Everyonne can see you're an expert in Macro Scheduler scripting. Nonetheless, if you're patient enough to STEP through the script through the debugger, you might be surprised by the discoveries you didn't expect before.
repeat>datalen
Gosub>NavigateMGB
VBEval>GetCell(%ACCTNUM%,%CURR_EXCEL_ROW%),cAcctData
Length>cAcctData,datalen
if>{(%datalen%>0)}
Gosub>ProcessCRData
endif
Gosub>SaveTime
Add>CURR_EXCEL_ROW,1
until>datalen,0
Before entering into the REPEAT> loop, datalen was initiated as 0. Then datalen may be chaned by Length> between REPEAT...UNTIL. However, the upper bound is set to 0! It's interesting but doesn't make sense to me.
Last but not the least, I suppose you also take care of the trailing spaces.
Good luck.
I am familiar wih MacroScript and how to use the debugger.
Everyonne can see you're an expert in Macro Scheduler scripting. Nonetheless, if you're patient enough to STEP through the script through the debugger, you might be surprised by the discoveries you didn't expect before.
repeat>datalen
Gosub>NavigateMGB
VBEval>GetCell(%ACCTNUM%,%CURR_EXCEL_ROW%),cAcctData
Length>cAcctData,datalen
if>{(%datalen%>0)}
Gosub>ProcessCRData
endif
Gosub>SaveTime
Add>CURR_EXCEL_ROW,1
until>datalen,0
Before entering into the REPEAT> loop, datalen was initiated as 0. Then datalen may be chaned by Length> between REPEAT...UNTIL. However, the upper bound is set to 0! It's interesting but doesn't make sense to me.
Last but not the least, I suppose you also take care of the trailing spaces.
Good luck.
Actually Armstrong there is no reason why he shouldn't use 0 as the value that terminates the repeat loop. Since this value relates to the length of a string he's simply looping until he gets an empty string. The loop termination value is not neccessarily an "upper bound". The documentation doesn't say that this value must be larger than it was to start with. The documentation just says "Use in conjunction with Until. Iterates the code from the Repeat statement to the Until statement until the specified variable equals the value specified in the Until statement. "
This is actually a bug with the If/else/endif logic as jsg suspected. We've located and fixed the cause of the problem today and the update will be released on Monday.
This is actually a bug with the If/else/endif logic as jsg suspected. We've located and fixed the cause of the problem today and the update will be released on Monday.
MJT Net Support
[email protected]
[email protected]
Hi Support,
Now why the terminating value must be equal to, instead of greater than or less than, is more crystal clear to me. The REPEAT...UNTIL has no advanced konwledge whether the counter will be incrementing or decrmenting. Being EQUAL TO is logical as you insisted previously. Perhaps I was heavily influenced by xBASE. Thanks a lot.
Now why the terminating value must be equal to, instead of greater than or less than, is more crystal clear to me. The REPEAT...UNTIL has no advanced konwledge whether the counter will be incrementing or decrmenting. Being EQUAL TO is logical as you insisted previously. Perhaps I was heavily influenced by xBASE. Thanks a lot.