Model custom code.fsmHello, I am currently writing a code that reads the label "Entrance" which holds the Floorstorage number and then adds a label with one of the two buffers that are associated to the Floorstorage to the token. I always get the Error code:
Flexscript Error MODEL:/Tools/ProcessFlow/ProcessFlow5/Custom Code>variables/codeNode Line 6 syntax error, unexpected '{'
Could not finish parsing because of previous errors.
Is this code even able to do my operation? I am currently just trying out the coding feature.
/**Custom Code*/
// Get the name of the current floor storage
string storageName = label(current, "Entrance");
// Define the buffers associated with each floor storage
object bufferDict = {
"FloorStorage 461": ["_461 Buffer", "_461 Buffer1"],
"FloorStorage 460": ["_460 Buffer", "_460 Buffer1"],
"FloorStorage 462": ["_462 Buffer", "_462 Buffer1"],
"FloorStorage 459": ["_459 Buffer", "_459 Buffer1"],
"FloorStorage 458": ["_458 Buffer", "_458 Buffer1"],
"FloorStorage 457": ["_457 Buffer", "_457 Buffer1"]
};
// Find the index of the current floor storage in the bufferDict array
int storageIndex = find(array(bufferDict), storageName);
// Select a random buffer for the current floor storage
int bufferIndex = rand(1, 2);
string selectedBuffer = bufferDict[storageName][bufferIndex];
// Print the selected buffer name to the console
traceln("Selected Buffer for " + storageName + ": " + selectedBuffer);
// Add a label to the token with the selected buffer name
token.label(selectedBuffer);
// Return the selected buffer as a node reference
return node(current, selectedBuffer);
Thank you all for your help in Advance!