Stuck and doesn't work
The simple program hangs and doesn't output any result

Thank you for reporting this.
I have attempted to reproduce this fault with this PR: #57 but the test works successfully.
Please feel free to alter the XML in the unit test to demonstrate the fault.
- open https://richorama.github.io/IronBlock/
- add
print ncommand beforeset nlike on screenshot - Click run button
@richorama do you know why it may happen? Any chance to get it fixed?
Yep, something is not quite right...

i got the same problem. i changed the code and it works
@q383186554 what change did you make?
public Workspace Parse(string xml, bool preserveWhitespace = false)
{
CustomPrintBlock.Text.Clear();
var xdoc = new XmlDocument { PreserveWhitespace = preserveWhitespace };
xdoc.LoadXml(xml);
var workspace = new Workspace();
foreach (XmlNode node in xdoc.DocumentElement.ChildNodes)
{
if (node.LocalName == "block" || node.LocalName == "shadow")
{
var block = ParseBlock(node);
if (null != block) workspace.Blocks.Add(block);
}
else
{
// Fast-Solution :-)
// Global variables should be parsed, else the assessment of any global variable in the script will cause an Application Exception("unexpected value type") exception.
// only global variables should be parsed in this context.
if (node.LocalName != "variables" || node.FirstChild == null ||
string.IsNullOrWhiteSpace(node.FirstChild.InnerText))
continue;
var block = new GlobalVariablesSet();
foreach (XmlNode nodeChild in node.ChildNodes)
{
if (nodeChild.LocalName != "variable" ||
string.IsNullOrWhiteSpace(nodeChild.InnerText))
continue;
// Generate variable members
var field = new Field
{
Name = "VAR",
Value = nodeChild.InnerText,
};
block.Fields.Add(field);
var value = new Value
{
Name = "VALUE"
};
block.Values.Add(value);
}
workspace.Blocks.Add(block);
}
}
return workspace;
}
IBlock ParseBlock(XmlNode node)
{
if (bool.Parse(node.GetAttribute("disabled") ?? "false")) return null;
var type = node.GetAttribute("type");
if (!blocks.ContainsKey(type)) throw new ApplicationException($"block type not registered: '{type}'");
//
var block = blocks[type]();
if (type == "text_print")
{
block = new Blocks.CustomPrintBlock();
}
block.Type = type;
block.Id = node.GetAttribute("id");
foreach (XmlNode childNode in node.ChildNodes)
{
switch (childNode.LocalName)
{
case "mutation":
ParseMutation(childNode, block);
break;
case "field":
ParseField(childNode, block);
break;
case "value":
ParseValue(childNode, block);
break;
case "statement":
ParseStatement(childNode, block);
break;
case "comment":
ParseComment(childNode, block);
break;
case "next":
var nextBlock = ParseBlock(childNode.FirstChild);
if (null != nextBlock) block.Next = nextBlock;
break;
default:
throw new ArgumentException($"unknown xml type: {childNode.LocalName}");
}
}
return block;
}
@q383186554 what change did you make?
Can you see the code?
yes, thank you, I did see the code, and compared it to the existing code. I think it adds some block-specific logic into functions which should be agnostic of block types, so it's not a generalised solution. I also don't see how it fixes the problem :¬/
I fixed the CustomPrintBlock bug. when we dag two print moudle. The output info is always the same.
yes, thank you, I did see the code, and compared it to the existing code. I think it adds some block-specific logic into functions which should be agnostic of block types, so it's not a generalised solution. I also don't see how it fixes the problem :¬/
I fixed the CustomPrintBlock bug. when we dag two print moudle. The output info is always the same.