Forum Discussion
What is the exception and on what line is it terminated?
- Pakema10 years agoContributor
I have code in 3 functions
Function F1
Dim a
Dim b
a = 5
b = 6
If a = b Then Log.Error("A must be C!") Exit Function End If End Function ' F1 Function F2
Dim a
Dim b
a = 3
b = 0
If a = b Then Log.Error("A must be C!") Exit Function End If End Function ' F2 Function F3
Dim a
Dim b
a = 4
b = 7
If a = b Then Log.Error("A must be C!") Exit Function End If End Function ' F3And I want to simplify this situation, f.e.
Function F1 Dim a Dim b a = 5 b = 6 execute(F4) ' <-- Error: script is terminated with an exception Function F2 Dim a Dim b a = 3 b = 0 eval (F4) ' <-- Error: script is terminated with an exception End Function ' F2 Function F3 Dim a Dim b a = 4 b = 7 execute(F4) ' <-- Error: script is terminated with an exception End Function ' F3 Function F4 Dim LocalVar_TmpTxt Dim LocalVar_CharEnter LocalVar_CharEnter = Chr(13) & Chr(10) LocalVar_TmpTxt = LocalVar_TmpTxt &_ "If a = b Then" & LocalVar_CharEnter & LocalVar_CharEnter LocalVar_TmpTxt = LocalVar_TmpTxt &_ "Log.Error(""A must be C!"")" & LocalVar_CharEnter & LocalVar_CharEnter LocalVar_TmpTxt = LocalVar_TmpTxt &_ "Exit Function" & LocalVar_CharEnter & LocalVar_CharEnter LocalVar_TmpTxt = LocalVar_TmpTxt &_ "End If" & LocalVar_CharEnter & LocalVar_CharEnter F4 = LocalVar_TmpTxt End Function ' F4
Why error: script is terminated with an exception ?
- sbkeenan10 years agoFrequent Contributor
Hi Pakema
It's not really clear what you are trying to achieve here, but I have given you a basic solution to what I think you are trying to achieve below. It could be simplified further, but I don't want to lose you if you're just starting out!!
Basically each sub (F1, F2 and F3) will need to be executed separately, each will pass their a and b values to F4, which will determine whether they are equal and display a suitable message. The solution could easily be configured such that F4 is a function and returns a true or false value to each of the calling subs, which would then be able to deal with the result in their own way. It could be further simplified whereby only one sub is required and it could simply loop through a specified number of iterations, each time passing different values to F4, but without knowing what you are trying to achieve, I've kept it to the same basic format that you gave.
If you need further assistance, perhaps you could give us more specific details of exactly what it is you are trying to achieve.
sub F1 dim a dim b a = 5 b = 6 call F4(a, b) end sub sub F2 dim a dim b a = 3 b = 0 call F4(a, b) end sub function F3 dim a dim b a = 4 b = 7 call F4(a, b) end function sub F4(a, b) if a = b then log.message("A and B are the same") else Log.error("A must be B!") end if end sub
Regards
Stephen.
- Pakema10 years agoContributor
sbkeenan, I need a little another result
In first, I need many time call same code with same result,
In second, I need same exit function In 3 different function
By your idea I need write additional condition each function, Why?
I want once write macro code and calling it when I want without waiting result of code
Related Content
- 8 years ago
Recent Discussions
- 15 hours ago
- 17 hours ago
- 19 hours ago