Bha*_*ran 1 progress-4gl openedge
这是我的问题
define varibale MyArray as character extent 40 no-undo.
define variable Mychara as character no-undo.
Mychara = "hai this is checking how to copy values"
Run Code Online (Sandbox Code Playgroud)
现在我想将此字符串复制到我的"MyArray".所以它应该如下
MyArray [1] = h,MyArray [2] = a,MyArray [3] = i,MyArray [4] ="",MyArray [5] = t,MyArray [6] = h等等......
那怎么办呢?
鉴于您的代码示例,这应该做的伎俩:
define variable MyArr as character EXTENT 40 no-undo.
define variable Mychara as character no-undo.
Mychara = "hai this is checking how to copy values".
DEF VAR i AS INT NO-UNDO.
DO i = 1 TO 40:
MyArr[i] = SUBSTRING(MyChara,i,1).
END.
Run Code Online (Sandbox Code Playgroud)
但需要注意的是:这意味着您必须事先知道String的(最大)大小,以便适当地定义数组大小.