Neal Matthews
14th June 2003, 16:12
Is it possible to define functions within an Exchange Scheme condition.
When attempting to define the function I receive the error message shown below.
Regards
Neal Matthews
Intier Automotive - IT Support Analyst
Marc van Kessel
16th June 2003, 03:31
It is possible. You have to take the function structure into account that Exchange generates. You could create the scripts in 'debug' mode and look at the source code to identify the problem. If I remember correctly you have to write the condition as follows:
....
....
}
function ......(.....)
{
That is: add an extra bracket to close the condition and leave out the last bracket which is added by exchange automatically. Note that you can also use these functions in other conditions.
estotz
17th June 2003, 02:27
As Marc mentioned, it is possible, but not recommended.
Exchange treats a condition as a function itself which is passed to the compiler. If you look at the source created, the exec.<whatever> function is created. The compiler is getting confused because you are nesting a function inside there (in your condition, which ends up being a function in a function).
You can intercept the code that exchange creates, edit the source and add your function calls and then compile it with the appropriate bic command. THis is pretty non standard and I'm not sure what you would gain in code reuse.
Better to just code that functionality into your condition and reuse that code over by entering it into another text and bringing it in. At least someone looking at your exchange script in the future will understand what is going on.
Marc van Kessel
17th June 2003, 02:50
I fully agree with Estotz, do not mess with the generated source code, but that is not what I meant. You can simply add the function to the exchange condition by editing the condition text and applying the proposed structure.
I know copying source-code always works, and it is probably acceptable in small scripts like conditions, but it is also the one thing I see in abundance on problem-projects and should be avoided whenever possible.
I think it is also possible to use libraries in Exchange, perhaps an even better solution...
Best regards,
Marc
Neal Matthews
17th June 2003, 09:47
Many thanks for the feedback.
As we do not have a development licence my previous experience in using functions was to add them to the bottom of my report scripts. So I was really just looking to do the same in my exchange condition.
This technique always seem to make editing and updating the code much easier.
In the circumstance where I am just calling the function situauted at the bottom of the text from the text in the condition above is it OK to use the recommended structure ?
return (false)
}
function invwrite(string m_item(7), string m_qty(8))
{
long count,m_ffno,update,m_nextseq
etc.
Regards
Neal Matthews
Intier Automotive - IT Support Analyst