Report Bugs Here

Moderator: Mmiscool

User avatar
By kingedem
#52611 Hi Micheal,

I wanted to have multiple return statement in each if condition checks; so that, it wont unnecessarily check all remaining if conditions.
Also, I had to do this because, i was unable to initialize the array variables like this:
=====================================
Dim BeaconArray$(7) as string
BeaconArray$(1) = "nb343434mn854"
BeaconArray$(2) = "nb343434mn667"
BeaconArray$(3) = "nb343434mn565"
BeaconArray$(4) = "nb343434mn454"
======================================
See below subroutine code:
[TimeCompare]

if instr(B1,serData) > 0 then
oldTime = mid(B1,14)
newTime = millis() 'time("hour") & time("min")
'serialprint "val: " & newTime & "-" & oldTime & chr(13) & chr(10)
'serialprint "55555: " & floor(newTime) & "-" & floor(oldTime) & chr(13) & chr(10)
if (floor(newTime) - floor(oldTime)) > 60000 then
B1 = replace(B1,oldTime,str(newTime))
serialprint "TEST: " & B1 & chr(13) & chr(10)
gosub [Boom]
end if
end if
if instr(B2,serData) > 0 then
oldTime = mid(B2,14)
newTime = millis() 'time("hour") & time("min")
if (floor(newTime) - floor(oldTime)) > 60000 then
B2 = replace(B2,oldTime,str(newTime))
serialprint "TEST: " & B2 & chr(13) & chr(10)
gosub [Boom]
end if
end if
if instr(B3,serData) > 0 then
oldTime = mid(B3,14)
newTime = millis() 'time("hour") & time("min")
if (floor(newTime) - floor(oldTime)) > 60000 then
B3 = replace(B3,oldTime,str(newTime))
serialprint "TEST: " & B3 & chr(13) & chr(10)
gosub [Boom]
end if
end if
if instr(B4,serData) > 0 then
oldTime = mid(B4,14)
newTime = millis() 'time("hour") & time("min")
if (floor(newTime) - floor(oldTime)) > 60000 then
B4 = replace(B4,oldTime,str(newTime))
serialprint "TEST: " & B4 & chr(13) & chr(10)
gosub [Boom]
end if
end if
if instr(B5,serData) > 0 then
oldTime = mid(B5,14)
newTime = millis() 'time("hour") & time("min")
if (floor(newTime) - floor(oldTime)) > 60000 then
B5 = replace(B5,oldTime,str(newTime))
serialprint "TEST: " & B5 & chr(13) & chr(10)
gosub [Boom]
end if
end if
if instr(B6,serData) > 0 then
oldTime = mid(B6,14)
newTime = millis() 'time("hour") & time("min")
if (floor(newTime) - floor(oldTime)) > 60000 then
B6 = replace(B6,oldTime,str(newTime))
serialprint "TEST: " & B6 & chr(13) & chr(10)
gosub [Boom]
end if
end if
if instr(B7,serData) > 0 then
oldTime = mid(B7,14)
newTime = millis() 'time("hour") & time("min")
if (floor(newTime) - floor(oldTime)) > 60000 then
B7 = replace(B7,oldTime,str(newTime))
serialprint "TEST: " & B7 & chr(13) & chr(10)
gosub [Boom]
end if
end if
if instr(B8,serData) > 0 then
oldTime = mid(B8,14)
newTime = millis() 'time("hour") & time("min")
if (floor(newTime) - floor(oldTime)) > 60000 then
B8 = replace(B8,oldTime,str(newTime))
serialprint "TEST: " & B8 & chr(13) & chr(10)
gosub [Boom]
end if
end if
if instr(B9,serData) > 0 then
oldTime = mid(B9,14)
newTime = millis() 'time("hour") & time("min")
if (floor(newTime) - floor(oldTime)) > 60000 then
B9 = replace(B9,oldTime,str(newTime))
serialprint "TEST: " & B9 & chr(13) & chr(10)
gosub [Boom]
end if
end if
return