;Uses DDE to get ProgMan to divluge contents of groups and builds
;CmdPost and File Commander menu items to match
CancelCmd="goto cancelbuild"
startpm = 0
OldWinTitle=WinName()
WinTitle("","Prog Build Initializing")
f=0
Pause("Progman Capture","This menu item will rebuild this menu file%cr%with the current contents of ProgMan groups.%cr%It does take a few minutes, so be patient.")
ProgWho=""
If stricmp("FileCmdr",param2)==0 then ProgWho="FC"
then OldWinTitle="File Manager"
If stricmp("CmdPost",param2)==0 then ProgWho="CP"
Terminate(ProgWho=="","ProgBuild Menu Error","Param2 not CP or FC")
LSP=""
if ProgWho=="CP" then newcpm = "cmdgroup.cpm"
then LSP=" "
if ProgWho=="FC" then newcpm = "wwwfc4.mnu"
n=FileLocate(newcpm)
if n=="" then newcpm=strcat(DirWindows(0),newcpm)
else newcpm=n
channel = DDEInitiate("Progman", "Progman")
If channel != 0 Then Goto DDEOK
; Hmmm DDE not working. Check for Progman
If WinExist("Program Manager") then Goto TRY2
If !FileExist("progman.exe") then Message("ProgMan Capture","Cannot find PROGMAN.EXE")
then goto cancelbuild
RunHide("progman.exe", "")
startpm=1
:TRY2
channel = DDEInitiate("Progman", "Progman")
If channel == 0 Then Goto ddeerror
:DDEOK
groups = DDERequest(channel, "Groups")
If groups == "***NACK***" Then Goto ddeerror
groups = StrReplace(groups, cr, tab)
groups = ItemSort(groups, tab)
f = FileOpen(newcpm, "WRITE")
if ProgWho=="CP" then FileWrite(f,"&Groups")
then FileWrite(f," Rebuild Menu from ProgMan Grps")
then FileWrite(f,' Call("wwwmenus.dll","PROGBUILD %%IniSection%%")')
if ProgWho=="FC" then FileWrite(f,"Rebuild Menu from ProgMan Grps")
then FileWrite(f,' Call("wwwmenus.dll","PROGBUILD %%IniSection%%")')
n = ItemCount(groups, tab)
i = 0
:nextgroup
i = i + 1
group = strtrim(ItemExtract(i, groups, tab))
If group == "" Then Goto DODANEXTONE
If group=="Quick Access" then goto DODANEXTONE
FirstItem=0
if i==1 then GroupTitle=strcat(LSP,"_",group)
then goto notfirstgrp
if ((i mod 18) == 1) then GroupTitle=strcat(LSP,"|",group)
if ComPort=="ASK" then XPort=AskLine("Phone Book","Enter modem COM port.%CR%If you have problems dialing, verify%CR%COM port setting in Windows Control Panel","COM1")
if XPort=="" then exit
if XPort!=ComPort then IniWritePvt("FileCmdr","PhonePort",Xport,"WWW-PROD.INI")
then ComPort=XPort
DialPrefix="ATDT"
HangCommand="ATH0"
; And here we go. First make a CR/LF and a TAB
CR=strcat(num2char(13),num2char(10))
TAB=num2char(9)
; Use Home Directory
DirChange(DirHome())
; Make sure there is a fonebook.txt file
if !FileExist("FONEBOOK.TXT") then fp=FileOpen("FONEBOOK.TXT","WRITE")
then FileWrite(fp,"Emergency Services 911")
then FileWrite(fp,"Directory Assistance 1-555-1212")
then FileClose(fp)
; Put up the TextBox so the user can choose a number
:NewNum
FBCancelCmd="Exit" ; What to do if user hits "Cancel"
OldFont=IntControl(28,1,0,0,0) ;Select fixed pitch font for textbox
num=StrTrim(TextBoxSort("DIALER - Just hit OK to add a new number","fonebook.txt"))
IntControl(28,OldFont,0,0,0)
if num!="" then goto zorkle
num=strtrim(AskLine("DIALER","Enter name and number as in%CR%(Don't put any spaces in the number)","Joe Blough 1-555-1212"))