WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Samples from Users
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Lunch Restaurant Chooser


It's very close to the weekend, when often we take a few minutes to indulge in a pet project... So here's a fun little script I whipped together to solve prolonged discussions about where to eat lunch. Originally, the idea was merely to randomly select a restaurant from a list, but my co-workers and I would end up disliking the outcome and trying again. After about 15 times through the program, someone would usually just make a suggestion that everybody could live with. I decided that the problem was that my program was too wishy-washy, and set out to make it more authoritative. Hence Lunchatron 2000 was born. Attached are Lunchatron 2000 and its accompanying INI file for all your gastronomical decision-making needs.
;*******************************************************************************************************
;** Name:       Lunchatron 2000
;** Author:     Marc Worrel, DTSEP
;** Version:    1.1    
;** Purpose:    To decide where to eat lunch
;** Date:       11/11/2003
;*******************************************************************************************************
;///////////////////////////////////// SPACER TO SEPARATE SECTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Set environmental information and initial variables   |
;-------------------------------------------------------- 
;If IsKeyDown(@SHIFT & @CTRL) Then Debug(@ON) 

IntControl (12,1+4,0,0,0)         ;Suppress OK to close messages
IntControl (49,1,0,0,0)           ;Enables Min/Max/Close Widgets
IntControl (1002,0,0,0,0)         ;Sets display state of WinBatch box
IntControl (1003,0,0,0,0)         ;Prevents WinBatch icon from being opened
IntControl (1008,1,0,0,0)         ;Enables Close command


;*******************************************************************************************************
;///////////////////////////////////// SPACER TO SEPARATE SECTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; UDF's                                                 |
;-------------------------------------------------------- 
;===============================================================================
;+-----STYLE-----------------------+-----ICONS-----------------------+
;| OK               = 0            | STOP      = 16                  |
;| OKCANCEL         = 1            | QUESTION  = 32                  |    
;| ABORTRETRYIGNORE = 2            | EXCLAIM   = 48                  |
;| YESNOCANCEL      = 3            | INFO      = 64                  |   
;| YESNO            = 4            | WINICON   = 4096                |
;| RETRYCANCEL      = 5            |                                 |
;+-----BUTTONS---------------------|----RETURN VALUES----------------|
;| DEFAULTBUTTON1   = 0            | IDOK      = 1                   |
;| DEFAULTBUTTON2   = 256          | IDCANCEL  = 2                   |
;| DEFAULTBUTTON3   = 512          | IDABORT   = 3                   | 
;+---------------------------------| IDRETRY   = 4                   |
;| Combine flags with OR operator: | IDIGNORE  = 5                   |
;|      Flags=4|48|256|4096        | IDYES     = 6                   |
;|                                 | IDNO      = 7                   |
;+---------------------------------+---------------------------------+
#DefineFunction xMsgBox(Caption,Text,Flags)
xMsg=DllCall(StrCat(DirWindows(1),"User32.dll"),long:"MessageBoxA",long:DllHwnd(""),lpstr:Text,lpstr:Caption,long:Flags)
Return (xMsg)
#EndFunction

#DefineSubroutine RndPick (List)
Index=Random(ItemCount(List,@TAB)-1)
Pick=ItemExtract (Index+1,List,@TAB)
;Message ("",StrReplace(List,@TAB,@CRLF))
;List=ItemRemove (Index+1,List,@TAB)
List=StrReplace (List,StrCat(Pick,@TAB),"")
Return (Pick)
#EndSubroutine

#DefineSubroutine DlgCallback (DlgName,DlgEvent,DlgCtrl,Res4,Res5)
If DlgEvent==00                                            ;Dialog initialization 
	Vetoes=3
	DialogControlSet (DlgName,001,4,StrCat("&Veto (",Vetoes,")"))
	DialogControlSet (DlgName,003,4,RndPick(List))
	DialogProcOptions (DlgName,2,1)                         ;Watch for button presses
	;Disables Min/Max/Restore/Close widgets in windows
	hwnd=DllHwnd("Lunchatron 2000")                         ;Window Title of desired window goes here
	sysmenu=DllCall(StrCat(DirWindows(1),"User32.dll"),long:"GetSystemMenu",long:hwnd,long:0)
	DllCall (StrCat(DirWindows(1),"User32.dll"),long:"RemoveMenu",long:sysmenu,long:61488,long:0)   ;Remove maximize from system menu
	OldStyle=DllCall(StrCat(DirWindows(1),"User32.dll"),long:"GetWindowLongA",long:hwnd,long:-16)
	NewStyle=OldStyle & ~65536                              ;Disable Maximize widget
	Result = DllCall(StrCat(DirWindows(1),"User32.dll"),long:"SetWindowLongA",long:hwnd,long:-16,long:NewStyle)
EndIf
If DlgEvent==02                                            ;Button press event
	If DlgCtrl==001
		If Vetoes<1
			xMsgBox ("Request Denied","You are out of vetoes.  You must now obey Lunchatron 2000's judgement.",16)
			Return (-2)
		EndIf
		Vetoes=Vetoes-1 
		DialogControlSet (DlgName,001,4,StrCat("&Veto (",Vetoes,")"))
		DialogControlSet (DlgName,003,4,RndPick(List))
	EndIf
EndIf
Return (-2)                                                ;Return (-1) for normal processing or (-2) for persistant dialog
#EndSubroutine

SrcLst=StrCat(FilePath(IntControl(1004,0,0,0,0)),"L2K.ini")
Low=IniReadPvt ("Places","Low","",SrcLst)
Medium=IniReadPvt ("Places","Medium","",SrcLst)
High=IniReadPvt ("Places","High","",SrcLst)
List=StrReplace (StrCat(High,@TAB,Medium,@TAB,Low,@TAB,High,@TAB,Medium,@TAB,High),";",@TAB)

L2KFormat=`WWWDLGED,6.1`
L2KCaption=`Lunchatron 2000`
L2KX=9999
L2KY=9999
L2KWidth=160
L2KHeight=042
L2KNumControls=003
L2KProcedure=`DlgCallback`
L2KFont=`DEFAULT`
L2KTextColor=`DEFAULT`
L2KBackground=`DEFAULT,DEFAULT`
L2KConfig=0
L2K001=`003,005,034,031,PUSHBUTTON,DEFAULT,Veto,2,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
L2K002=`041,001,114,036,GROUPBOX,DEFAULT,"Today's restaurant:",DEFAULT,3,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
L2K003=`047,013,104,014,STATICTEXT,DEFAULT,"Static 1",DEFAULT,4,512,"Microsoft Sans Serif|9728|40|34","0|0|0",DEFAULT`
ButtonPushed=Dialog("L2K")

Exit


;L2K.INI
[Places]

Low = Arby's/Sabarro's;Applebee's;Bruegger's;Maverick's;Chi-Chi's;Ruby Tuesday;Perkins;Boston Market;Taste of Thailand;Willow Gate II;Olive Garden;Baker's Square;Davanni's
Medium = Subway;Jimmy John's;Kahn's;Chin's;Great China
High = Green Mill;Mama's;Quizno's;Chipotle;Villiage Wok;Noodles && Company;Old Chicago


Article ID:   W16193
File Created: 2004:03:30:15:43:12
Last Updated: 2004:03:30:15:43:12