Added list reporter block.

This commit is contained in:
Scimonster 2013-10-30 15:00:28 +02:00
parent 234e044660
commit 4d237ef389

View file

@ -26,6 +26,7 @@ VarListPrims.prototype.addPrimsTo = function(primTable) {
primTable['showVariable:'] = this.primShowVar;
// List primitives
primTable['contentsOfList:'] = this.primReadList;
primTable['append:toList:'] = this.primListAppend;
primTable['deleteLine:ofList:'] = this.primListDeleteLine;
primTable['insert:at:ofList:'] = this.primListInsertAt;
@ -103,6 +104,14 @@ var findList = function(targetSprite, listName) {
return null;
}
VarListPrims.prototype.primReadList = function(b) {
var list = findList(interp.targetSprite(), interp.arg(b, 0));
if (list) {
var allOne = list.map(function(val){return val.length}).reduce(function(old,val){return old+val},0)===list.length;
return list.join(allOne?'':' ');
}
}
VarListPrims.prototype.primListAppend = function(b) {
var list = findList(interp.targetSprite(), interp.arg(b, 1));
if (list) list.push(interp.arg(b, 0));