- Sun Jun 05, 2016 2:31 pm
#48630
I recall there was actually a limit to the amount of variables per line at one time I think you may a fixed this in version 1.x because this was an issue I discussed so my fault for forgetting but I believe it was 3 & symbols per line or something along that line but yes you are correct likely 2.x did not have that limitation I really don't know as my power strip is still sitting happy at 1.x.
I wish there were a way to dump everything on that particular nodemcu and clone it on to another to be honest as it is set in DIO mode and everything functions perfectly with very little overhead and is quick and responsive for DIO mode.
Anyhow back to the original reason for the post:
So lets take this code for example the start of my power strip code:
Code: Select all msgbranch [mybranch]
print "SEVER STATUS 200 OK"
debugoff
Wait
[mybranch]
MyReturnMsg = "Not a valid msg received"
msgget "pin" pinNo
msgget "stat" pinStatus
msgget "action" pinAction
if pinAction == "po" then gosub [po.pin]
if pinAction == "s" then gosub [read.it]
print "DOne with retrn code"
msgreturn MyReturnMsg
wait
[po.pin]
po pinNo pinStatus
if pinNo == "D1" then D2S = pinStatus
if pinNo == "D2" then D2S = pinStatus
if pinNo == "D3" then D3S = pinStatus
if pinNo == "D4" then D4S = pinStatus
if pinNo == "D5" then D5S = pinStatus
if pinNo == "D6" then D6S = pinStatus
if pinNo == "D7" then D7S = pinStatus
if pinNo == "D8" then D8S = pinStatus
MyReturnMsg = ""
'io(po,pinNO,pinStatus)
if pinStatus = 1 then MyReturnMsg = MyReturnMsg & "Outlet was turned ON successfully" else MyReturnMsg = MyReturnMsg & "Outlet was turned OFF successfully"
return
[read.it]
MyReturnMsg = ""
if D1S = 1 then MyReturnMsg = MyReturnMsg & "<p>OUTLET_1 is OFF</p>" else MyReturnMsg = MyReturnMsg & "<p>OUTLET_1 is ON</p>"
if D2S = 1 then MyReturnMsg = MyReturnMsg & "<p>OUTLET_2 is OFF</p>" else MyReturnMsg = MyReturnMsg & "<p>OUTLET_2 is ON</p>"
if D3S = 1 then MyReturnMsg = MyReturnMsg & "<p>OUTLET_3 is OFF</p>" else MyReturnMsg = MyReturnMsg & "<p>OUTLET_3 is ON</p>"
if D4S = 1 then MyReturnMsg = MyReturnMsg & "<p>OUTLET_4 is OFF</p>" else MyReturnMsg = MyReturnMsg & "<p>OUTLET_4 is ON</p>"
if D5S = 1 then MyReturnMsg = MyReturnMsg & "<p>OUTLET_5 is OFF</p>" else MyReturnMsg = MyReturnMsg & "<p>OUTLET_5 is ON</p>"
if D6S = 1 then MyReturnMsg = MyReturnMsg & "<p>OUTLET_6 is OFF</p>" else MyReturnMsg = MyReturnMsg & "<p>OUTLET_6 is ON</p>"
if D7S = 1 then MyReturnMsg = MyReturnMsg & "<p>OUTLET_7 is OFF</p>" else MyReturnMsg = MyReturnMsg & "<p>OUTLET_7 is ON</p>"
if D8S = 1 then MyReturnMsg = MyReturnMsg & "<p>OUTLET_8 is OFF</p>" else MyReturnMsg = MyReturnMsg & "<p>OUTLET_8 is ON</p>"
return
- See more at:
viewtopic.php?f=43&t=6851&p=35223#sthash.ZonFwwv9.dpufI noticed you changed this for example:
you added in debugoff ?
You also added the comment 'io(po,pinNO,pinStatus)
I assume you edited according to v3 syntax?
It really looks like there is no difference to code other than this.
I guess I am missing what was changed you claim the change is A function is now used to retrieve the desired msg argument.
So to make sure I am not missing anything would this edit be correct:
Code: Select all msgbranch [mybranch]
print "SEVER STATUS 200 OK"
debugoff '''??? Don't remember this is it to turn debug off in version 3.0?
Wait
[mybranch]
MyReturnMsg = "Not a valid msg received"
msgget "pin" pinNo 'CHANGE TO - - - pinNo = msgget("pin")
msgget "stat" pinStatus 'CHANGE TO - - - pinStatus = msgget("stat")
msgget "action" pinAction 'CHANGE TO - - - pinAction = msgget("action")
if pinAction == "po" then gosub [po.pin] 'DO I NEED A COMMA HERE? between gosub
if pinAction == "s" then gosub [read.it] 'DO I NEED A COMMA HERE? between gosub
print "DOne with retrn code"
msgreturn MyReturnMsg
wait
[po.pin]
po pinNo pinStatus 'CHANGE TO - - - io(po,pinNo,pinStatus)
if pinNo == "D1" then D2S = pinStatus
if pinNo == "D2" then D2S = pinStatus
if pinNo == "D3" then D3S = pinStatus
if pinNo == "D4" then D4S = pinStatus
if pinNo == "D5" then D5S = pinStatus
if pinNo == "D6" then D6S = pinStatus
if pinNo == "D7" then D7S = pinStatus
if pinNo == "D8" then D8S = pinStatus
MyReturnMsg = ""
'io(po,pinNO,pinStatus) ???? What is the purpose of the comment at this location?
if pinStatus = 1 then MyReturnMsg = MyReturnMsg & "Outlet was turned ON successfully" else MyReturnMsg = MyReturnMsg & "Outlet was turned OFF successfully"
return
[read.it]
MyReturnMsg = ""
if D1S = 1 then MyReturnMsg = MyReturnMsg & "<p>OUTLET_1 is OFF</p>" else MyReturnMsg = MyReturnMsg & "<p>OUTLET_1 is ON</p>"
if D2S = 1 then MyReturnMsg = MyReturnMsg & "<p>OUTLET_2 is OFF</p>" else MyReturnMsg = MyReturnMsg & "<p>OUTLET_2 is ON</p>"
if D3S = 1 then MyReturnMsg = MyReturnMsg & "<p>OUTLET_3 is OFF</p>" else MyReturnMsg = MyReturnMsg & "<p>OUTLET_3 is ON</p>"
if D4S = 1 then MyReturnMsg = MyReturnMsg & "<p>OUTLET_4 is OFF</p>" else MyReturnMsg = MyReturnMsg & "<p>OUTLET_4 is ON</p>"
if D5S = 1 then MyReturnMsg = MyReturnMsg & "<p>OUTLET_5 is OFF</p>" else MyReturnMsg = MyReturnMsg & "<p>OUTLET_5 is ON</p>"
if D6S = 1 then MyReturnMsg = MyReturnMsg & "<p>OUTLET_6 is OFF</p>" else MyReturnMsg = MyReturnMsg & "<p>OUTLET_6 is ON</p>"
if D7S = 1 then MyReturnMsg = MyReturnMsg & "<p>OUTLET_7 is OFF</p>" else MyReturnMsg = MyReturnMsg & "<p>OUTLET_7 is ON</p>"
if D8S = 1 then MyReturnMsg = MyReturnMsg & "<p>OUTLET_8 is OFF</p>" else MyReturnMsg = MyReturnMsg & "<p>OUTLET_8 is ON</p>"
return
From what I can see there is very little change... But in order to make the changes one must know what the needed changes are to make things operational and example is a great way to learn we learn from them every day.