BizTalk Script Functoid using a mid fuction
I am new to BizT开发者_JS百科alk and am looking for an example of how to use a vb.net mid function in a scripting functoid.
I always suggest writing and testing your function in regular Visual Studio first, then if you want, copy the function into the mapping functoid. The reason for this is full use of intellisense (auto-completion), debugging, sytnax checking, etc... - all of which is missing in the little mapping functoid box.
NOTE: You can also save the module in Visual Studio as a .DLL, and call the .DLL from the functoid. Then you can build a larger and larger .DLL custom library for your all your mapping functoids.
Example in Visual Studio:
Module Module1
Sub Main()
Dim demoString As String = "abcdef"
Console.WriteLine("result=" & DemoFunction1(demoString))
Console.WriteLine("result=" & DemoFunction2(demoString))
End Sub
Function DemoFunction1(ByVal textin As String) As String
Dim textout As String
textout = Mid(textin, 3, 4)
Return textout
End Function
Function DemoFunction2(ByVal textin As String) As String
Dim textout As String
textout = textin.Substring(2, 4)
Return textout
End Function
End Module
For example, if you pass a value of "abc", the function will bomb. So that may indicate you need to test the length of the field before doing the MID function.
You either do the old-style MID function or the newer VB.NET .Substring function. I have shown both in the sample above. The substring function has a zero offset, but MID has a 1-offset.
The chunk of code you would copy into your functoid is:
Function DemoFunction1(ByVal textin As String) As String
Dim textout As String
textout = Mid(textin, 3, 4)
Return textout
End Function
精彩评论