Switch blocks
Unless there is already a way, it would be nice to have switch blocks based upon ordinals. Supposed one issue might be the number of switches. Today I implemented the equivalent with nested if then else blocks. Keep up the good work! 👍
I am not sure that I understand what it says. Could you please give an example ?
An example
Didn't mean to close this.
I understand now. Thinking....
Thx for reopenning this and considering it. I have worked out a work around for now, not yet implemented. I can add a new ASP.NET controller method that takes a csv list of ordinals for the required commands along with the menu parameter which implements the switch-case funstionality there. ... The "beauty of being able to adhocly add more controller methords..
Even better, take the string at the start of the block above and look up the command names using the menu parameter and call that comamnd. The new version of Softata NetCporeBlockly has lookup capability for commands. Nb: For simplicity, the lookup selects the named command that either contains the part of the csv string when split into its components or the commnd name that is contained in the lookup value._ A "lazy" search.
The latter was simple to implement:
public IActionResult ActionDeviceCmdindexfrmCSVlistNoParam(DeviceInstance deviceInstance, string csv, byte index)
{
string[] cmds = csv.Split(',');
if (index >= cmds.Length)
{
return BadRequest("Index out of range");
}
byte subCmd = LookUpGenericCmd(deviceInstance.DeviceType, cmds[index]);
string result = sharedService.ActionDeviceCmdwithByteArrayParams((int)deviceInstance.DeviceType, HttpContext, Client, deviceInstance.ListLinkId, subCmd);
return Ok(result);
}
Is only a few obvious lines different from ActionDeviceCmdNoParam()
Actually it's a little more complex, (not shown here) but only marginally, because the csv string has a colon seperated part at start for the menu heading.
switch-case would be useful in the longer term though, but I understand it could be complex.
Here are the blocks thus (implemented with 2nd scenario):
Comment. Note found that variables used in a function are global. Hence menu2 as menu is in the Menu with MenuCSV() function etc. Might be "nice" if function variables weren't gobal
Oh I see that the following block can do it, I think. Once I figured out how to and more cases: