Jump to content

Recommended Posts

Posted

It's been years since I've posted, I think originally when I created my account I had a question about MM Bot. This is my first time doing any real scripting and I must say I'm having a blast. I understood the first basic scripts in the "Examples" folder well enough and have built off of them. For me there seems to be a very large difference between those and the include scripts.

Anyway I'm looking for some advice on how to set a somewhat top level check on the current system time. I'm writing a script that I will be running on a virtual computer 24-7 and I'm thinking the code will look something like this:

Select
Case {CurrentTime 8am - 11am}
  Global $meal = "Breakfast"
Case {CurrentTime 11:01am - 4pm}
  Global $meal = "Lunch"
Case {CurrentTime 4:01pm - 8pm}
  Global $meal = "Dinner"
Case {CurrentTime 8:01pm - 1am}
  Global $meal = "Evening"
Case {CurrentTime 1:01am - 7:59am}
  Global $meal = "Closed"
EndSelect

I just used plain english for the part inbetween "{" & "}" markers to give you an idea of what I'm looking to do. I have looked at some of the time stuff in the help file and the includes and I just can't figure out how to do it.

That's what I'm thinking at this point. Again I'm a newb so if there is something better than Select / Case I welcome advice on that.

  • Moderators
Posted

MrVining,

Well if it has been that long: Welcome back! :)

The @HOUR, @MIN and @SEC macros sound like what you are looking for. But your syntax is more suited to a Switch structure than a Select - take a look in the Help file to see the difference. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

With the snippet of code it would also be advised to declare the variable $meal only once.

Global $vMeal = 0 ; or Local
Switch $vMeal
    Case 0
        ; Do something.
    Case 1
        ; Do something.
    Case Else
        ; Do something.
EndSwitch

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

Wow thank you for all the timely response! I think I'm going to like it here.

For the first time I think I actually wanted to look things up...

Just learned what a 262144 message box is, the @LF AND that you could have a message box time out. =p

Funny that is the one place I have seen so far that uses seconds not milliseconds.

Posted
  Help File said:

Hours value of clock in 24-hour format. Range is 00 to 23

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

There is Local/Global and/or Static. Have a look around the help file and Forum as this has been discussed quite a bit, actually quite recently about variable declaration.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

For completion you'll also find Const (obvious for constants) and Enum (for enumerations) useful. Dim is obsolescent and best avoided but ReDim is something else. Again the help file is your best friend.

  Reveal hidden contents

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Posted

  On 1/10/2013 at 9:39 PM, 'jchd said:

For completion you'll also find Const (obvious for constants) and Enum (for enumerations) useful. Dim is obsolescent and best avoided but ReDim is something else. Again the help file is your best friend.

Don't know why I skipped those. My mistake.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

No, I'm the nitpicker but surely can be nitpicked back.

  Reveal hidden contents

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Posted

; this one-liner is NOT meant good programming practice ;-)
; just to show excessive use of ternary operator (?:) in new version 3.3.9.5 (alpha version)
#AutoIt3Wrapper_Run_AU3Check=n
#AutoIt3Wrapper_AutoIt3=G:\Program Files (x86)\AutoIt3\Beta.3.3.9.5\autoit3.exe ; Change this to your Alpha 3.3.9.5 directory

MsgBox(262144, " ", @HOUR & ":" & @MIN & @LF & @LF & (@HOUR < 01) ? "Evening" :(@HOUR < 08) ? "Closed" :(@HOUR < 11) ? "Breakfast" :(@HOUR < 16) ?"Lunch" :(@HOUR < 20) ?"Dinner" : "Evening", 5)

App: Au3toCmd              UDF: _SingleScript()                             

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...