Skip to content

StringByte

返回字符串指定范围i-jASCII 码,i 的默认值为 1,即第一个字节,j 的默认值为 i 。

Lua字符串的字节下标是从 1 开始的

业务属性

属性含义说明输入限定示例值
enable是否启用该控件,未启用时不编译是否编译选择值启用
name控件返回值命名控件输出值变量名常量StringByte
text与控件关联的文本设计页控件显示常量StringByte
input输入参数常量/流程变量abc
startIndex起始索引常量/流程变量1
endIndex截止索引常量/流程变量2
output控件返回值变量命名常量o1,o2

该控件具有若干个返回值,返回值的个数由输入参数的长度决定,所以需要定义若干个返回变量进行接收。

参数长度大于控件返回值定义个数时,多余的返回值就被丢弃。例如参数为xyz,此时参数长度为3,若只定义一个返回值变量,将只返回字符xASCII 码

返回值定义个数大于参数长度时,多余的返回值变量将会为nil。例如参数为xyz,此时参数长度为3,却定义了a,b,c,d,e,f6个返回值变量,此时d,e,f三个变量将为nil

起始索引及截止索引的默认值为1,所以当这两个参数为nil或者为1时,控件将只有一个返回值。

使用示例

单个返回值

参数输入:abc,起始索引及截止索引为空,此时将只有一个返回值既字符aASCII 码,所以只需定义一个返回值:output1

img_36.png

输出控件返回output1data属性为:

json
{
  "output1": "#{output1}"
}
{
  "output1": "#{output1}"
}
img_37.png

使用curl请求接口:

$ curl http://localhost:6636/api/stringByte
$ curl http://localhost:6636/api/stringByte

接口返回:

json
{
    "output1": 97
}
{
    "output1": 97
}

将起始索引修改为:3,截止索引依旧为空,此时依旧只有一个返回值既字符cASCII 码

img_38.png

使用curl请求接口:

$ curl http://localhost:6636/api/stringByte
$ curl http://localhost:6636/api/stringByte

接口返回:

json
{
    "output1": 99
}
{
    "output1": 99
}

多个返回值

参数输入:#{body.string},起始索引:#{body.start},截止索引:#{body.end},定义返回值变量:op1,op2,op3

img_39.png

多个变量之间使用英文,进行隔开

输出控件data属性:

json
{
  "a": "#{op1}",
  "b": "#{op2}",
  "c": "#{op3}"
}
{
  "a": "#{op1}",
  "b": "#{op2}",
  "c": "#{op3}"
}
img_40.pngimg_41.png

使用curl请求接口:

$ curl http://localhost:6636/api/stringSub -d "{ \"string\": \"abc\", \"start\": 1, \"end\": 3 }"
$ curl http://localhost:6636/api/stringSub -d "{ \"string\": \"abc\", \"start\": 1, \"end\": 3 }"

接口返回:

json
{
    "a": 97,
    "b": 98,
    "c": 99
}
{
    "a": 97,
    "b": 98,
    "c": 99
}