Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is there a way to access the time and use in IF statement
#1
Hey guys, was just wondering if there is a way I could access the system clock and incorporate it into a "IF, then, else" statement.

I have a macro which I would like to alternate the amount of time In which it repeats a program based on the time of day, what do you reckon would be the best way? .

For example in pseudocode,
rep x until 12 pm rep x until 1 pm and so fourth. Or would i be better of having some kind on on going timer that executes when x amount of time has passed.

_i=Uniform(1 50)
rep _i
For example this code above i would like to run for 3 hours then after x amount of time /time of day change it to

_i=Uniform(50 150)
rep _i

Thank you very much in advance for any ideas or suggestions.
PS, im very new to this so if you could provide an example/code with your replys.
Kind Regards Smile
Paul
#2
So are you wanting a set time or what do you mean?...

Quote:_i=Uniform(1 50)
rep _i
This is going to repeat a random number of times between 1 and 50. I'm not sure exactly whether or not this is what your wanting since I am somewhat confused. But to get the time and date from the clock use this:

Code:
Copy      Help
str s
rep
,s.time("-" "h:mm tt")
,out s
This will put the time and date into the QM Outbox.


I think your wanting to use the code somewhat like this:

Code:
Copy      Help
str s
rep
,s.time("-" "h:mm tt")
,out s
,if s="12:00 AM"
,,mac- "Other Macro"
,30


Please update me and let me know if any of this is kind of what your looking for?
Taking on Quick Macros one day at a time
#3
Code:
Copy      Help
str s
int x
,s.time("-" "H")
if (val(s)>12)
;,out "PM"
,x=3
else
;,out "AM"
,x=6


rep x
,out "QM ROCKS"
#4
Thank you for your time, yes something like this. What I would like to do is
at each hour of the day, choose a different set and range random times my program will loop for. So say for example:

the program starts running at 9 am say.
_i=Uniform(1 10)
rep _i

but when 10 am i want to change the random numbers say to
_i=Uniform(20 30)
rep _i

when 11 am
_i=Uniform(30 40)
rep_i

and so fourth. How could i link that to that time statement.
Thank you very much.
#5
Code:
Copy      Help
;get current date and time
DATE now.getclock
;get time part
int days=now.date; now.date-days
;set variables for times
DATE t9("9:00") t10("10:00") t11("11:00") t12("12:00") ;;and so on
;compare

int x y
if(now>=t9 and now<t10) x=1; y=10
else if(now<t11) x=20; y=30
else if(now<t12) x=30; y=40
;and so on

;run it
rep Uniform(x y)
,out "run program"
,;...
,


Forum Jump:


Users browsing this thread: 1 Guest(s)