

; Version information  DO NOT REMOVE THIS LINE  Version [[[ 44181 ]]]
; This is a common WIL script file for the WinBatch Studio
         cancelcmd="exit"
         GoTo %PARAM1%

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
:BUTTONMACRO                                               ; From ?
; we get here via a line like
; Call("WSHELP.DLL", "BUTTONMACRO 1")  Add a goto label to jump to
; a specific section
; e.g.
;       goto butmac%param2%
;      :butmac1
;          code here
;          return
;      :butmac2
;           code here
;          return
         Message("Sample Macro","You called user macro number %param2%")
         Exit


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
:KEYWORDHELP                                               ; From ?

;First do some initialization and grab the word help is desired for.
         cancelcmd="goto KWHDONE"                          ; Setup cancel processing - clear variables.
         helpword = wEdGetWord()                           ; Get Selected word.
         If IniReadPvt("Keywords",helpword,"",StrCat(DirHome(),"wil.clr"))=="" ; A known command?
            ; No, assume cursor is right of opening (.
            wLeft()                                        ; Hop over...
            wLeft()                                        ; (.
            helpword = wEdGetWord()                        ; Select possible word...
            wRight()                                       ; And...
            wRight()                                       ; Reposition cursor.
         EndIf                                             ; Helpword=="".
         If helpword==""
            helpword=AskLine("Help!","Enter command for syntax/help information","Type keyword here")
         EndIf                                             ; Helpword=="".

         If helpword==""  then Message("WinBatch Studio Help Error","Cursor must be on a word to use this function.")
                          then GOTO KEYDONE       ;Sleazy goto

; Quick Help routine  only for Keyword Lookup
            If IniReadPvt("HelpInfo","quick",0,"www-prod.ini")==1 ; Quick help wanted?
               If stricmp(IniReadPvt("HelpInfo","Status","","www-prod.ini"),helpword)==0 ; Second call for same command?
                  IniWritePvt("HelpInfo","Status","","www-prod.ini") ; Start again.
                Else                                       ; ! IniReadPvt("HelpInfo","Status","","www-prod.ini")==StrLower(Helpword).
                  IniWritePvt("HelpInfo","Status",helpword,"www-prod.ini") ; First time for command.
                  qck_wspopupmnu=FileGet(StrCat(DirHome(),"wspopup.mnu"))
                  popline=StrSub(qck_wspopupmnu,StrIndexNc(qck_wspopupmnu,StrCat("^",helpword,"^"),1,@Fwdscan),500) ; Get the menu title line plus some.
                  popline=StrSub(popline,1,StrIndex(popline,@Cr,1,@Fwdscan)-1) ; Get menu title line only.
                  If popline<>"" 
                     popline2=ItemExtract(2,popline,"^")
                     popline3=ItemExtract(3,popline,"^")
                     popline4=ItemExtract(4,popline,"^")
                     wStatusMsg(StrCat("  ",popline2,popline3," ; ",popline4)) ; Command and info feedback via status bar.
                  endif
                  drop(qck_wspopupmnu,popline,popline2,popline3,popline4)

                  Exit
               EndIf                                       ; IniReadPvt("HelpInfo","Status","","www-prod.ini")==StrLower(Helpword).
            EndIf                                          ; IniReadPvt("HelpInfo","quick",0,"www-prod.ini")==1.
; End of Quick Help routine

:REMOTEKEYWORDHELP   ; From default.wbt "WinBatch Navigator"
   ; Locate our WSHELP.INI file and determine help file list to process
            wedir = DirHome()
            wedirupone=FilePath ( strsub(wedir,1,strlen(wedir)-1   ) )
            inifile = StrCat(wedir, "HELP\WSHELP.INI")
            If FileExist(inifile)==@False Then inifile=FileLocate("WSHELP.INI")
            if rtstatus() == 10 then filext = FileExtension(wGetFileName())
            else filext="WBT"
            If filext == "" Then filext = "NONE"           ; Section for files w/no extension.
            helpsec = IniReadPvt("EXTENSIONS", filext, "DEFAULT", inifile)
            hfnum = 0

            AllWEHFiles=strlower(FileItemPath(FilePath(inifile):"*.weh"))
            AllWEHCount=ItemCount(AllWEHFiles,@tab)

            ; Get the next help file from the list, and from entire list of weh files next

            For hfnum=1 To 1000
               ffound=0
               wehinfo = StrUpper(IniReadPvt(helpsec, "HF%HFnum%", "NONE", inifile))
               If wehinfo == "NONE"
                   if AllWEHCount > 0
                     wehinfo=ItemExtract(1,AllWEHFiles,@tab) : 2 ; its probably an old help file skulking around
                     AllWEHFiles=ItemRemove(wehremfile,AllWEHFiles,@tab)
                     AllWEHCount=AllWEHCount-1
                   else
                     Message(StrCat("WinBatch Studio Help Error - ",helpword), "No applicable help files found.") ; <<<<<<.
                     Break
                  endif
               EndIf                                       ; Wehinfo == "NONE".
               If wehinfo == "" Then Continue              ; Empty HFx setting, skip.

       ; Extract and build information from the HFx setting
               hfr2=StrIndex(wehinfo," ",0,@Backscan)
               helpfilei=StrSub(wehinfo,1,hfr2-1)          ; Long File Name Fix.
               wehfile = StrCat(wedir, "HELP\",FileRoot(helpfilei), ".WEH")
               If FileExist(wehfile)==@False Then wehfile=FileLocate(StrCat(FileRoot(helpfilei),".WEH"))
               wehtype=StrSub(wehinfo,hfr2+1,-1)   ; might be altered laters

       ; Make sure we have a WEH file someplace

               wehremfile=ItemLocate(strlower(wehfile),AllWEHFiles,@tab)
               if wehremfile!=0
                  AllWEHFiles=ItemRemove(wehremfile,AllWEHFiles,@tab)
                  AllWEHCount=AllWEHCount-1
               endif
               If !(FileExist(wehfile)) Then Continue      ; Skip missing help file

       ; Read Keyword data from WEH file
               wehdata=IniReadPvt("KEYWORDS",helpword,"",wehfile)
               If wehdata == "" Then Continue              ; No keyword defined, try next file.
               ffound=1
       ;WEH file located.  See if WEH file contains search hints.
               helpfile2=IniReadPvt("LOOKUP","Consolidated","",wehfile)
               if helpfile2=="" then helpfile2=IniReadPvt("LOOKUP","Located","",wehfile)
               helpfile2=FileLocate(helpfile2)

               If !FileExist(helpfile2)

                  helpfile2=helpfilei                      ; Then test actual ini setting.
                  If !FileExist(helpfile2)
                     ffound=0
                     While 1
                        If WinMetrics(-2)==2               ; 32 bit platform.
                           hintname=IniReadPvt("LOOKUP","ALTLONG","",wehfile)
                           hintreg=IniReadPvt("LOOKUP","REG32","",wehfile)
                           If hintname!="" Then GoSub HLPSRCH ; Line 194
                           If ffound==1 Then Break

                           hintname=IniReadPvt("LOOKUP","ALTSHORT","",wehfile)
                           If hintname!="" Then GoSub HLPSRCH ; Line 194
                           If ffound==1 Then Break
                        EndIf                              ; WinMetrics(-2)==2.

                        hintname=IniReadPvt("LOOKUP","ALTSHORT","",wehfile)
                        hintreg=IniReadPvt("LOOKUP","REG16","",wehfile)
                        If hintname!="" Then GoSub HLPSRCH ; Line 194
                        If ffound==1 Then Break
                        hintname=StrCat(FileRoot(helpfilei),'.',FileExtension(helpfilei))
                        hintreg=""
                        GoSub HLPSRCH                      ; Line 194
                        Break
                     EndWhile                              ; Random searching.
                     If ffound==0
             ; Give up and ask user....what a concept...
                        While 1
                           helpfile2=helpfile              ; Ask user.
                           cancelcmd="goto HELPCAN23"
                           helpfile2=AskFileName("Please locate %HelpFile%","","Help Files (*.CHM *.HLP)|*.CHM;*.HLP|",helpfile2,1)
                           cancelcmd="exit"
                ; Verify we can access help file user entered
                           If FileExist(helpfile2)
                              ffound=1
                              Break
                           EndIf                           ; FileExist(Helpfile2).

                ; If cancelled, remove reference to help file from WSHELP.INI
:HELPCAN23                                                 ; From ?
                           a=AskYesNo(helpfile2,"Do you wish to remove %HelpFile% from the help file search?")
                           If a==@Yes  Then IniWritePvt(helpsec,"HF%HFnum%","",inifile)
                           Break

                        EndWhile                           ; Asking user.
                     EndIf                                 ; Asking user.
                  EndIf                                    ; Raw ini setting.
                  if ffound==1                     
                     IniWritePvt("LOOKUP","Located",FileLocate(helpfile2),wehfile) ; Save in weh file for next time.
                  endif
               EndIf                                       ; File not located in weh hint.


               If ffound==0 Then Continue
               Break                                       ; Done.  break out of next file for loop.
            Next                                           ; Next HFx for loop.
            If ffound==1
               Switch wehtype

                Case 1
                  wehdata=StrReplace(wehdata,"~",StrCat(Num2Char(13),Num2Char(10)))
                  Message(helpword,wehdata)
                  Break

                Case 2   ; hlp files
                Case 4   ; chm files
                  If StrLower(helpword)=="intcontrol"      ; Special compound command? <<<<<<<.
                     wWordLeft()                           ; Put cursor at start `intcontrol`. <<<<.
                     wEdStartSel()                         ; Activate selection.
                     wEdEnd()                              ; Highlight rest of line.
                     wEdEndSel()                           ; Mark end of selection.
                     helpword2=wEdGetWord()                ; Pick up selected data.
                     wEdClearSel()                         ; Clear selection.
                     helpword2=ItemExtract(1,StrSub(StrTrim(helpword2),11,-1),",") ; Isolate number.
                     helpword2=StrTrim(ItemExtract(2,helpword2,"("))
                     If IsInt(helpword2) Then helpword=StrCat(helpword," ",helpword2) ; Set up `intcontrol xx` if integer.
                  EndIf                                    ; StrLower(Helpword)=="intcontrol".
                  helpfile3=strreplace(strlower(helpfile2),".hlp",".chm")
                  if FileExist(helpfile3)
                     helpfile2=helpfile3
                     wehtype=4
                  else
                     helpfile3=strreplace(strlower(helpfile2),".chm",".hlp")
                     if FileExist(helpfile3)
                        helpfile2=helpfile3
                        wehtype=2
                     endif
                  endif
                  if wehtype==2 then WinHelp(helpfile2,"PARTIALKEY",helpword)
                  if wehtype==4 then ShellExecute('WILHH.EXE', '"':helpfile2:'" "':helpword:'" $global_main' , '', @NORMAL, "") 

                  Break

                Case 3
                  ErrorMode(@Off)
                  RunZoom(helpfile2,helpword)
                  ErrorMode(@Cancel)
                  If LastError()==1902 Then Message("WinBatch Studio Help Error","Help for >%helpword%< not available.")
                  Break


                Case 100
           ; Put your HelpFileType 100 stuff here
                  Message("WinBatch Studio User Help - %HelpFile2%","Help for %helpword% goes here")
                  Break
               End Switch                                  ; Wehtype.
         EndIf                                             ; From initial check for cusror on word.
:KWHDONE                                                   ; From ?
; Drop variables to save memory space
         Drop(helpword,wedir,inifile,filext,helpsec,hintdir,hintname,ffound)
         Drop(wehinfo,helpfilei,wehfile,wehtype,wehdata,helpfile,helpfile2)

         Exit

:HLPSRCH                                                   ; From 104 108 114 118
         hintdir=""
         ErrorMode(@Off)
         If hintreg!="" Then hintdir=RegQueryValue(@regMachine,hintreg)
         ErrorMode(@Cancel)
         If hintdir==0 Then hintdir=""
         helpfile2= StrCat(hintdir,hintname)
         If !FileExist(helpfile2)
      ; First of all, completely ignore path to help file specified and
      ; look in  help directory FIRST!
            helpfile=hintname
            helpfile2=StrCat(DirHome(),"HELP\%HelpFile%")  ; Look in HELP dir first.
            If !FileExist(helpfile2)
         ; Remove directory, and let Windows search path
               helpfile2=helpfile                          ; Try local dir and path.
               If !FileExist(helpfile2)
            ; Check editor home dir just in case path search bypassed it
                  helpfile2=WEDir : HelpFile            ; Check editor dir.
                  If !FileExist(helpfile2)
                     helpfile2=WEDirupone : Helpfile
                     if !(FileExist(helpfile2)) then return ; eeek.  We're giving up here
                  endif
               EndIf                                       ; !FileExist(Helpfile2).
            EndIf                                          ; !FileExist(Helpfile2).
         EndIf                                             ; !FileExist(Helpfile2).
         ffound=1
         Return

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
:DLGCALLBACK

      ;=========================
      ; Inspired by Jim Taylor
      ; by MW Jan 2003

    #DefineFunction AlignComment(statement,comment)
       if strlen(statement)<60 then statement=strfix(statement," ",60)
       return(strcat(statement,comment))
    #EndFunction

    cancelcmd="Exit"                          ; Setup cancel processing

    JobList="IN FC SC CO FO SO"
    JobType=param2    ;IN FC SC CO FO CO
    If ItemLocate(JobType,JobList," ") == 0
       Message("Create Callbacks Error","%JobType% is an invalid JobType")
       gosub CLEANUP_DLGCALLBACK
       exit
    endif

    if JobType=="IN"
        gosub DoDialogHelp
        gosub CLEANUP_DLGCALLBACK
        exit
    endif

    cmtline=StrCat(";",StrFill("=",60),@CrLf)
    cmtline=StrCat(cmtline,cmtline,cmtline)
    redline=StrCat('"',StrFill("<X>--^!---",100),'"',@CrLf)
    redline=StrCat(redline,redline,redline)



    ;sort out the job.  Part 1.  Do we need to generate the constants
    if JobType=="FC" || JobType=="SC" || Jobtype=="CO"   
       Gosub DoDialogConstants
       if JobType=="CO" 
          Clipput(strcat(cmtline,x,@CRLF))      ; write constants to clipboard
          Drop(x)
          gosub CLEANUP_DLGCALLBACK
          exit
       endif
    else
       x=""   ; no constants
    endif

    DlgObjID=1000
    DlgObjIncrement=1000

    ;at this point only FC SC FO and CO are coming thru here

    a = wGetSelState() ;!!!!!!!!!!!!!!!! CHANGE BACK !!!!!!!!!!!!!!!!!!!!!!!!
    If a != 1
         Message("Dialog Callback Creator","Instructions%@crlf%To use this menu item, hilight an entire dialog%@CRLF%then choose this menu item to place a%@crlf%Dialog Callback Procedure on the clipboard.")
         gosub CLEANUP_DLGCALLBACK
         Exit
    EndIf                              ; A != 1.
    wCopy()
    wClearSel()
    controls="PUSHBUTTON RADIOBUTTON CHECKBOX PICTUREBUTTON EDITBOX MULTILINEBOX SPINNER DROPLISTBOX FILELISTBOX ITEMBOX CALENDAR COMCONTROL MENUITEM REPORTVIEW"
    controlscount=ItemCount(controls," ")
    messages="MSG_BUTTONPUSHED MSG_RADIOPUSHED MSG_CHECKBOX MSG_BUTTONPUSHED MSG_EDITBOX MSG_EDITBOX MSG_SPINNER MSG_COMBOCHANGE MSG_FILESELECT MSG_ITEMSELECT MSG_CALENDAR MSG_COMEVENT MSG_MENUITEM|MSG_MENUITEMINIT MSG_RVITEMSELROW|MSG_RVDBLCLICKROW|MSG_RVCHECKEDITEM|MSG_RVITEMTEXT|MSG_RVHEADER"
    thedialog=ClipGet()
    thedialog=StrReplace(thedialog,",PICTUREBUTTON,",",PUSHBUTTON,")
    thedialog=StrReplace(thedialog,",MULTILINEBOX,",",EDITBOX,")

    keyword = "WWWDLGED," 
    ptr=StrIndexNc(thedialog,keyword,0,@Fwdscan)
    If ptr==0
         Message("Dialog Callback Creator","Instructions%@crlf%To use this menu item, hilight an entire dialog%@CRLF%then choose this menu item to place a%@crlf%Dialog Callback Procedure on the clipboard.")
         gosub CLEANUP_DLGCALLBACK
         Exit
    EndIf ; Ptr==0.

    ;Figure out dialog name
    ptra=StrIndex(thedialog,@Lf,ptr,@Backscan)
    If ptra==0 Then ptra=1
    Else ptra=ptra+1
    ptrb=StrIndexNc(thedialog,"format",ptra,@Fwdscan)
    dlgvar=StrSub(thedialog,ptra,ptrb-ptra)

    ;Figure out dialog format   ;ADDED 20081109 DRF
    ptra = ptr+StrLen(keyword)
    ptrb=StrIndex(thedialog,@cr,ptra,@Fwdscan)-1
    format = StrSub(thedialog, ptra, ptrb-ptra)
    ;Pause("Format", format)


    ;Define first line of callback
    theproc=Strcat(cmtline,@crlf,x,@CRLF,@CRLF)

     if JobType=="FC" || JobType=="FO"
        if format == '6.1' ; Old way
           theproc=StrCat(theProc,@crlf,"#DefineFunction ",dlgvar,"CallbackProc(",dlgvar,"_Handle,",dlgvar,"_Message,",dlgvar,"_ID,",dlgvar,"_EventInfo, rsvd)")
        else  
           theproc=StrCat(theProc,@crlf,"#DefineFunction ",dlgvar,"CallbackProc(",dlgvar,"_Handle,",dlgvar,"_Message,",dlgvar,"_Name,",dlgvar,"_EventInfo,",dlgvar,"_ChangeInfo)")  ;FIXED
		  endif
		  theproc=strcat(theproc,@crlf,AlignComment("    InitDialogConstants()","; Initialize Dialog Constants"))
     else  ; Its a subroutine
	     theproc=strcat(theproc,@crlf,AlignComment("InitDialogConstants()","; Initialize Dialog Constants (need only be done once usually)"),@CRLF)
		  if format == '6.1' ; Old way
				theproc=StrCat(theProc,@crlf,"#DefineSubroutine ",dlgvar,"CallbackProc(",dlgvar,"_Handle,",dlgvar,"_Message,",dlgvar,"_ID,",dlgvar,"_EventInfo, rsvd)")
		  else  
				theproc=StrCat(theProc,@crlf,"#DefineSubroutine ",dlgvar,"CallbackProc(",dlgvar,"_Handle,",dlgvar,"_Message,",dlgvar,"_Name,",dlgvar,"_EventInfo,",dlgvar,"_ChangeInfo)")  ;FIXED
		  endif
     endif
    Drop(x)

	 if format == '6.2'
	    theproc=StrCat(theproc,@CrLf,AlignComment("   ON_EQUAL = @TRUE","; Initialize variable ON_EQUAL"))  ;FIXED
	 endif

    ;Start the big switch
    theproc=StrCat(theproc,@CrLf,AlignComment(strcat("   switch ",dlgvar,"_Message"),"; Switch based on Dialog Message type"))


    ;Add in the init case
    ;-------------------------------------------------------------------------------------------------------------------------------
    theproc=StrCat(theproc,@CrLf,AlignComment("      case MSG_INIT","; Standard Initialization message"))
    theproc=StrCat(theproc,@CrLf,";         DialogProcOptions(",dlgvar,"_Handle,MSG_TIMER,1000)")
    ;theproc=StrCat(theproc,@CrLf,";         DialogProcOptions(",dlgvar,"_Handle,MSG_RESIZE,1)")  ;Commented out to reduce end user confusion
    ;Stuff in other DialogProcOptions
    For xx=1 To controlscount
         thiscontrol=ItemExtract(xx,controls," ")
         If StrIndex(thedialog,StrCat(',',thiscontrol,','),0,@Fwdscan) && thiscontrol !="COMCONTROL"
              thismessage=ItemExtract(ItemLocate(thiscontrol,controls," "),messages," ")          
              ; Check if Control Supports multiple messages 2012 DRF
              If StrIndexNC( thismessage, "|", 1, @Fwdscan ) !=0
                 damsgcount = ItemCount(thismessage,"|")
                 For mm= 1 to damsgcount
                   damsg = ItemExtract(mm,thismessage,"|")
                   theproc=StrCat(theproc,@CrLf,";         DialogProcOptions(",dlgvar,"_Handle,",damsg,",@TRUE)")
                 Next
              Else
                   theproc=StrCat(theproc,@CrLf,";         DialogProcOptions(",dlgvar,"_Handle,",thismessage,",@TRUE)")
              Endif
         EndIf                         ; StrIndex(TheDialog,strcat(',',thiscontrol,','),0,@fwdscan) !=0.
    Next                               ; Xx=1 to ControlsCount.

    ;Now toss in the required DialogObjects 
    ;-------------------------------------------------------------------------------------------------------------------------------
         thiscontrol="COMCONTROL"
         ptr=0
         while @TRUE
			    ptr=StrIndexNc(thedialog,StrCat(',',thiscontrol,','),ptr,@Fwdscan)
	             if ptr==0 then break
			     if format == "6.1"
	              xxptr=StrIndexNC(thedialog,Strcat(@LF,dlgvar),ptr,@BackScan)+1
	              thisid=StrSub(thedialog,  xxptr+StrLen(dlgvar),3)
	              thisxxline=Strsub( thedialog, xxptr, StrIndexNC(thedialog, @LF, ptr+1,@FWDSCAN) - xxptr )
	              thisxxline=StrReplace(StrReplace(thisxxline,@CR,""),@LF,"")
	              thisxxline=ItemExtract(2,thisxxline,"`")
	              thisxxtext=strcat (ItemExtractCSV(6,thisxxline,0,",")," ",ItemExtractCSV(7,thisxxline,0,","))
	              thisxxtext=StrTrim(StrReplace(thisxxtext,"DEFAULT",""))
	             ; Pause("%xx%   %thisid%",thisxxline)
	              theproc=StrCat(theproc,@CrLf,";         DialogObject(",dlgvar,"_Handle,",thisid,',DLGOBJECT_ADDEVENT,"ComEventName",',DlgObjID,")")
	              DlgObjID=DlgObjID+DlgObjIncrement
	              ptr=ptr+1
				  else
				     ;Format 6.2
				  	  beginptr=StrIndexNC(thedialog,Strcat(@LF,dlgvar),ptr,@BackScan)+1
					  ptr=StrIndexNC(thedialog,',',ptr+1,@FwdScan)+1
 					  xxptr=StrIndexNC(thedialog,',',ptr,@FwdScan)
					  thisid=StrSub(thedialog,  ptr, xxptr - ptr)
	              thisxxline=Strsub( thedialog, beginptr, StrIndexNC(thedialog, @LF, ptr+1,@FWDSCAN) - beginptr )
	              thisxxline=StrReplace(StrReplace(thisxxline,@CR,""),@LF,"")
	              thisxxline=ItemExtract(2,thisxxline,"`")
	              thisxxtext=strcat (ItemExtractCSV(6,thisxxline,0,",")," ",ItemExtractCSV(7,thisxxline,0,","))
	              thisxxtext=StrTrim(StrReplace(thisxxtext,"DEFAULT",""))
	             ; Pause("%xx%   %thisid%",thisxxline)
	              theproc=StrCat(theproc,@CrLf,";         DialogObject(",dlgvar,"_Handle,",thisid,',DLGOBJECT_ADDEVENT,"ComEventName",',DlgObjID,")")
	              DlgObjID=DlgObjID+DlgObjIncrement
	              ptr=ptr+1
				  endif
         endwhile                         ; Ptr !=0.

    ;-------------------------------------------------------------------------------------------------------------------------------


    theproc=StrCat(theproc,@CrLf,"         return(RET_DO_DEFAULT)")
    theproc=StrCat(theproc,@CrLf,"")


    ;Now do cases here
    ;-------------------------------------------------------------------------------------------------------------------------------
    For xx=1 To controlscount
         thiscontrol=ItemExtract(xx,controls," ")
         thismessage=ItemExtract(ItemLocate(thiscontrol,controls," "),messages," ")  
         ; HACK: only Create procedure for first message
         If StrIndexNC( thismessage, "|", 1, @Fwdscan ) !=0
            thismessage = ItemExtract( 1, thismessage, "|" )
         Endif
         ptr=StrIndexNc(thedialog,StrCat(',',thiscontrol,','),0,@Fwdscan)
         If  ptr !=0
			     ;--------------------------------------
				  ;Format 6.1
				  ;--------------------------------------
			     if Format == "6.1"
	              xxptr=StrIndexNC(thedialog,Strcat(@LF,dlgvar),ptr,@BackScan)+1
	              thisid=StrSub(thedialog,  xxptr+StrLen(dlgvar),3)
	              thisxxline=Strsub( thedialog, xxptr, StrIndexNC(thedialog, @LF, ptr+1,@FWDSCAN) - xxptr )
	              thisxxline=StrReplace(StrReplace(thisxxline,@CR,""),@LF,"")
	              thisxxline=ItemExtract(2,thisxxline,"`")
	              thisxxtext=strcat (ItemExtractCSV(6,thisxxline,0,",")," ",ItemExtractCSV(7,thisxxline,0,","))
	              thisxxtext=StrTrim(StrReplace(thisxxtext,"DEFAULT",""))
	             ; Pause("%xx%   %thisid%",thisxxline)
	              ;is there more than one control of this type?
	              ptra=StrIndexNc(thedialog,StrCat(',',thiscontrol,','),ptr+1,@Fwdscan)
	              If ptra==0
	                   theproc=StrCat(theproc,@CrLf,AlignComment(strcat(";     case ",thismessage),strcat("; ID ",thisid,"  ",thisxxtext)))
	                 Else                  ; ! ptra==0.
	                   theproc=StrCat(theproc,@CrLf,";     case ",thismessage)
	                   theproc=StrCat(theproc,@CrLf,";        switch ",dlgvar,"_ID")
	                   theproc=StrCat(theproc,@CrLf,AlignComment(strcat(";           case ",thisid),strcat("; ID ",thisid,"  ",thisxxtext)))
	                   theproc=StrCat(theproc,@CrLf,";              return(RET_DO_DEFAULT)",@CrLf)
	                   While ptra!=0
	                   
	                        xxptr=StrIndexNC(thedialog,Strcat(@LF,dlgvar),ptra,@BackScan)+1
	                        thisid=StrSub(thedialog,  xxptr+StrLen(dlgvar),3)
	                        thisxxline=Strsub( thedialog, xxptr, StrIndexNC(thedialog, @LF, ptra+1,@FWDSCAN) - xxptr )
	                        thisxxline=StrReplace(StrReplace(thisxxline,@CR,""),@LF,"")
	                        thisxxline=ItemExtract(2,thisxxline,"`")
	                        thisxxtext=strcat (ItemExtractCSV(6,thisxxline,0,",")," ",ItemExtractCSV(7,thisxxline,0,","))
	                        thisxxtext=StrTrim(StrReplace(thisxxtext,"DEFAULT",""))
	                   
	                        theproc=StrCat(theproc,@CrLf,AlignComment(strcat(";           case ",thisid),strcat("; ID ",thisid,"  ",thisxxtext)))
	                        theproc=StrCat(theproc,@CrLf,";              return(RET_DO_DEFAULT)",@CrLf)
	                        ptra=StrIndex(thedialog,StrCat(',',thiscontrol,','),ptra+1,@Fwdscan)
	                 ;Pause("TheProc",Theproc)
	                   EndWhile            ; Ptra!=0.
	                   theproc=StrCat(theproc,@CrLf,AlignComment(";        endswitch",strcat("; ",dlgvar,"_ID")))
	              EndIf                    ; Ptra==0.
	              theproc=StrCat(theproc,@CrLf,";        return(RET_DO_DEFAULT)",@CrLf)
					Else
					   ;--------------------------------------
						;Format 6.2
						;--------------------------------------
						beginptr=StrIndexNC(thedialog,Strcat(@LF,dlgvar),ptr,@BackScan)+1  ;Get pointer to beginning of line
						;thisid=StrSub(thedialog,  xxptr+StrLen(dlgvar),3)
						;search forward to control name
						ptr=StrIndexNC(thedialog,',',ptr+1,@FwdScan)+1
 					   commaptr=StrIndexNC(thedialog,',',ptr,@FwdScan)
						thisid=StrSub(thedialog,  ptr, commaptr - ptr)
						endptr =  StrIndexNC(thedialog, @LF, ptr+1,@FWDSCAN)
						thisxxline=Strsub( thedialog, beginptr, endptr - beginptr )
						thisxxline=StrReplace(StrReplace(thisxxline,@CR,""),@LF,"")
						thisxxline=ItemExtract(2,thisxxline,"`")
						thisxxtext=strcat (ItemExtractCSV(7,thisxxline,0,",")," ",ItemExtractCSV(8,thisxxline,0,","))  ;FIXED
						thisxxtext=StrTrim(StrReplace(thisxxtext,"DEFAULT",""))
			         ; Pause(thisid,thisxxtext)
						;is there more than one control of this type?
						ptra=StrIndexNc(thedialog,StrCat(',',thiscontrol,','),endptr+1,@Fwdscan)
						If ptra==0
						    theproc=StrCat(theproc,@CrLf,AlignComment(strcat(";     case ",thismessage),strcat("; ID ",thisid,"  ",thisxxtext)))
						Else                  ; ! ptra==0.
						    theproc=StrCat(theproc,@CrLf,";     case ",thismessage)
						    theproc=StrCat(theproc,@CrLf,AlignComment(strcat(";        if ",dlgvar,"_Name == ",thisid),strcat("; ", thisxxtext))) 	;FIXED
						    theproc=StrCat(theproc,@CrLf,";              return(RET_DO_DEFAULT)",@CrLf)
						    While ptra!=0
						    
						         beginptr=StrIndexNC(thedialog,Strcat(@LF,dlgvar),ptra,@BackScan)+1
						         ;search forward to control name
									ptra=StrIndexNC(thedialog,',',ptra+1,@FwdScan)+1
			 					   commaptr=StrIndexNC(thedialog,',',ptra,@FwdScan)
									thisid=StrSub(thedialog,  ptra, commaptr - ptra)
						         thisxxline=Strsub( thedialog, beginptr, StrIndexNC(thedialog, @LF, ptra+1,@FWDSCAN) - beginptr )
						         thisxxline=StrReplace(StrReplace(thisxxline,@CR,""),@LF,"")
						         thisxxline=ItemExtract(2,thisxxline,"`")
						         thisxxtext=strcat (ItemExtractCSV(7,thisxxline,0,",")," ",ItemExtractCSV(8,thisxxline,0,",")) ;FIXED
						         thisxxtext=StrTrim(StrReplace(thisxxtext,"DEFAULT",""))
						    
						         theproc=StrCat(theproc,@CrLf,AlignComment(strcat(";        elseif ",dlgvar,"_Name == ",thisid),strcat("; ", thisxxtext)))          ;FIXED
						         theproc=StrCat(theproc,@CrLf,";              return(RET_DO_DEFAULT)",@CrLf)
						         ptra=StrIndex(thedialog,StrCat(',',thiscontrol,','),ptra+1,@Fwdscan)
						  ;Pause("TheProc",Theproc)
						    EndWhile            ; Ptra!=0.
							 theproc=StrCat(theproc,@CrLf,AlignComment(";        endif",strcat("; ",dlgvar,"_Name")))

						EndIf                    ; Ptra==0.
						theproc=StrCat(theproc,@CrLf,";        return(RET_DO_DEFAULT)",@CrLf)
					Endif
         EndIf                         ; Ptr !=0.
    Next                               ; Xx=1 to ControlsCount.


      ;end big switch
    theproc=StrCat(theproc,@CrLf,AlignComment("   endswitch",strcat("; ",dlgvar,"_Message")))
    theproc=StrCat(theproc,@CrLf,"   return(RET_DO_DEFAULT)")
      ;Define last line of callback
    if JobType=="FC" || JobType=="FO"
        theproc=StrCat(theproc,@CrLf,AlignComment("#EndFunction",  strcat("; End of Dialog Callback ",dlgvar,"CallbackProc")),@CrLf,@CrLf,cmtline)
    else
        theproc=StrCat(theproc,@CrLf,AlignComment("#EndSubroutine",strcat("; End of Dialog Callback ",dlgvar,"CallbackProc")),@CrLf,@CrLf,cmtline)
    endif


    theproc=StrCat(theproc,@CrLf,@CrLf,redline,'"REMEMBER UPDATE ',dlgvar,'Procedure VARIABLE AS BELOW AND DELETE THESE LINES"')
    theproc=StrCat(theproc,@CrLf,dlgvar,"Procedure=`",dlgvar,"CallbackProc`",@CrLf,redline,@CrLf)

    ClipPut(theproc)
    Display(3,"Dialog Callback","Placed on clipboard, so it can be pasted into your script.")
    gosub CLEANUP_DLGCALLBACK
    Exit


:DODIALOGCONSTANTS
    ;define constants subroutine
    x=strcat(@CRLF,@CRLF,@CRLF,"#DefineSubRoutine InitDialogConstants()")
    ;Stuff in some variable definitions
    x=StrCat(x,@CrLf,"   ;DialogprocOptions Constants")
    x=StrCat(x,@CrLf,"   MSG_INIT=0                    ; The one-time initialization")
    x=StrCat(x,@CrLf,"   MSG_TIMER=1                   ; Timer event")
    x=StrCat(x,@CrLf,"   MSG_BUTTONPUSHED=2            ; Pushbutton or Picturebutton")
    x=StrCat(x,@CrLf,"   MSG_RADIOPUSHED=3             ; Radiobutton clicked")
    x=StrCat(x,@CrLf,"   MSG_CHECKBOX=4                ; Checkbox clicked")
    x=StrCat(x,@CrLf,"   MSG_EDITBOX=5                 ; Editbox or Multilinebox")
    x=StrCat(x,@CrLf,"   MSG_FILESELECT=6              ; Filelistbox")
    x=StrCat(x,@CrLf,"   MSG_ITEMSELECT=7              ; Itembox")
    x=StrCat(x,@CrLf,"   MSG_COMBOCHANGE=8             ; Combobox/Droplistbox")
    x=StrCat(x,@CrLf,"   MSG_CALENDAR=9                ; Calendar date change")
    x=StrCat(x,@CrLf,"   MSG_SPINNER=10                ; Spinner number change")
    x=StrCat(x,@CrLf,"   MSG_CLOSEVIA49=11             ; Close clicked (Enabled via DialogProcOptions 1002")
    x=StrCat(x,@CrLf,"   MSG_FILEBOXDOUBLECLICK=12     ; Get double-click message on a FileListBox")
    x=StrCat(x,@CrLf,"   MSG_ITEMBOXDOUBLECLICK=13     ; Get double-click message on an ItemBox")
    x=StrCat(x,@CrLf,"   MSG_COMEVENT=14               ; COMCONTROL Event notification from DialogObject (NOT DialogProcOptions)")
    x=StrCat(x,@CrLf,"   MSG_MENUITEM=15               ; MenuItem selected")
    x=StrCat(x,@CrLf,"   MSG_MENUITEMINIT=16           ; MenuItem initialized")
    x=StrCat(x,@CrLf,"   MSG_RESIZE=17                 ; Dialog resized")
    x=StrCat(x,@CrLf,"   MSG_RVITEMSELROW=18           ; Reportview item select row")
    x=StrCat(x,@CrLf,"   MSG_RVDBLCLICKROW=19          ; Reportview double-click row")
    x=StrCat(x,@CrLf,"   MSG_RVCHECKEDITEM=20          ; Reportview checked/unchecked Item")
    x=StrCat(x,@CrLf,"   MSG_RVITEMTEXT=21             ; Reportview changed text of first column ")
    x=StrCat(x,@CrLf,"   MSG_RVHEADER=22               ; Reportview header clicked ")
    x=StrCat(x,@CrLf)

    x=StrCat(x,@CrLf,"   DPO_DISABLESTATE=1000         ; codes -1=GetSetting 0=EnableDialog 1=DisableDialog")
    x=StrCat(x,@CrLf,"   DPO_CHANGEBACKGROUND=1001     ; -1=Get Current otherise bitmap or color string")
    x=StrCat(x,@CrLf,"   DPO_CHANGESYSMENU=1002        ; -1=Get Current 0=none 1=close 2=close/min 3=close/max 4=close/min/max ")
    x=StrCat(x,@CrLf,"   DPO_CHANGETITLE=1003          ; Set/Get Dialog Title - (-1 to get) ")
    x=StrCat(x,@CrLf,"   DPO_GETNAME=1004              ; Returns the name associated with a control's number. ")
    x=StrCat(x,@CrLf,"   DPO_GETNUMBER=1005            ; Returns the number associated with a control's name. ")
    x=StrCat(x,@CrLf,"   DPO_GETCLIENTAREA=1007        ; Returns a space delimited list of the width and height of the client area.")
    x=StrCat(x,@CrLf)

    x=StrCat(x,@CrLf,"   ;DialogControlState Constants")
    x=StrCat(x,@CrLf,"   DCSTATE_SETFOCUS=1            ; Give Control Focus")
    x=StrCat(x,@CrLf,"   DCSTATE_QUERYSTYLE=2          ; Query control's style")
    x=StrCat(x,@CrLf,"   DCSTATE_ADDSTYLE=3            ; Add control style")
    x=StrCat(x,@CrLf,"   DCSTATE_REMOVESTYLE=4         ; Remove control style")
    x=StrCat(x,@CrLf,"   DCSTATE_GETFOCUS=5            ; Get control that has focus")
    x=StrCat(x,@CrLf,"   DCSTATE_MOVEMOUSEOVER=6       ; Move the mouse over the control")
    x=StrCat(x,@CrLf)

    x=StrCat(x,@CrLf,"   DCSTYLE_DEFAULT=0             ; Set Default Style")
    x=StrCat(x,@CrLf,"   DCSTYLE_INVISIBLE=1           ; Set Control Invisible")
    x=StrCat(x,@CrLf,"   DCSTYLE_DISABLED=2            ; Set Control Disabled")
    x=StrCat(x,@CrLf,"   DCSTYLE_NOUSERDATA=4          ; Note: Setable via DialogControlState function ONLY SPINNER control only")
    x=StrCat(x,@CrLf,"   DCSTYLE_READONLY=8            ; Sets control to read-only (user cannot type in data) EDITBOX MULTILINEBOX SPINNER")
    x=StrCat(x,@CrLf,"   DCSTYLE_PASSWORD=16           ; Sets 'password mode' where only *'s are displayed EDITBOX")
    x=StrCat(x,@CrLf,"   DCSTYLE_DEFAULTBUTTON=32      ; Sets a button as the default button PUSHBUTTON PICTUREBUTTON")
    x=StrCat(x,@CrLf,"   DCSTYLE_DIGITSONLY=64         ; Set edit box to accept digits only EDITMOX MULTILINEBOX")
    x=StrCat(x,@CrLf,"   DCSTYLE_FLAT=128              ; Makes a 'flat' hyperlink-looking button PUSHBUTTON PICTUREBUTTON")
    x=StrCat(x,@CrLf,"   DCSTYLE_NOADJUST=256          ; Turns off auto-height adjustment  ITEMBOX FILELISTBOX")
    x=StrCat(x,@CrLf,"   DCSTYLE_TEXTCENTER=512        ; Center text in control VARYTEXT STATICTEXT")
    x=StrCat(x,@CrLf,"   DCSTYLE_TEXTRIGHT=1024        ; Flush-Right text in control VARYTEXT STATICTEXT")
    x=StrCat(x,@CrLf,"   DCSTYLE_NOSELCURLEFT=2048     ; No selection, cursor left EDITBOX MULTILINEBOX")
    x=StrCat(x,@CrLf,"   DCSTYLE_NOSELCURRIGHT=4096    ; No selection, cursor right EDITBOX MULTILINEBOX")
    x=StrCat(x,@CrLf,"   DCSTYLE_SHIELD=8192           ; Display Security Shield icon on button (Vista only) PUSHBUTTON PICTUREBUTTON")
    x=StrCat(x,@CrLf,"   DCSTYLE_MENUCHECK=32768       ; Adds a check mark to the left of a menu item MENUITEM")
    x=StrCat(x,@CrLf,"   DCSTYLE_MENURADIO=65536       ; Adds a radio button like dot graphic to the left of a menu item MENUITEM")
    x=StrCat(x,@CrLf,"   DCSTYLE_MENUSEP=131072        ; Separator bar graphic MENUITEM")
    x=StrCat(x,@CrLf,"   DCSTYLE_MENUBREAK=262144      ; Column break MENUBAR")
    x=StrCat(x,@CrLf,"   DCSTYLE_NOHEADER=524288       ; No header bar REPORTVIEW")
    x=StrCat(x,@CrLf,"   DCSTYLE_COLHEADER=1048576     ; First row column header REPORTVIEW")
    x=StrCat(x,@CrLf,"   DCSTYLE_GRIDLINES=2097152     ; Grid lines REPORTVIEW")
    x=StrCat(x,@CrLf,"   DCSTYLE_SELONEROW=4194304     ; Only one row can be selected at a time REPORTVIEW")
    x=StrCat(x,@CrLf,"   DCSTYLE_SELALLROW = 8388608   ; Highlight complete row REPORTVIEW")
    x=StrCat(x,@CrLf,"   DCSTYLE_SORTASC=16777216      ; Ascending sort REPORTVIEW")
    x=StrCat(x,@CrLf,"   DCSTYLE_SORTDESC=33554432     ; Descending sort REPORTVIEW ")
    x=StrCat(x,@CrLf,"   DCSTYLE_EDITCOL=67108864      ; Edit first columns text REPORTVIEW")
    x=StrCat(x,@CrLf,"   DCSTYLE_COLCHECKBOX=134217728 ; Add checkbox to first column REPORTVIEW")
    x=StrCat(x,@CrLf,"   DCSTYLE_INSHEADER=268435456   ; Include column header text REPORTVIEW")
    x=StrCat(x,@CrLf)

    x=StrCat(x,@CrLf,"   ;DialogControlSet / DialogControlGet Constants")
    x=StrCat(x,@CrLf,"   DC_CHECKBOX=1             ; CHECKBOX REPORTVIEW")
    x=StrCat(x,@CrLf,"   DC_RADIOBUTTON=2          ; RADIOBUTTON")
    x=StrCat(x,@CrLf,"   DC_EDITBOX=3              ; EDITBOX MULTILINEBOX")
    x=StrCat(x,@CrLf,"   DC_TITLE=4                ; PICTURE RADIOBUTTON CHECKBOX PICTUREBUTTON VARYTEXT STATICTEXT GROUPBOX PUSHBUTTON MENUITEM")
    x=StrCat(x,@CrLf,"   DC_ITEMBOXCONTENTS=5      ; ITEMBOX FILELISTBOX DROPLISTBOX REPORTVIEW")
    x=StrCat(x,@CrLf,"   DC_ITEMBOXSELECT=6        ; ITEMBOX FILELISTBOX DROPLISTBOX REPORTVIEW")
    x=StrCat(x,@CrLf,"   DC_CALENDAR=7             ; CALENDAR")
    x=StrCat(x,@CrLf,"   DC_SPINNER=8              ; SPINNER")
    x=StrCat(x,@CrLf,"   DC_MULTITABSTOPS=9        ; MULTILINEBOX")
    x=StrCat(x,@CrLf,"   DC_ITEMSCROLLPOS=10       ; ITEMBOX FILELISTBOX")
    x=StrCat(x,@CrLf,"   DC_BACKGROUNDCOLOR=11     ; RADIOBUTTON CHECKBOX VARYTEXT STATICTEXT GROUPBOX PUSHBUTTON ITEMBOX FILELISTBOX DROPLISTBOX SPINNER EDITBOX MULTILINEBOX REPORTVIEW")
    x=StrCat(x,@CrLf,"   DC_PICTUREBITMAP=12       ; PICTURE PICTUREBUTTON")
    x=StrCat(x,@CrLf,"   DC_TEXTCOLOR=13           ; RADIOBUTTON CHECKBOX VARYTEXT STATICTEXT GROUPBOX PUSHBUTTON ITEMBOX FILELISTBOX DROPLISTBOX SPINNER EDITBOX MULTILINEBOX REPORTVIEW")
    x=StrCat(x,@CrLf,"   DC_ITEMBOXADD=14          ; ITEMBOX FILELISTBOX DROPLISTBOX REPORTVIEW")
    x=StrCat(x,@CrLf,"   DC_ITEMBOXREMOVE=15       ; ITEMBOX FILELISTBOX DROPLISTBOX REPORTVIEW")
    x=StrCat(x,@CrLf,"   DC_RADIOVALUE=16          ; RADIOBUTTON")
    x=StrCat(x,@CrLf,"   DC_POSITION=17            ; ALL CONTROLS (Except MENUBAR and MENUITEM)")
    x=StrCat(x,@CrLf,"   DC_MENUNAMES=18           ; ALL CONTROLS")
    x=StrCat(x,@CrLf,"   DC_HANDLE=19              ; ALL CONTROLS (Except MENUBAR and MENUITEM)")
    x=StrCat(x,@CrLf,"   DC_RVCOLHEAD=20           ; REPORTVIEW")
    x=StrCat(x,@CrLf,"   DC_RVCOLWIDTH=21          ; REPORTVIEW")
    x=StrCat(x,@CrLf,"   DC_RVADDCOL=22            ; REPORTVIEW")
    x=StrCat(x,@CrLf,"   DC_RVREMOVECOL=23         ; REPORTVIEW")
    x=StrCat(x,@CrLf,"   DC_RVMATCHCOL=24          ; REPORTVIEW")
    x=StrCat(x,@CrLf,"   DC_RVCANCELEDIT=25        ; REPORTVIEW")
    x=StrCat(x,@CrLf,"   DC_RVCHECKEDROWS=26       ; REPORTVIEW")
    x=StrCat(x,@CrLf,"   DC_RVJUSTIFY=27           ; REPORTVIEW")
    x=StrCat(x,@CrLf)
    x=StrCat(x,@CrLf)

    x=StrCat(x,@CrLf,"   ;DialogObject constants")
    x=StrCat(x,@CrLf,"   DLGOBJECT_ADDEVENT=1      ; Call dialog callback when the specified event occurs")
    x=StrCat(x,@CrLf,"   DLGOBJECT_STOPEVENT=2     ; Stop calling dialog callback when an event previously requested with")
    x=StrCat(x,@CrLf,"   DLGOBJECT_GETOBJECT=3     ; Return an object references to the specified control")
    x=StrCat(x,@CrLf,"   DLGOBJECT_GETPICTURE=4    ; Create and return an object reference to a picture object")
    x=StrCat(x,@CrLf)
    x=StrCat(x,@CrLf,"   ;Return code constants")
    x=StrCat(x,@CrLf,"   RET_DO_CANCEL=0           ; Cancels dialog")
    x=StrCat(x,@CrLf,"   RET_DO_DEFAULT= -1        ; Continue with default processing for control")
    x=StrCat(x,@CrLf,"   RET_DO_NOT_EXIT= -2       ; Do not exit the dialog")
    x=StrCat(x,@CrLf,"   return")
    x=StrCat(x,@CrLf,"#EndSubroutine")
    x=StrCat(x,@CrLf,cmtline,@CRLF,@CRLF)


return

:DODIALOGHELP
IntControl(54,"",1,0,0)  ;on top
text='There are several menu Items to generate dialog callbacks.'
text=strcat(text,@crlf,'In order to use them, the steps are:')
text=strcat(text,@crlf)
text=strcat(text,@crlf,'   Create a Dialog using the Dialog Editor.  When done,')
text=strcat(text,@crlf,'   Choose the "File - Save to Clipboard" menu item.')
text=strcat(text,@crlf,'   (Or alternatively, save it to a WDL file using the')
text=strcat(text,@crlf,'   "File - Save menu".)')
text=strcat(text,@crlf)
text=strcat(text,@crlf,'   Then in Winbatch Studio, paste the dialog definition')
text=strcat(text,@crlf,'   code into your script.')
text=strcat(text,@crlf,'   (Or open the WDL file you saved your dialog code in)')
text=strcat(text,@crlf)
text=strcat(text,@crlf,'   Highlight your dialog code, top to bottom, starting with') 
text=strcat(text,@crlf,'   the line similar to..')
text=strcat(text,@crlf,'       MyDialogFormat=`WWWDLGED,6.2`')
text=strcat(text,@crlf,'    all the way down to and including the')
text=strcat(text,@crlf,'       ButtonPushed=Dialog("MyDialog")')
text=strcat(text,@crlf,'    line.')
text=strcat(text,@crlf)
text=strcat(text,@crlf,'   Select the Desired Menu item, and have it build your')
text=strcat(text,@crlf,'   dialog template code.')
text=strcat(text,@crlf)
text=strcat(text,@crlf,'   When it is complete, usually just a second or two, paste')
text=strcat(text,@crlf,'   the generated code into your script, usually above the')
text=strcat(text,@crlf,'   Dialog Definition code.')
text=strcat(text,@crlf)
text=strcat(text,@crlf,'   Locate the line similar to')
text=strcat(text,@crlf,'      MyDialogProcedure=`MyDialogCallbackProc`')
text=strcat(text,@crlf,'   in the area at the bottom of the code you pasted (usually')
text=strcat(text,@crlf,'   a block marked in red), and move it into the corresponding')
text=strcat(text,@crlf,'   line at the top of your Dialog Definition code you made')
text=strcat(text,@crlf,'   with the Dialog Editor.')
text=strcat(text,@crlf)
text=strcat(text,@crlf,'   Now you are done.  At this point you have to uncomment')
text=strcat(text,@crlf,'   desired lines in the generated code and add your own code')
text=strcat(text,@crlf,'   to make the Dialog Callback do what you need.')
text=strcat(text,@crlf)
text=strcat(text,@crlf)
text=strcat(text,@crlf,'The following menu items are available:')
text=strcat(text,@crlf)
text=strcat(text,@crlf,'  Function with Constants')
text=strcat(text,@crlf,'         This selection creates both a InitDialogConstants')
text=strcat(text,@crlf,'         subroutine and a DialogCallBack Function (UDF).')
text=strcat(text,@crlf)
text=strcat(text,@crlf,'  Subroutine with Constants')
text=strcat(text,@crlf,'         This selection creates both a InitDialogConstants')
text=strcat(text,@crlf,'         subroutine and a DialogCallBack Subroutine (UDS).')
text=strcat(text,@crlf)
text=strcat(text,@crlf,'  Constants Only')
text=strcat(text,@crlf,'         This selection only creates a standalone')
text=strcat(text,@crlf,'         InitDialogConstants subroutine, used perhaps')
text=strcat(text,@crlf,'         when too many constants were trimmed out of')
text=strcat(text,@crlf,'         an older subroutine in a fit of optimization.')
text=strcat(text,@crlf)
text=strcat(text,@crlf,'         (No pre-highlighting of code required for this')
text=strcat(text,@crlf,'         item as it does not generate a DialogCallback.)')
text=strcat(text,@crlf)
text=strcat(text,@crlf,'  Function Only')
text=strcat(text,@crlf,'         This selection creates a DialogCallBack function,')
text=strcat(text,@crlf,'         used perhaps when the program already contains')
text=strcat(text,@crlf,'         an InitDialogConstants subroutine.')
text=strcat(text,@crlf)
text=strcat(text,@crlf,'  Subroutine Only')
text=strcat(text,@crlf,'         This selection creates a DialogCallBack subroutine,')
text=strcat(text,@crlf,'         used perhaps when the program already contains')
text=strcat(text,@crlf,'         an InitDialogConstants subroutine.')
text=strcat(text,@crlf)
text=strcat(text,@crlf)
text=strcat(text,@crlf)
text=strcat(text,@crlf,'Functions or Subroutines.  Which one to choose?')
text=strcat(text,@crlf)
text=strcat(text,@crlf,'   Functions')
text=strcat(text,@crlf,'     Used when the DialogCallback controls only the')
text=strcat(text,@crlf,'     dialog and does not need to interact with any other')
text=strcat(text,@crlf,'     parts of the program.')
text=strcat(text,@crlf)
text=strcat(text,@crlf,'   Subroutines')
text=strcat(text,@crlf,'     Used when the DialogCallback needs to access or')
text=strcat(text,@crlf,'     save variables that other parts of the program,')
text=strcat(text,@crlf,'     outside of the DialogCallBack itself, need to')
text=strcat(text,@crlf,'     either initialize or access.')
text=strcat(text,@crlf)

DCMIFormat=`WWWDLGED,6.2`

DCMICaption=`Dialog CallBack Menu Instructions`
DCMIX=1000
DCMIY=1000
DCMIWidth=320
DCMIHeight=126
DCMINumControls=005
DCMIProcedure=`DEFAULT`
DCMIFont=`DEFAULT`
DCMITextColor=`DEFAULT`
DCMIBackground=`DEFAULT,0|0|0`
DCMIConfig=0

DCMI001=`173,105,040,012,PUSHBUTTON,"PUSHBUTTON_1",DEFAULT,"&Ok",1,1,32,"Microsoft Sans Serif|5632|70|34","0|0|0","128|255|255"`
DCMI002=`011,007,054,084,PICTURE,"PICTURE_1",DEFAULT,"Illustration of Howland",DEFAULT,3,DEFAULT,DEFAULT,DEFAULT,"WBOwl.bmp"`
DCMI003=`007,093,058,012,STATICTEXT,"STATIC_1",DEFAULT,"Dialog",DEFAULT,4,512,"Microsoft Sans Serif|8192|70|34","0|255|255",DEFAULT`
DCMI004=`007,105,058,012,STATICTEXT,"STATIC_2",DEFAULT,"Callbacks",DEFAULT,5,512,"Microsoft Sans Serif|8192|70|34","0|255|255",DEFAULT`
DCMI005=`069,005,240,092,MULTILINEBOX,"MULTILINEBOX_1",text,"Multiline edit 1",DEFAULT,2,8,"Microsoft Sans Serif|6144|70|34","0|0|0",DEFAULT`

ButtonPushed=Dialog("DCMI")
IntControl(54,"",0,0,0)  ;NOT on top anymore

return


:CLEANUP_DLGCALLBACK
DROP(a,buttonpushed,cancelcmd,cmtline,controls,controlscount,contrsolscount,dcmi001,dcmi002)
DROP(dcmi003,dcmi004,dcmi005,dcmibackground,dcmicaption,dcmiconfig,dcmifont,dcmiformat,dcmiheight)
DROP(dcminumcontrols,dcmiprocedure,dcmitextcolor,dcmiwidth,dcmix,dcmiy,dlgvar,joblist,jobtype)
DROP(messages,param2,ptr,ptra,ptrb,redline,text,thedialog,theproc,thiscontrol,thisid,thismessage)
DROP(thisxxline,thisxxtext,x,xx,xxptr)
Return



:WBCHARCHART
;*************************************************************************
;** 
;** WBCharChart.wbt
;** Deana Falk, 2006:03:21
;** Displays a dialog with ANSI, Extended ANSI characters and Extended ASCII characters, copies 
;** characters or code values to clipboard
;** 
;** Fixes and Improvements
;** 
;**  08.21.2006 DRF
;**     Fixed decimal to hex conversion.
;**     Fixed button fonts to better display ascii characters.
;**     Fixed problem with null ascii displaying blank hex value 
;***************************************************************************

;; Initialize some variables
XANSIFONT="Microsoft Sans Serif|5325|40|34"
XANSIFONTBIG="Microsoft Sans Serif|13517|40|34"
XASCIIFONT="Terminal|5325|40|65329"
XASCIIFONTBIG="Terminal|13517|40|65329"

TABLEFONT=XANSIFONT
TABLEFONTBIG=XANSIFONTBIG

cDialogINIT = 0
cDialogTIMER = 1
cDialogBUTTON = 2
cDialogRADIO = 3
DCGET_TITLE = 4
DCGET_RADIO = 2
DCSET_REPLACE_TITLE = 4
DCSTATE_NULL = 0
DCSTATE_SET_FOCUS = 1
DCSTATE_ADD_STYLE = 3
DCSTATE_REMOVE_STYLE = 4
DCSTATE_GET_FOCUS   = 5
DCSTYLE_DISABLED = 2

#DefineFunction BaseConvert( value, base )
        b = "UNKNOWN"
        If vartype(value) == 1
           b = ""
           while value>0
             b = strcat(strsub("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",value mod base+1,1), b)
             value = int(value / base)
           endwhile
           if b == "" then b = "0"
        Endif

        If vartype(value) == 2 ;string
           b = 0
           while value > ""
             x = strindex("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",strsub(value,1,1),1,0)
             if x == 0 || x > base then return -1
             b = b * base + (x - 1)
             value = strsub(value, 2, -1)
           endwhile
        Endif
        return b
 #EndFunction


#DefineFunction Dec2Hex( dec )
   IsZero = @TRUE
   str = "0123456789ABCDEF"
   hex = ""
   for x = 7 to 0 by -1
       nibble = (dec >> (x*4)) & 15
       if nibble==0 && IsZero==@TRUE then continue
       IsZero = @FALSE
       hex = StrCat( hex, Strsub( str, nibble+1, 1 ) )
   next
   if hex == "" then hex = 0
   return( hex )
#EndFunction


; Dynamically creates or re-titles buttons - 
#DefineSubRoutine GenerateButtons()
   HighBit = IniReadPvt( 'AsciiChart', 'ChartType', '0', inifile )
   if Highbit!=0 then HighBit=1
   For Column = 1 To 4
      For Row = 0 To 31
         CurCharDec = Row + (Column - 1) * 32 + (HighBit * 128)   ;; ASCII 0-127, or 128 to 255 if HighBit
         CurConCap = Num2Char(CurCharDec)
         SpecialValue = ItemLocate(CurCharDec, SpecialValues, @TAB)      ;; Exceptions
         If SpecialValue then CurConCap = ItemExtract(SpecialValue, SpecialCaptions, @TAB)
         CurConNum = CurCharDec + 19 - (HighBit * 128)
         CurConTab = CurCharDec + 12 - (HighBit * 128)
         CurConRetVal = CurConNum - 12   ;; Current Control number - 18 fixed controls, plus 6 pre-existing button return values
         CurConX = 5 + ((Column - 1) * 30)   ;; Control X coordinate
         CurConY = Row * 9               ;; Control Y coordinate
         If CurConNum < 10 Then CurConDef = StrCat("TABLE00", CurConNum)
         If CurConNum > 9 && CurConNum < 100 Then CurConDef = StrCat("TABLE0", CurConNum)
         If CurConNum > 99 Then CurConDef = StrCat("TABLE", CurConNum)
         If CurCharDec>127 && CurCharDec<160 Then CurConCap = "NA"
         %CurConDef%=`%CurConX%,%CurConY%,016,009,PUSHBUTTON,DEFAULT,"%CurConCap%",%CurConRetVal%,%CurConTab%,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
    
         TABLENumControls = TABLENumControls + 1
      Next Row
   Next Column
   Return (1)
;; End of GenerateButtons
#EndSubRoutine


#DefineSubRoutine TABLE(TABLEHandle, EventCode, ControlNum, res4, res5)
Switch EventCode
   Case cDialogINIT   
      DialogProcOptions(TABLEHandle, cDialogBUTTON, @ON)
      DialogProcOptions(TABLEHandle, cDialogRADIO, @ON)
      DialogProcOptions(TABLEHandle, cDialogTIMER, 1000)   ;; Set Timer for keyboard focus tracking

      DialogControlState(TABLEHandle, 13, DCSTATE_ADD_STYLE, DCSTYLE_DISABLED)   ;; Initially disable buttons   
      DialogControlState(TABLEHandle, 14, DCSTATE_ADD_STYLE, DCSTYLE_DISABLED)      
      DialogControlState(TABLEHandle, 15, DCSTATE_ADD_STYLE, DCSTYLE_DISABLED)      
      DialogControlState(TABLEHandle, 16, DCSTATE_ADD_STYLE, DCSTYLE_DISABLED)      
      DialogControlState(TABLEHandle, 17, DCSTATE_ADD_STYLE, DCSTYLE_DISABLED)      
      CurActiveCon = 14 
      Return -2
      Break


   Case cDialogTIMER
      CurActiveCon = DialogControlState(TABLEHandle, DCSTATE_NULL, DCSTATE_GET_FOCUS, DCSTATE_NULL)
      If CurActiveCon >18
         DialogControlState(TABLEHandle, 13, DCSTATE_REMOVE_STYLE, DCSTYLE_DISABLED)   ;; Enable buttons   
         DialogControlState(TABLEHandle, 14, DCSTATE_REMOVE_STYLE, DCSTYLE_DISABLED)      
         DialogControlState(TABLEHandle, 15, DCSTATE_REMOVE_STYLE, DCSTYLE_DISABLED)      
         DialogControlState(TABLEHandle, 16, DCSTATE_REMOVE_STYLE, DCSTYLE_DISABLED)      
         DialogControlState(TABLEHandle, 17, DCSTATE_REMOVE_STYLE, DCSTYLE_DISABLED)      
         CurCharSelected = DialogControlGet(TABLEHandle, CurActiveCon, DCGET_TITLE)
         CurCharDec = Char2Num(CurCharSelected)
         DialogControlSet(TABLEHandle, 13, DCSET_REPLACE_TITLE, CurCharSelected)
         SpecialCharacter = ItemLocate(CurCharSelected, SpecialCaptions, @TAB)
         If SpecialCharacter
            CurCharDec = ItemExtract(SpecialCharacter, SpecialValues, @TAB)
            CurCharDesc = ItemExtract(SpecialCharacter, SpecialDescriptions, @TAB)
            DialogControlSet(TABLEHandle, 5, DCSET_REPLACE_TITLE, CurCharDesc)
            DialogControlSet(TABLEHandle, 14, DCSET_REPLACE_TITLE, CurCharDec)
            DialogControlSet(TABLEHandle, 15, DCSET_REPLACE_TITLE, Dec2Hex(CurCharDec)) 
            DialogControlSet(TABLEHandle, 16, DCSET_REPLACE_TITLE, BaseConvert(CurCharDec+0,8))
            DialogControlSet(TABLEHandle, 17, DCSET_REPLACE_TITLE, StrCat("&&#", Strfixleft( CurCharDec, 0 , 3)))
         Else
            ;handle undefined cases
            if CurCharSelected == "NA"
               DialogControlSet(TABLEHandle, 5, DCSET_REPLACE_TITLE, "")
               DialogControlSet(TABLEHandle, 14, DCSET_REPLACE_TITLE, "")
               DialogControlSet(TABLEHandle, 15, DCSET_REPLACE_TITLE, "") 
               DialogControlSet(TABLEHandle, 16, DCSET_REPLACE_TITLE, "")
               DialogControlSet(TABLEHandle, 17, DCSET_REPLACE_TITLE, "")
            Else
               DialogControlSet(TABLEHandle, 5, DCSET_REPLACE_TITLE, CurCharSelected)
               DialogControlSet(TABLEHandle, 14, DCSET_REPLACE_TITLE, Char2Num(CurCharSelected))
               DialogControlSet(TABLEHandle, 15, DCSET_REPLACE_TITLE,  Dec2Hex(CurCharDec)) 
               DialogControlSet(TABLEHandle, 16, DCSET_REPLACE_TITLE, BaseConvert(CurCharDec,8))
               DialogControlSet(TABLEHandle, 17, DCSET_REPLACE_TITLE, StrCat("&&#", Strfixleft( CurCharDec, 0 , 3)))
            Endif
         Endif
      Endif
      Return -2

   Case cDialogBUTTON
      Switch ControlNum
         Case 1      ;; Cancel
            Return 0

         Case 13      ;; Copy Character to Clipboard
            ToClip = DialogControlGet(TABLEHandle, 13, DCGET_TITLE)
            SpecialCharacter = ItemLocate(ToClip, SpecialCaptions, @TAB)
            If SpecialCharacter Then ToClip = Num2Char(ItemExtract(SpecialCharacter, SpecialValues, @TAB))         
            ClipPut(ToClip)
            Return -2

         Case 14      ;; Copy Decimal to Clipboard
         Case 15      ;; Copy Hexadecimal to Clipboard
         Case 16      ;; Copy Octal to Clipboard
         Case 17      ;; Copy HTML to Clipboard
            ToClip = DialogControlGet(TABLEHandle, ControlNum, DCGET_TITLE)
            If ControlNum == 17 Then ToClip = StrSub(ToClip, 2, -1)    ;; Strip leading ampersand
            ClipPut(ToClip)
            Return -2
            Break

         Case ControlNum   ;; One of the TABLE Characters
            DialogControlState(TABLEHandle, 13, DCSTATE_REMOVE_STYLE, DCSTYLE_DISABLED)      
            DialogControlState(TABLEHandle, 14, DCSTATE_REMOVE_STYLE, DCSTYLE_DISABLED)      
            DialogControlState(TABLEHandle, 15, DCSTATE_REMOVE_STYLE, DCSTYLE_DISABLED)      
            DialogControlState(TABLEHandle, 16, DCSTATE_REMOVE_STYLE, DCSTYLE_DISABLED)      
            DialogControlState(TABLEHandle, 17, DCSTATE_REMOVE_STYLE, DCSTYLE_DISABLED)      
            CurCharSelected = DialogControlGet(TABLEHandle, ControlNum, DCGET_TITLE)
            CurCharDec = Char2Num(CurCharSelected)
            DialogControlSet(TABLEHandle, 13, DCSET_REPLACE_TITLE, CurCharSelected)
            SpecialCharacter = ItemLocate(CurCharSelected, SpecialCaptions, @TAB)
            If SpecialCharacter
               CurCharDec = ItemExtract(SpecialCharacter, SpecialValues, @TAB)
               CurCharDesc = ItemExtract(SpecialCharacter, SpecialDescriptions, @TAB)
               DialogControlSet(TABLEHandle, 5, DCSET_REPLACE_TITLE, CurCharDesc)
               DialogControlSet(TABLEHandle, 14, DCSET_REPLACE_TITLE, CurCharDec)
               DialogControlSet(TABLEHandle, 15, DCSET_REPLACE_TITLE, Dec2Hex(CurCharDec)) 
               DialogControlSet(TABLEHandle, 16, DCSET_REPLACE_TITLE, BaseConvert(CurCharDec,8))
               DialogControlSet(TABLEHandle, 17, DCSET_REPLACE_TITLE, StrCat("&&#", Strfixleft( CurCharDec, 0 , 3)))
            Else
               ;handle undefined cases
               if CurCharSelected == "NA"
                  DialogControlSet(TABLEHandle, 5, DCSET_REPLACE_TITLE, "")
                  DialogControlSet(TABLEHandle, 14, DCSET_REPLACE_TITLE, "")
                  DialogControlSet(TABLEHandle, 15, DCSET_REPLACE_TITLE, "") 
                  DialogControlSet(TABLEHandle, 16, DCSET_REPLACE_TITLE, "")
                  DialogControlSet(TABLEHandle, 17, DCSET_REPLACE_TITLE, "")
               Else
                  DialogControlSet(TABLEHandle, 5, DCSET_REPLACE_TITLE, CurCharSelected)
                  DialogControlSet(TABLEHandle, 14, DCSET_REPLACE_TITLE, Char2Num(CurCharSelected))
                  DialogControlSet(TABLEHandle, 15, DCSET_REPLACE_TITLE,  Dec2Hex(CurCharDec)) 
                  DialogControlSet(TABLEHandle, 16, DCSET_REPLACE_TITLE, BaseConvert(CurCharDec,8))
                  DialogControlSet(TABLEHandle, 17, DCSET_REPLACE_TITLE, StrCat("&&#", Strfixleft( CurCharDec, 0 , 3)))
               Endif

            
            Endif



          Return -2
          Break
      EndSwitch
      Return -2
      Break

   Case cDialogRADIO
      LowBit = DialogControlGet(TABLEHandle, 2, DCGET_RADIO)   ;; ANSI
      if LowBit
         ;ASCIIFont = 'DEFAULT'
         TABLEFONT=XASCIIFONT
         TABLEFONTBIG=XASCIIFONTBIG
         IniWritePvt( 'AsciiChart', 'ChartType', 0, inifile )
      Endif

      HighBitx = DialogControlGet(TABLEHandle, 3, DCGET_RADIO)   ;; Extended ANSI
      if HighBitx
         TABLEFont = XANSIFONT
         TABLEFONTBIG=XANSIFONTBIG
         IniWritePvt( 'AsciiChart', 'ChartType', 1, inifile )
      Endif
      
      AsciiBit = DialogControlGet(TABLEHandle, 18, DCGET_RADIO)   ;; Extended ASCII
      if AsciiBit
         TABLEFont = XASCIIFONT
         TABLEFONTBIG=XASCIIFONTBIG
         IniWritePvt( 'AsciiChart', 'ChartType', 2, inifile )
      Endif

      Return 999
      Break   

EndSwitch

Return -2
;; End of TABLE Dialog Callback Subroutine
#EndSubRoutine  


inifile = "WWW-PROD.INI"
                                        
SpecialCaptions = "NUL,SOH,STX,ETX,EOT,ENQ,ACK,BEL,BS,TAB,LF,VT,FF,CR,SO,SI,DLE,"
SpecialCaptions = StrCat(SpecialCaptions, "DC1,DC2,DC3,DC4,NAK,SYN,ETB,CAN,EM,SUB,ESC,")
SpecialCaptions = StrCat(SpecialCaptions, "FS,GS,RS,US,SPC,"""",%%,``,DEL")
SpecialDescriptions = "Null,Start of Heading,Start of Text,End of Text,End of Transmission,Enquiry,"
SpecialDescriptions = StrCat(SpecialDescriptions, "Acknowledge,Bell,Backspace,Horizontal Tab,Line Feed,")
SpecialDescriptions = StrCat(SpecialDescriptions, "Vertical Tab,Form Feed,Carriage Return,Shift Out,")
SpecialDescriptions = StrCat(SpecialDescriptions, "Shift In,Data Link Escape,Device Control 1,Device Control 2,")
SpecialDescriptions = StrCat(SpecialDescriptions, "Device Control 3,Device Control 4,Negative Acknowledge,")
SpecialDescriptions = StrCat(SpecialDescriptions, "Synchronous Idle,End of Transmission Block,Cancel,")
SpecialDescriptions = StrCat(SpecialDescriptions, "End of Medium,Substitute,Escape,File Separator,Group Separator,")
SpecialDescriptions = StrCat(SpecialDescriptions, "Record Separator,Unit Separator,Space,Double Quote,Percent,Single Quote,Delete")
SpecialValues = StrCat("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,34,37,96,127,")

SpecialCaptions = StrReplace( SpecialCaptions, ",", @tab )
SpecialDescriptions = StrReplace( SpecialDescriptions, ",", @tab )
SpecialValues = StrReplace( SpecialValues, ",", @tab )

While @True
   ;Check which radio button is selected and re-select it
      ;This is because we have to redisplay the dialog with a different font
      ChartType = IniReadPvt( 'AsciiChart', 'ChartType', 0, inifile )
      Switch ChartType 
         Case 0 ;Low bit ANSI  
            CharSet = 1
            TABLEFONT=XANSIFONT
            TABLEFONTBIG=XANSIFONTBIG
            break
         Case 1 ;High bit ANSI
            CharSet = 2
            TABLEFONT=XANSIFONT
            TABLEFONTBIG=XANSIFONTBIG
            break
         Case 2 ;High bit ASCII
            CharSet = 3
            TABLEFONT=XASCIIFONT
            TABLEFONTBIG=XASCIIFONTBIG
            break
      endswitch
     


      TABLEFormat=`WWWDLGED,6.1`

      TABLECaption=`WB Char Chart`
      TABLEX=9999
      TABLEY=9999
      TABLEWidth=252
      TABLEHeight=291
      TABLENumControls=018
      TABLEProcedure=`TABLE`
      TABLETextColor=`DEFAULT`
      TABLEBackground=`DEFAULT,DEFAULT`
      TABLEConfig=0
      
      TABLE001=`213,271,028,012,PUSHBUTTON,DEFAULT,"Cancel",0,145,DEFAULT,"Microsoft Sans Serif|5325|40|34",DEFAULT,DEFAULT`
      TABLE002=`153,007,084,012,RADIOBUTTON,CharSet,"&ANSI / ASCII Codes (0 - 127)",1,1,DEFAULT,"Microsoft Sans Serif|5325|40|34",DEFAULT,DEFAULT`
      TABLE003=`153,019,094,012,RADIOBUTTON,CharSet,"&Extended ANSI Codes (128 - 255)",2,2,DEFAULT,"Microsoft Sans Serif|5325|40|34",DEFAULT,DEFAULT`
      TABLE004=`185,062,060,026,STATICTEXT,DEFAULT,"Press to copy this character to the clipboard",DEFAULT,3,DEFAULT,"Microsoft Sans Serif|5325|40|34",DEFAULT,DEFAULT`
      TABLE005=`143,100,102,020,STATICTEXT,DEFAULT,DEFAULT,DEFAULT,4,DEFAULT,"Microsoft Sans Serif|5325|40|34",DEFAULT,DEFAULT`
      TABLE006=`143,157,026,012,STATICTEXT,DEFAULT,"Decimal:",DEFAULT,5,DEFAULT,"Microsoft Sans Serif|5325|40|34",DEFAULT,DEFAULT`
      TABLE007=`143,171,026,012,STATICTEXT,DEFAULT,"Hex:",DEFAULT,6,DEFAULT,"Microsoft Sans Serif|5325|40|34",DEFAULT,DEFAULT`
      TABLE008=`143,185,026,012,STATICTEXT,DEFAULT,"Octal:",DEFAULT,7,DEFAULT,"Microsoft Sans Serif|5325|40|34",DEFAULT,DEFAULT`
      TABLE009=`143,199,026,012,STATICTEXT,DEFAULT,"HTML:",DEFAULT,8,DEFAULT,"Microsoft Sans Serif|5325|40|34",DEFAULT,DEFAULT`
      TABLE010=`143,135,074,020,STATICTEXT,DEFAULT,"Press a button below to copy its value to clipboard",DEFAULT,9,DEFAULT,"Microsoft Sans Serif|5325|40|34",DEFAULT,DEFAULT`
      TABLE011=`143,047,044,008,STATICTEXT,DEFAULT,"Selected:",DEFAULT,10,DEFAULT,"Microsoft Sans Serif|5325|40|34",DEFAULT,DEFAULT`
      TABLE012=`183,119,010,010,STATICTEXT,DEFAULT,"or",DEFAULT,11,DEFAULT,"Microsoft Sans Serif|5325|40|34",DEFAULT,DEFAULT`
      TABLE013=`143,059,039,039,PUSHBUTTON,DEFAULT,DEFAULT,2,140,32,"%TABLEFONTBIG%",DEFAULT,DEFAULT`
      TABLE014=`173,155,022,012,PUSHBUTTON,DEFAULT,DEFAULT,3,141,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
      TABLE015=`173,169,022,012,PUSHBUTTON,DEFAULT,DEFAULT,4,142,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
      TABLE016=`173,183,022,012,PUSHBUTTON,DEFAULT,DEFAULT,5,143,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
      TABLE017=`173,197,022,012,PUSHBUTTON,DEFAULT,DEFAULT,6,144,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
      TABLE018=`153,031,104,012,RADIOBUTTON,CharSet,"&Extended ASCII Codes (128 - 255)",3,3,DEFAULT,"Microsoft Sans Serif|5325|40|34",DEFAULT,DEFAULT`

      GenerateButtons()

      ButtonPushed=Dialog("TABLE")

      ;if ButtonPushed == 999 then continue


EndWhile
Return  


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
         Exit                                              ; Put an exit here in case anyone ever drops through to cancel.
          ; Not that we would ever do anything like that ourselves...
:CANCEL                                                    ; From ?
         %cancelcmd%


