PeterAtkin Posted March 8, 2010 Share Posted March 8, 2010 (edited) OK so looks like i missed school a bit as i seem to remember getting these kind of projects to do, only then it was in Ada, which for those that don't know understood fuzzy logic. I'm looking for a fuzzy way to do time, e.g. 00:00 to 06:59 is too dam early 07:00 to 11:59 is morning 12:00 to 17:59 is afternoon 18:00 to 23:50 is evening While I can think of several ways to do it they all seem to involve lots of case or if statements, I have not really fully understood the operators yet == <= >= etc. maybe I could use them more effectively, or would a better way be to use an array? Any pointers would be nice, I don't want to re-invent the wheel if possible. Edited March 8, 2010 by PeterAtkin [topic='115020'] AD Domain Logon Script[/topic] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 8, 2010 Moderators Share Posted March 8, 2010 PeterAtkin, lots of case or if statementsSurely not: Switch @HOUR Case 0 To 6 ConsoleWrite("Too damn early!" & @CRLF) Case 7 To 11 ConsoleWrite("Morning" & @CRLF) Case 12 To 17 ConsoleWrite("Afternoon" & @CRLF) Case Else ConsoleWrite("Evening" & @CRLF) EndSwitch M23 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: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Xenobiologist Posted March 8, 2010 Share Posted March 8, 2010 _TimeToWords("3:45") _TimeToWords("13:15") _TimeToWords("23:05") _TimeToWords("00:05") Func _TimeToWords($time) Switch StringRegExpReplace($time, ':.*', '') Case 00 To 06 ConsoleWrite('is too dam early' & @CRLF) Case 07 To 11 ConsoleWrite('is morning' & @CRLF) Case 12 To 17 ConsoleWrite('is afternoon' & @CRLF) Case 18 To 23 ConsoleWrite('is evening' & @CRLF) EndSwitch EndFunc ;==>_TimeToWords Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Fulano Posted March 8, 2010 Share Posted March 8, 2010 (edited) I'm looking for a fuzzy way to do time, e.g. 00:00 to 06:59 is too dam early 07:00 to 11:59 is morning 12:00 to 17:59 is afternoon 18:00 to 23:50 is evening Only thing I can think of would be something like this: Func fuzzyTime ($Time) If $Time < 7 Then Return "is too early" Elseif $Time < 12 Then Return "is morning" Elseif $Time < 18 Then Return "is afternoon" EndIf Return "is evening" EndFunc Feed @Hour to that and it should return what you are looking for. Edit: Cleaned up the look of the code. Wow, that was a race to be first Edited March 8, 2010 by Fulano #fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja! Link to comment Share on other sites More sharing options...
PeterAtkin Posted March 8, 2010 Author Share Posted March 8, 2010 (edited) Excellent thanks I was really going about this the wrong way.. just so you can have a laugh expandcollapse popuplocal $greeting switch @HOUR Case 1 $greeting = "this is just too early" Case 2 $greeting = "this is just too early" Case 3 $greeting = "this is just too early" Case 4 $greeting = "this is just too early" Case 5 $greeting = "this is just too early" Case 6 $greeting = "this is just too early" Case 7 $greeting = "Good Morning" Case 8 $greeting = "Good Morning" Case 9 $greeting = "Good Morning" Case 10 $greeting = "Good Morning" Case 11 $greeting = "Good Morning" Case 12 $greeting = "Good Afternoon" Case 13 $greeting = "Good Afternoon" Case 14 $greeting = "Good Afternoon" Case 15 $greeting = "Good Afternoon" Case 16 $greeting = "Good Afternoon" Case 17 $greeting = "Good Afternoon" Case 18 $greeting = "Good Afternoon" Case 19 $greeting = "Good Evening" Case 20 $greeting = "Good Evening" Case 21 $greeting = "Good Evening" Case 22 $greeting = "Good Evening" Case 23 $greeting = "This is way too late" Case 00 $greeting = "Goto Bed" EndSwitch _say($greeting & " " & @UserName & " welcome to the Computer Facilities Network, please wait while you are logged onto the system") Func _say($v2t) Local $objVoice = False, $temp $objVoice = ObjCreate("SAPI.SpVoice") $objVoice.Volume = 50 $objVoice.Rate = 0 $objVoice.Speak($v2t, 0) EndFunc ;==>_say And this is the solution I come up with, with your help.$greeting = FuzzyTime() _say($greeting & " " & @UserName & " welcome to the Computer Facilities Network, please wait while you are logged onto the system") Func FuzzyTime() Switch @HOUR Case 0 To 6 Return "is too early" Case 7 To 11 Return "Good Morning" Case 12 To 17 Return "Good Afternoon" Case 18 To 23 Return "Good Evening" Case Else Return "Go to bed" EndSwitch EndFunc Func _say($v2t) Local $objVoice = False, $temp $objVoice = ObjCreate("SAPI.SpVoice") $objVoice.Volume = 50 $objVoice.Rate = 0 $objVoice.Speak($v2t, 0) EndFunc ;==>_say Edited March 8, 2010 by PeterAtkin [topic='115020'] AD Domain Logon Script[/topic] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 8, 2010 Moderators Share Posted March 8, 2010 PeterAtkin, Thanks for that - always nice to get positive feedback (and a good laugh)! M23 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: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
PeterAtkin Posted March 8, 2010 Author Share Posted March 8, 2010 Welcome and thanks to you all again, I really learned allot.. [topic='115020'] AD Domain Logon Script[/topic] Link to comment Share on other sites More sharing options...
dani Posted March 8, 2010 Share Posted March 8, 2010 (edited) As it's a greeting "is too early" doesn't really fit in there. Shouldn't you make it something like "What are you doing here so early, go back to bed!" ? Edited March 8, 2010 by dani Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now