Place to put your Basic demos and examples

Moderator: Mmiscool

User avatar
By Mmiscool
#51350 Looks like you need an endif on the line after the serial print. Or put the serial print directly after the then.
User avatar
By lew247
#51351 I just downgraded to V2 in case it was a V3 error but I still cannot get it working there with the same simple 3 line program

Is there any way to do this?
It seems anything to do with IF = THEN just won't work

Even this will not work
DO
IF TIME(SEC) == 0 THEN ' I also tried IF TIME(SEC) = 0 THEN
PRINT TIME
END IF
LOOP

I've tried so many variables but cannot get = to work
User avatar
By Mmiscool
#51364 The time function will return a string. You need to turn it to a value to compare.

If Val(time("sec")) = 1 then print "good" else print "bad"
User avatar
By lew247
#51366 If Val(time("sec")) = 1 then print "good" else print "bad" works

However I cannot find a way to get the program to loop UNTIL Val(time("sec")) = 1

What I'm trying to do - as I couldn't get the serialbranch working is set a timer so the program fetches the weather update at set intervals
I originally wanted it to fetch the update when a serial interrupt with a specific character happened, but it can be done with a timer as well - so it fetches the update say once an hour which "should" be easier to do

I'm using SEC = 1 as a test just until I can get it working then I'll switch it to minutes or hours

THIS WORKS but will not LOOP - as I would expect
Code: Select allDO
A = Val(time("SEC"))
IF A = 40 then print "good" ELSE PRINT "ARGHH"
END IF


However THIS does exactly the same as the above ie it WILL NOT LOOP

Code: Select allDO
A = Val(time("SEC"))
IF A = 40 then print "good" ELSE PRINT "ARGHH"
END IF
LOOP


What am I doing wrong? I just can't seem to get it to do what I want at all
and thank you for your patience with me, it is appreciated