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]
]