0
在zscript中我可以创造的8项追加变量列出在zscript中
[VarDef, myArr(8)]
的名单如何添加(推)到列表中的变量?
[VarDef, temp, 14]
[myArr.push(temp)] // ??? there is no push command
在zscript中我可以创造的8项追加变量列出在zscript中
[VarDef, myArr(8)]
的名单如何添加(推)到列表中的变量?
[VarDef, temp, 14]
[myArr.push(temp)] // ??? there is no push command
我终于明白了。不是我未来的自我,你需要为数组长度设置一个新的变量。
(我不认为存在的zscript相当于array.length的。
以下是创建一个空数组,然后填充它在一个循环的例子
[IButton, "Append", "stuff!",
// create array with 5 elements
[VarDef, myArr(5)]
// [Note,myArr(1),,1] // can't do! Variable has not been assigned a value
// create variable equal to array length
[VarDef, len, 5]
// create string to hold results
[VarDef, s, ""]
// loop over array
[VarSet,i,0]
[Loop,len,
[VarSet,myArr(i), i * 2]
[VarSet,s, [StrMerge, s, i, " "]]
// [Note,i,,0.5] // show counter
// [Note,s,,0.5] // show string value
[VarInc,i] // increase loop counter by 1
]
// show results!
[Note,myArr(1),,1]
]