CupCarbon icon indicating copy to clipboard operation
CupCarbon copied to clipboard

CONC Command: Fix issue with delimeter variable being re-assigned in a wrong way

Open YuriyAM opened this issue 1 year ago • 0 comments

Description

This pull request addresses a variable assignment issue encountered during CONC command execution. The problem arised from the re-assignment of the symbol variable, which, in certain cases, was not being reset to its initial value. This behavior occurred due to references to the same object in memory.

To rectify this issue, a new variable named delim has been introduced. This change ensures that symbol retains its original value, while delim is used as the delimiter for string concatenation.

Code example

set result ""
loop
	conc result "" result "A"
	cprint result

Exception in thread "Thread-17" java.lang.StringIndexOutOfBoundsException: String index out of range: 0 at java.lang.String.charAt(String.java:658) at senscript.SenScript.getVariableValue(SenScript.java:178) at senscript.Command_CONC.execute(Command_CONC.java:25) at senscript.SenScript.executeCommand(SenScript.java:152) at device.SensorNode.execute(SensorNode.java:679) at simulation.WisenSimulation.start_simulation(WisenSimulation.java:253) at simulation.WisenSimulation.simulate(WisenSimulation.java:74) at simulation.WisenSimulation.run(WisenSimulation.java:479) at java.lang.Thread.run(Thread.java:748)

YuriyAM avatar Oct 07 '23 18:10 YuriyAM