diff --git a/ChangeLog.txt b/ChangeLog.txt
index 3bb1c394..94f43137 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -1,5 +1,17 @@
Changelog
+
+========== Version 2.0.0 ==========
+
+Major Changes:
+Alter loop counters to be more pythonic (starting at 0)
+
+Minor Changes:
+Defines loop counters in the loop
+
+Patches and Bug Fixes:
+Tinker blocks in loops no longer generate functions
+
========== Version 1.1.0 ==========
Major Changes:
@@ -16,4 +28,4 @@ Rename 'Tests' to 'Logical Operators'
========== Version 1.0.0 ==========
-First Release (of this fork)
\ No newline at end of file
+First Release (of this fork)
diff --git a/pom.xml b/pom.xml
index 4e859de7..08ad4ed6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
org.ardublock
ardublock
jar
- 1.1.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
ArduBlock
A Block Programming Language for Arduino
diff --git a/src/main/java/com/ardublock/translator/block/RepeatBlock.java b/src/main/java/com/ardublock/translator/block/RepeatBlock.java
index 28f49c90..7706b950 100644
--- a/src/main/java/com/ardublock/translator/block/RepeatBlock.java
+++ b/src/main/java/com/ardublock/translator/block/RepeatBlock.java
@@ -20,17 +20,15 @@ public RepeatBlock(Long blockId, Translator translator, String codePrefix, Strin
@Override
public String toCode() throws SocketNullException, SubroutineNotDeclaredException
{
- String varName="";//this.getRequiredTranslatorBlockAtSocket(0);
TranslatorBlock teste = this.getRequiredTranslatorBlockAtSocket(0);
if (!(teste instanceof VariableNumberBlock || teste instanceof VariableNumberUnsignedLongBlock || teste instanceof VariableNumberDoubleBlock)) {
throw new BlockException(blockId, uiMessageBundle.getString("ardublock.error_msg.number_var_slot"));
}
- varName=varName+teste.toCode();
- //translator.addDefinitionCommand("int " + varName + "; //teste");
- String ret = "for (" + varName + "= 1; " + varName + "<= ( ";
+ String varName=teste.toCode();
+ String ret = "for(int " + varName + "=0; " + varName + " < ";
TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(1);
ret = ret + translatorBlock.toCode();
- ret = ret + " ); " + varName + "++ )\n{\n";
+ ret = ret + "; " + varName + "++)\n{\n";
translatorBlock = getTranslatorBlockAtSocket(2);
diff --git a/src/main/java/com/ardublock/translator/block/RepeatControlBlock.java b/src/main/java/com/ardublock/translator/block/RepeatControlBlock.java
index 2d78253b..370d2a72 100644
--- a/src/main/java/com/ardublock/translator/block/RepeatControlBlock.java
+++ b/src/main/java/com/ardublock/translator/block/RepeatControlBlock.java
@@ -37,11 +37,18 @@ public String toCode() throws SocketNullException, SubroutineNotDeclaredExceptio
tb = this.getRequiredTranslatorBlockAtSocket(3);
String incVal = tb.toCode();
- String ret = "";
+ String ret = "for(int " + varName + " = " + startVal + "; ";
- ret = ret + "for(" + varName + " = " + startVal + "; \n" +
- startVal + "<=" + stopVal + "?" + varName + " <= " + stopVal + ":" + varName + " >= " + stopVal + "; \n" +
- startVal + "<=" + stopVal + "?" + varName + " = " + varName + " + " + incVal + ":" + varName + " = " + varName + " - " + incVal + ")\n{";
+ if (Integer.parseInt(startVal) <= Integer.parseInt(stopVal)) {
+ ret = ret + varName + " < " + stopVal+"; ";
+ ret = ret + varName + " = " + varName + " + " + incVal+")\n";
+ }
+ else {
+ ret = ret + varName + " > " + stopVal+"; ";
+ ret = ret + varName + " = " + varName + " - " + incVal+")\n";
+ }
+
+ ret = ret +"{";
TranslatorBlock translatorBlock = getTranslatorBlockAtSocket(4);
while (translatorBlock != null)
diff --git a/src/main/java/com/ardublock/translator/block/RepeatTimesBlock.java b/src/main/java/com/ardublock/translator/block/RepeatTimesBlock.java
index ea2b9d97..f5d71a6f 100644
--- a/src/main/java/com/ardublock/translator/block/RepeatTimesBlock.java
+++ b/src/main/java/com/ardublock/translator/block/RepeatTimesBlock.java
@@ -16,11 +16,10 @@ public RepeatTimesBlock(Long blockId, Translator translator, String codePrefix,
public String toCode() throws SocketNullException, SubroutineNotDeclaredException
{
String varName = translator.buildVariableName();
- translator.addDefinitionCommand("int " + varName + "a;");
- String ret = "for (" + varName + "a=1; " + varName + "a<= ( ";
+ String ret = "for(int " + varName + "i=0; " + varName + "i < ";
TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
ret = ret + translatorBlock.toCode();
- ret = ret + " ); ++" + varName + "a )\n{\n";
+ ret = ret + "; " + varName + "i++)\n{\n";
translatorBlock = getTranslatorBlockAtSocket(1);
diff --git a/src/main/java/com/ardublock/translator/block/tinker/AbstractTinkerWriteDigitalBlock.java b/src/main/java/com/ardublock/translator/block/tinker/AbstractTinkerWriteDigitalBlock.java
index 374041ba..210f4757 100644
--- a/src/main/java/com/ardublock/translator/block/tinker/AbstractTinkerWriteDigitalBlock.java
+++ b/src/main/java/com/ardublock/translator/block/tinker/AbstractTinkerWriteDigitalBlock.java
@@ -22,22 +22,16 @@ public String toCode() throws SocketNullException, SubroutineNotDeclaredExceptio
TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
String ret = "";
- if (translatorBlock instanceof NumberBlock || translatorBlock instanceof TinkerOutputPortBlock)
+ String number = translatorBlock.toCode();
+
+ if (translatorBlock instanceof NumberBlock)
{
- String number = translatorBlock.toCode();
String setupCode = "pinMode( " + number + " , OUTPUT);";
translator.addSetupCommand(setupCode);
-
- ret = "digitalWrite( ";
- ret = ret + number;
- }
- else
- {
- translator.addDefinitionCommand(DigitalOutputBlock.ARDUBLOCK_DIGITAL_WRITE_DEFINE);
- ret = "__ardublockDigitalWrite(";
-
- ret = ret + translatorBlock.toCode();
}
+
+ ret = "digitalWrite( ";
+ ret = ret + number;
ret = ret + " , ";
translatorBlock = this.getRequiredTranslatorBlockAtSocket(1);
diff --git a/src/main/resources/com/ardublock/block/ardublock.properties b/src/main/resources/com/ardublock/block/ardublock.properties
index 698fa2ba..09561fc0 100644
--- a/src/main/resources/com/ardublock/block/ardublock.properties
+++ b/src/main/resources/com/ardublock/block/ardublock.properties
@@ -437,7 +437,7 @@ ardublock.ui.create_refer=create reference
ardublock.ui.website=Go to Web Site
ardublock.ui.serialMonitor=Serial Monitor
ardublock.ui.saveImage=Save as image...
-ardublock.ui.version=1.1.0
+ardublock.ui.version=2.0.0
ardublock.error_msg.digital_var_slot=Digital variable slot must take a 'digital variable' name.\nHint: Look at the 'variable' socket on the highlighted block
ardublock.error_msg.number_var_slot=Standard variable slot must take a standard 'numeric' variable name.\nHint: Look at the 'variable' socket on the highlighted block
@@ -1505,4 +1505,4 @@ bg.FaireBot_AddRight.description=Save "right" in memory
bg.FaireBot_Go.description=Run saved commands
bg.FaireBot_Distance.description=Set the forward/back distance of the FaireBot
-bg.FaireBot_Turn.description=Set the turn of the FaireBot
\ No newline at end of file
+bg.FaireBot_Turn.description=Set the turn of the FaireBot