I'm working on a thing and I need something to register every other second..
This code doesn't seem to be working...
Code:
IF (TIMER MOD 2) = 0 THEN
'Do the stuff I want
END IF
Any suggestions?
I will give out source code on request but i'd prefer to keep it disclosed...
Oz~
Two methods:
Code:
DEFINT A-Z
CLS
Trigger = 0
DO
IF TIMER AND 1 THEN
IF NOT Trigger THEN
PRINT "Trigger"
Trigger = NOT Trigger
END IF
ELSE
IF Trigger THEN Trigger = NOT Trigger
END IF
LOOP WHILE INKEY$ = ""
END
Code:
CLS
ON TIMER(2) GOSUB Trigger
TIMER ON
DO
LOOP WHILE INKEY$ = ""
END
Trigger:
PRINT "Trigger"
RETURN
I think this works.
[syntax="QBASIC"]t = timer
if timer - t => 1 then
'bla
end if[/syntax]
Any reason why my code doesn't work?
Whitetiger0990, Your code is the most easy adaptable and quickest to the extent of my knowledge
I'm trying to minimize variables, but i'll just static one in the sub it uses...
Oz~
Well, TIMER is a floating-point value, so maybe try using INT(TIMER) in place of TIMER in your original code. However, as Plasma pointed out, x MOD 2 = 0 can be replaced with x AND 1 = 1, etc.
Hmmmmmm....there is some kinda glitch...the code for the timer isn't being registered....
here is how it looks....
Code:
SUB Gui.TextBox (info AS TextBoxType)
'TYPE TextBoxType
' selected AS INTEGER
' cursor as INTEGER
' x AS INTEGER
' y AS INTEGER
' length AS INTEGER
' height AS INTEGER
' text AS STRING * 150
'END TYPE
DIM t AS SINGLE
Future.BOX info.x - 2, info.y - 2, info.x + info.length + 2, info.y + info.height + 2, Black&
Gui.Outline info.x + 1, info.y + 1, info.x + info.length + 1, info.y + info.height + 1, lGrey&, dGrey&
Future.FILLBOX info.x, info.y, info.x + info.length, info.y + info.height, White&
IF TIMER - t >= 1 OR t = 0 THEN
t = TIMER
info.cursor = info.cursor AND 1
END IF
IF info.cursor THEN
dx% = info.x + ((LEN(info.text) + 1) * 8) + 5
Future.Line dx%, info.y + 1, dx%, info.y + info.height - 1, Black&, -1
END IF
Gui.Print info.text, info.x, info.y, Black&
END SUB
Obviously with future lib and a few routines that im not going to include, coz this should just be a look and fix problem...
Oz~
nevermind...i found the problem
i had to do LEN(LTRIM$(RTRIM$(info.text)))
hehehe
:oops:
Oz~