使用 mid 函数的 BizTalk 脚本 Functoid

发布于 2024-09-08 06:01:14 字数 62 浏览 1 评论 0原文

我是 BizTalk 的新手,正在寻找如何在脚本 functoid 中使用 vb.net mid 函数的示例。

I am new to BizTalk and am looking for an example of how to use a vb.net mid function in a scripting functoid.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

叫嚣ゝ 2024-09-15 06:01:14

我总是建议首先在常规 Visual Studio 中编写和测试函数,然后如果需要,将函数复制到映射 functoid 中。其原因是充分利用了智能感知(自动完成)、调试、sytnax 检查等 - 所有这些都在小映射 functoid 框中缺失。

注意:您还可以在 Visual Studio 中将模块另存为 .DLL,并从 functoid 调用该 .DLL。然后,您可以为所有映射 functoid 构建越来越大的 .DLL 自定义库。

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

例如,如果您传递“abc”值,该函数将会崩溃。因此,这可能表明您需要在执行 MID 功能之前测试字段的长度。

您可以执行旧式 MID 函数或较新的 VB.NET .Substring 函数。我已经在上面的示例中展示了两者。 substring 函数的偏移量为零,但 MID 的偏移量为 1。

您要复制到 functoid 中的代码块是:

Function DemoFunction1(ByVal textin As String) As String
    Dim textout As String
    textout = Mid(textin, 3, 4)
    Return textout
End Function

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文