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

Crystal Reports

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

Crystal Report Viewer

 Keywords: Crystal Report Viewer Dialog 

AutoCrystalConfig.wbt
#DefineSubRoutine InitDialogConstants()
   ;DialogprocOptions Constants
   MSG_INIT=0                ; The one-time initialization
   MSG_TIMER=1               ; Timer event
   MSG_BUTTONPUSHED=2        ; Pushbutton or Picturebutton
   MSG_RADIOPUSHED=3         ; Radiobutton clicked
   MSG_CHECKBOX=4            ; Checkbox clicked
   MSG_EDITBOX=5             ; Editbox or Multilinebox
   MSG_FILESELECT=6          ; Filelistbox
   MSG_ITEMSELECT=7          ; Itembox
   MSG_COMBOCHANGE=8         ; Combobox/Droplistbox
   MSG_CALENDAR=9            ; Calendar date change
   MSG_SPINNER=10            ; Spinner number change
   MSG_CLOSEVIA49=11         ; Close clicked (Enabled via DialogProcOptions 1002
   MSG_FILEBOXDOUBLECLICK=12 ; Get double-click message on a FileListBox
   MSG_ITEMBOXDOUBLECLICK=13 ; Get double-click message on an ItemBox
   MSG_COMEVENT=14           ; COMCONTROL Event notification from DialogObject (NOT DialogProcOptions)

   DPO_DISABLESTATE=1000     ; codes -1=GetSetting 0=EnableDialog 1=DisableDialog
   DPO_CHANGEBACKGROUND=1001 ; -1=Get Current otherise bitmap or color string
   DPO_CHANGESYSMENU=1002    ; -1=Get Current 0=none 1=close 2=close/min 3=close/max 4=close/min/max
   DPO_CHANGETITLE=1003      ; Set/Get Dialog Title - (-1 to get)

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

   DCSTYLE_INVISIBLE=1       ; Set Control Invisible
   DCSTYLE_DISABLED=2        ; Set Control Disabled
   DCSTYLE_NOUSERDATA=4      ; Note: Setable via DialogControlState function ONLY SPINNER control only
   DCSTYLE_READONLY=8        ; Sets control to read-only (user cannot type in data) EDITBOX MULTILINEBOX SPINNER
   DCSTYLE_PASSWORD=16       ; Sets 'password mode' where only *'s are displayed EDITBOX
   DCSTYLE_DEFAULTBUTTON=32  ; Sets a button as the default button PUSHBUTTON PICTUREBUTTON
   DCSTYLE_DIGITSONLY=64     ; Set edit box to accept digits only EDITMOX MULTILINEBOX
   DCSTYLE_FLAT=128          ; Makes a 'flat' hyperlink-looking button PUSHBUTTON PICTUREBUTTON
   DCSTYLE_NOADJUST=256      ; Turns off auto-height adjustment  ITEMBOX FILELISTBOX
   DCSTYLE_TEXTCENTER=512    ; Center text in control VARYTEXT STATICTEXT
   DCSTYLE_TEXTRIGHT=1024    ; Flush-Right text in control VARYTEXT STATICTEXT
   DCSTYLE_NOSELCURLEFT=2048 ; No selection, cursor left EDITBOX MULTILINEBOX
   DCSTYLE_NOSELCURRIGHT=4096; No selection, cursor right EDITBOX MULTILINEBOX

   ;DialogControlSet / DialogControlGet Constants
   DC_CHECKBOX=1             ; CHECKBOX
   DC_RADIOBUTTON=2          ; RADIOBUTTON
   DC_EDITBOX=3              ; EDITBOX MULTILINEBOX
   DC_TITLE=4                ; PICTURE RADIOBUTTON CHECKBOX PICTUREBUTTON VARYTEXT STATICTEXT GROUPBOX PUSHBUTTON
   DC_ITEMBOXCONTENTS=5      ; ITEMBOX FILELISTBOX DROPLISTBOX
   DC_ITEMBOXSELECT=6        ; ITEMBOX FILELISTBOX DROPLISTBOX
   DC_CALENDAR=7             ; CALENDAR
   DC_SPINNER=8              ; SPINNER
   DC_MULTITABSTOPS=9        ; MULTILINEBOX
   DC_ITEMSCROLLPOS=10       ; ITEMBOX FILELISTBOX
   DC_BACKGROUNDCOLOR=11     ; RADIOBUTTON CHECKBOX VARYTEXT STATICTEXT GROUPBOX PUSHBUTTON ITEMBOX FILELISTBOX DROPLISTBOX SPINNER EDITBOX MULTILINEBOX
   DC_PICTUREBITMAP=12       ; PICTURE PICTUREBUTTON
   DC_TEXTCOLOR=13           ; RADIOBUTTON CHECKBOX VARYTEXT STATICTEXT GROUPBOX PUSHBUTTON ITEMBOX FIELLISTBOX DROPLISTBOX SPINNER EDITBOX MULTILINEBOX
   DC_ITEMBOXADD=14          ; ITEMBOX FILELISTBOX DROPLISTBOX
   DC_ITEMBOXREMOVE=15       ; ITEMBOX FILELISTBOX DROPLISTBOX
   DC_RADIOVALUE=16          ; RADIOBUTTON


   ;DialogObject constants
   DLGOBJECT_ADDEVENT=1      ; Call dialog callback when the specified event occurs
   DLGOBJECT_STOPEVENT=2     ; Stop calling dialog callback when an event previously requested with
   DLGOBJECT_GETOBJECT=3     ; Return an object references to the specified control
   DLGOBJECT_GETPICTURE=4    ; Create and return an object reference to a picture object

   ;Return code constants
   RET_DO_CANCEL=0           ; Cancels dialog
   RET_DO_DEFAULT= -1        ; Continue with default processing for control
   RET_DO_NOT_EXIT= -2       ; Do not exit the dialog

   Return
#EndSubRoutine


CurrDir = DirGet ( )
INIFile = StrCat(CurrDir,"AutoCrystal.ini")

:Start
New = ""
Fields = ""
ExitCode = ""
If ( FileExist(INIFile) == @FALSE ) Then Goto AddNew


;============================================================


Section=IniItemizePvt("",INIFile)

INIPromptFormat=`WWWDLGED,6.2`

INIPromptCaption=`AutoCrystal Configuration`
INIPromptX=060
INIPromptY=060
INIPromptWidth=092
INIPromptHeight=067
INIPromptNumControls=005
INIPromptProcedure=`DEFAULT`
INIPromptFont=`DEFAULT`
INIPromptTextColor=`DEFAULT`
INIPromptBackground=`DEFAULT,DEFAULT`
INIPromptConfig=0

INIPrompt001=`047,047,036,012,PUSHBUTTON,"PushButton_Quit",DEFAULT,"Quit",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
INIPrompt002=`005,005,036,040,ITEMBOX,"ItemBox",Section,DEFAULT,DEFAULT,30,256,DEFAULT,DEFAULT,DEFAULT`
INIPrompt003=`047,005,036,012,PUSHBUTTON,"PushButton_Edit",DEFAULT,"Edit",2,40,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
INIPrompt004=`047,019,036,012,PUSHBUTTON,"PushButton_Delete",DEFAULT,"Delete",3,50,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
INIPrompt005=`047,033,036,012,PUSHBUTTON,"PushButton_Add",DEFAULT,"Add New",4,60,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("INIPrompt")

Switch ButtonPushed
   Case 2
   Goto ReadINI
   Break
   Case 3
   If Section == "" Then Goto Start
   If Section == "(NONE)" Then Goto Start
   Del = AskYesNo( "Delete %Section%", "Are you sure you want to delete %section%?" )
   If ( Del == @YES ) Then IniDeletePvt(Section,@WHOLESECTION,INIFile)
   Goto Start
   Break
   Case 4
   Goto AddNew
   Break
EndSwitch

Exit

:AddNew
New = 1

;=========== Start Report File Dialog ===========
:FilePrompt
#DefineFunction CrystalProc(DialogHandle,DialogMessage,DialogControlID,param4,param5)
 InitDialogConstants()

 Switch DialogMessage
          Case MSG_INIT
               DialogProcOptions(DialogHandle,MSG_BUTTONPUSHED,@TRUE)
               Break
          Case MSG_BUTTONPUSHED
              Switch DialogControlID
                  Case 003
                     ReportFileName=AskFilename("Choose a FileName", "N:\HEAT\Reports", "Crystal Reports|*.rpt", "*.rpt", 1 )
                     DialogControlSet(DialogHandle,002,DC_EDITBOX,ReportFileName)
                     :CANCEL
                     Return(RET_DO_NOT_EXIT)
               EndSwitch
               Break
   EndSwitch
   Return(RET_DO_DEFAULT)
#EndFunction

CrystalFormat=`WWWDLGED,6.1`

CrystalCaption=`Choose Crystal Report`
CrystalX=060
CrystalY=060
CrystalWidth=242
CrystalHeight=057
CrystalNumControls=005
CrystalProcedure=`CrystalProc`
CrystalFont=`DEFAULT`
CrystalTextColor=`DEFAULT`
CrystalBackground=`DEFAULT,DEFAULT`
CrystalConfig=0

Crystal001=`007,005,042,008,STATICTEXT,DEFAULT,"Report File:",DEFAULT,1,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Crystal002=`007,015,178,014,EDITBOX,report,DEFAULT,DEFAULT,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Crystal003=`195,015,034,014,PUSHBUTTON,DEFAULT,"Browse",2,3,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Crystal004=`151,035,034,014,PUSHBUTTON,DEFAULT,"OK",1,4,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Crystal005=`195,035,034,014,PUSHBUTTON,DEFAULT,"Cancel",0,5,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("Crystal")
;=========== End Report File Dialog ===========

Section = AskLine( "Friendly Report Name", "Name:", report )
IniWritePvt( Section, "Report", report, INIFile )

:ReadINI
If Section == "" Then Goto Start
If Section == "(NONE)" Then Goto Start

Report = IniReadPvt(Section, "Report", "", INIFile)
ExportYN = IniReadPvt(Section, "ExportYN", "", INIFile)
ExportFormatSelected = IniReadPvt(Section, "ExportFormat", "", INIFile)
ExportFile = IniReadPvt(Section, "ExportFile", "", INIFile)
ShowOut = IniReadPvt(Section, "ShowOut", "Yes", INIFile)
ShowOutType = IniReadPvt(Section, "ShowOutType", "Crystal", INIFile)
EmailYN = IniReadPvt(Section, "EmailYN", "", INIFile)
EmailRecipient = IniReadPvt(Section, "EmailRecipient", "", INIFile)
EmailSender = IniReadPvt(Section, "EmailSender", "", INIFile)
EmailSubject = IniReadPvt(Section, "EmailSubject", "", INIFile)
EmailAttach = IniReadPvt(Section, "EmailAttach", "", INIFile)
EmailBody = StrReplace(IniReadPvt(Section, "EmailBody", "", INIFile),"CRLF",@CRLF)

:ReportValues
FieldNum = 1
FieldName1 = ""
FieldName2 = ""
FieldName3 = ""
FieldName4 = ""
FieldName5 = ""
FieldName6 = ""
FieldName7 = ""

CrystalReportApp = ObjectCreate("CrystalRuntime.Application")

  CrystalReport = CrystalReportApp.OpenReport(report)
    CrystalReport.DiscardSavedData()
    CrystalReport.EnableParameterPrompting() = 0
    CrystalReport.DisplayProgressDialog() = 0
    crpardefs = CrystalReport.ParameterFields
      crpardefs_h = ObjectCollectionOpen(crpardefs)
        While 1
          crpar = ObjectCollectionNext(crpardefs_h)
          If crpar == 0 Then Break
            FieldName%FieldNum% = StrClean( crpar.name, "{?} ","",@FALSE,1)
            FieldNum = FieldNum + 1
            crpar = ""
        EndWhile
      crpardefs_h = ""
    crpardefs  = ""
  CrystalReport = ""
CrystalReportApp = ""
FieldNum = FieldNum - 1

If FieldName1 == "" Then Goto Options

FieldValue1 = IniReadPvt(Section,"FieldName1","",INIFile)
FieldValue2 = IniReadPvt(Section,"FieldName2","",INIFile)
FieldValue3 = IniReadPvt(Section,"FieldName3","",INIFile)
FieldValue4 = IniReadPvt(Section,"FieldName4","",INIFile)
FieldValue5 = IniReadPvt(Section,"FieldName5","",INIFile)
FieldValue6 = IniReadPvt(Section,"FieldName6","",INIFile)
FieldValue7 = IniReadPvt(Section,"FieldName7","",INIFile)

:VariablesDialog
;=========== Start Report Parameters Dialog ===========
ControlNums = ( FieldNum * 2 ) + 3
If ControlNums > 9
ControlsVal = StrCat("0",ControlNums)
Else
ControlsVal = StrCat("00",ControlNums)
EndIf

#DefineSubRoutine VariableProc(DialogHandle, EventCode, ControlName, EventInfo, Res5)
InitDialogConstants()
   Switch(EventCode)
      Case 0
         DialogProcOptions(DialogHandle, 2, 1)
         break;
      Case 2
         If ControlName == "PushButton_Cancel"
            ExitCode = "Cancel"
            Return(RET_DO_DEFAULT)
         EndIf
         If ControlName == "PushButton_OK"
            ExitCode = "OK"
         EndIf
   EndSwitch
   Return(RET_DO_DEFAULT)
#EndSubRoutine

VariableDialogFormat=`WWWDLGED,6.2`

VariableDialogCaption=`Variables - %Section%`
VariableDialogX=060
VariableDialogY=060
VariableDialogWidth=288
VariableDialogHeight=129
VariableDialogNumControls=ControlsVal
VariableDialogProcedure=`VariableProc`
VariableDialogFont=`DEFAULT`
VariableDialogTextColor=`DEFAULT`
VariableDialogBackground=`DEFAULT,DEFAULT`
VariableDialogConfig=0

VariableDialog001=`007,111,036,012,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,1,32,DEFAULT,DEFAULT,DEFAULT`
VariableDialog002=`055,111,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
VariableDialog003=`005,009,022,012,VARYTEXT,"VaryText_1",FieldName1,"Vary 1",DEFAULT,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
VariableDialog004=`033,007,082,012,EDITBOX,"EditBox_1",FieldValue1,DEFAULT,DEFAULT,40,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
VariableDialog005=`127,005,156,090,STATICTEXT,"StaticText_1",DEFAULT,"If the field requires static data, eg. Team Name: ""TCS"", then just enter the value.%@CRLF%However, should you require data such as today's date, or date range calculations, or even multiple values, please enter as follows:%@CRLF%{Today} = Today's date%@CRLF%{Multiple:Value1,Value2,...}=Multiple values, used in repeat reports%@CRLF%{DateCalc:Value}=Date Range calculations. eg. {DateCalc:-5} for ""Start Date"" field, will enter today's date minus 5 days.%@CRLF%{LastMonth:Start/End}=Will set date to 1st or 31st. eg. {LastMonth:Start} will return 2009-06-1 (Assuming this month is 2009-07)%@CRLF%If you select Multiple values, they will automatically be appended to the Export file name chosen in the Report Options screen.",DEFAULT,70,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
VariableDialog006=`005,023,022,012,VARYTEXT,"VaryText_2",FieldName2,"Vary 2",DEFAULT,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
VariableDialog007=`033,021,082,012,EDITBOX,"EditBox_2",FieldValue2,DEFAULT,DEFAULT,40,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
VariableDialog008=`005,037,022,012,VARYTEXT,"VaryText_3",FieldName3,"Vary 3",DEFAULT,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
VariableDialog009=`033,035,082,012,EDITBOX,"EditBox_3",FieldValue3,DEFAULT,DEFAULT,40,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
VariableDialog010=`005,051,022,012,VARYTEXT,"VaryText_4",FieldName4,"Vary 4",DEFAULT,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
VariableDialog011=`033,049,082,012,EDITBOX,"EditBox_4",FieldValue4,DEFAULT,DEFAULT,40,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
VariableDialog012=`005,065,022,012,VARYTEXT,"VaryText_5",FieldName5,"Vary 5",DEFAULT,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
VariableDialog013=`033,063,082,012,EDITBOX,"EditBox_5",FieldValue5,DEFAULT,DEFAULT,40,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
VariableDialog014=`005,079,022,012,VARYTEXT,"VaryText_6",FieldName6,"Vary 6",DEFAULT,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
VariableDialog015=`033,077,082,012,EDITBOX,"EditBox_6",FieldValue6,DEFAULT,DEFAULT,40,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
VariableDialog016=`005,093,018,012,VARYTEXT,"VaryText_7",FieldName7,"Vary 7",DEFAULT,50,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
VariableDialog017=`033,091,082,012,EDITBOX,"EditBox_7",FieldValue7,DEFAULT,DEFAULT,60,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("VariableDialog")
;=========== End Report Parameters Dialog ===========

If ExitCode == "Cancel" Then Goto Start

While FieldNum != 0
If FieldNum == 1 Then IniWritePvt(Section,"FieldName1",FieldValue1,INIFile)
If FieldNum == 2 Then IniWritePvt(Section,"FieldName2",FieldValue2,INIFile)
If FieldNum == 3 Then IniWritePvt(Section,"FieldName3",FieldValue3,INIFile)
If FieldNum == 4 Then IniWritePvt(Section,"FieldName4",FieldValue4,INIFile)
If FieldNum == 5 Then IniWritePvt(Section,"FieldName5",FieldValue5,INIFile)
If FieldNum == 6 Then IniWritePvt(Section,"FieldName6",FieldValue6,INIFile)
If FieldNum == 7 Then IniWritePvt(Section,"FieldName7",FieldValue7,INIFile)
FieldNum = FieldNum - 1
EndWhile

:Options
;=========== Start Ouput Options Dialog ===========
ExportFormat = StrCat("PDF",@TAB,"XLS",@TAB,"HTM",@TAB,"DOC")
ExitCode = ""

#DefineSubRoutine OptionsProc(DialogHandle, EventCode, ControlName, EventInfo, Res5)
InitDialogConstants()
   Switch(EventCode)
      Case MSG_INIT
         If ExportFormatSelected != "" Then DialogControlSet(DialogHandle,"ExportFormat",6,ExportFormatSelected)
         DialogProcOptions(DialogHandle, MSG_BUTTONPUSHED, 1)
         DialogProcOptions(DialogHandle, MSG_RADIOPUSHED, 1)
         DialogProcOptions(DialogHandle, MSG_CHECKBOX, 1)
         If New == "1" Then
            DialogControlState(DialogHandle,"EmailRecipient",3,2)
            DialogControlState(DialogHandle,"EmailSender",3,2)
            DialogControlState(DialogHandle,"EmailSubject",3,2)
            DialogControlState(DialogHandle,"EmailBody",3,2)
            DialogControlState(DialogHandle,"EmailAttach",3,2)
            DialogControlState(DialogHandle,"ShowOutTypeC",3,2)
            DialogControlState(DialogHandle,"ShowOutTypeE",3,2)
            DialogControlState(DialogHandle,"ExportFile",3,2)
            DialogControlState(DialogHandle,"ExportFormat",3,2)
            New = ""
         EndIf
         break;
      Case MSG_BUTTONPUSHED
         If ControlName == "Pushbutton_Cancel"
            ExitCode = "Cancel"
            Return(RET_DO_DEFAULT)
         EndIf
         If ControlName == "Pushbutton_OK"
            ExitCode = "OK"
            Return(RET_DO_DEFAULT)
         EndIf
      Case MSG_RADIOPUSHED
         If ( ControlName == "ShowOutTypeE" ) && ( DialogControlGet( DialogHandle, "ShowOutTypeE", 2 ) == "1" )
            DialogControlSet(DialogHandle,"ExportYN",DC_CHECKBOX,1)
            STYLE = 4
            GoSub ChangeExport
         Return(RET_DO_NOT_EXIT)
         EndIf
      Case MSG_CHECKBOX
         If ControlName == "ExportYN" Then
            If DialogControlGet(DialogHandle,"ExportYN",DC_CHECKBOX) == "1" Then STYLE = 4
            If DialogControlGet(DialogHandle,"ExportYN",DC_CHECKBOX) == "0" Then STYLE = 3
            GoSub ChangeExport
         Return(RET_DO_NOT_EXIT)
         EndIf
         If ( ControlName == "ShowOut" )
            If DialogControlGet(DialogHandle,"ShowOut",DC_CHECKBOX) == "1"
            DialogControlState(DialogHandle,"ShowOutTypeC",DCSTATE_REMOVESTYLE,DCSTYLE_DISABLED)
            DialogControlState(DialogHandle,"ShowOutTypeE",DCSTATE_REMOVESTYLE,DCSTYLE_DISABLED)
            Else
            DialogControlState(DialogHandle,"ShowOutTypeC",DCSTATE_ADDSTYLE,DCSTYLE_DISABLED)
            DialogControlState(DialogHandle,"ShowOutTypeE",DCSTATE_ADDSTYLE,DCSTYLE_DISABLED)
            EndIf
         Return(RET_DO_NOT_EXIT)
         EndIf
         If ( ControlName == "EmailYN" )
            If DialogControlGet(DialogHandle,"EmailYN",1) == "1"
            DialogControlState(DialogHandle,"EmailSender",DCSTATE_REMOVESTYLE,DCSTYLE_DISABLED)
            DialogControlState(DialogHandle,"EmailRecipient",DCSTATE_REMOVESTYLE,DCSTYLE_DISABLED)
            DialogControlState(DialogHandle,"EmailSubject",DCSTATE_REMOVESTYLE,DCSTYLE_DISABLED)
            DialogControlState(DialogHandle,"EmailAttach",DCSTATE_REMOVESTYLE,DCSTYLE_DISABLED)
            DialogControlState(DialogHandle,"EmailBody",DCSTATE_REMOVESTYLE,DCSTYLE_DISABLED)
            Else
            DialogControlState(DialogHandle,"EmailRecipient",DCSTATE_ADDSTYLE,DCSTYLE_DISABLED)
            DialogControlState(DialogHandle,"EmailSender",DCSTATE_ADDSTYLE,DCSTYLE_DISABLED)
            DialogControlState(DialogHandle,"EmailSubject",DCSTATE_ADDSTYLE,DCSTYLE_DISABLED)
            DialogControlState(DialogHandle,"EmailBody",DCSTATE_ADDSTYLE,DCSTYLE_DISABLED)
            DialogControlState(DialogHandle,"EmailAttach",DCSTATE_ADDSTYLE,DCSTYLE_DISABLED)
            EndIf
         Return(RET_DO_NOT_EXIT)
         EndIf
         If ( ControlName == "EmailAttach" ) && ( DialogControlGet(DialogHandle,"EmailAttach",1) == "1" )
            DialogControlSet(DialogHandle,"ExportYN",DC_CHECKBOX,1)
            STYLE = 4
            GoSub ChangeExport
         Return(RET_DO_NOT_EXIT)
         EndIf
    EndSwitch
   Return(RET_DO_DEFAULT)
:ChangeExport
   DialogControlState(DialogHandle,"ExportFile",STYLE,DCSTYLE_DISABLED)
   DialogControlState(DialogHandle,"ExportFormat",STYLE,DCSTYLE_DISABLED)
Return
#EndSubRoutine

OptionsFormat=`WWWDLGED,6.2`

OptionsCaption=`Report Options - %Section%`
OptionsX=060
OptionsY=060
OptionsWidth=206
OptionsHeight=189
OptionsNumControls=023
OptionsProcedure=`OptionsProc`
OptionsFont=`DEFAULT`
OptionsTextColor=`DEFAULT`
OptionsBackground=`DEFAULT,DEFAULT`
OptionsConfig=0

Options001=`153,149,036,012,PUSHBUTTON,"Pushbutton_OK",DEFAULT,"OK",1,1,32,DEFAULT,DEFAULT,DEFAULT`
Options002=`153,165,036,012,PUSHBUTTON,"Pushbutton_Cancel",DEFAULT,"Cancel",0,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Options003=`003,005,044,012,CHECKBOX,"ExportYN",ExportYN,"Export to file?",1,3,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Options004=`009,017,188,042,GROUPBOX,"ExportOptions",DEFAULT,"Export Options",DEFAULT,4,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Options005=`119,061,076,012,CHECKBOX,"ShowOut",ShowOut,"Display Report Output?",1,5,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Options006=`125,073,070,032,GROUPBOX,"DisplayOptions",DEFAULT,"Display Options",DEFAULT,6,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Options007=`129,081,064,012,RADIOBUTTON,"ShowOutTypeC",ShowOutType,"Crystal Report Viewer",1,7,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Options008=`129,091,044,012,RADIOBUTTON,"ShowOutTypeE",ShowOutType,"Exported File",2,8,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Options009=`045,027,134,012,EDITBOX,"ExportFile",ExportFile,DEFAULT,DEFAULT,9,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Options010=`013,027,028,012,STATICTEXT,"FilePath",DEFAULT,"File Path:",DEFAULT,10,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Options011=`045,043,082,048,DROPLISTBOX,"ExportFormat",ExportFormat,DEFAULT,DEFAULT,11,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Options012=`013,043,030,012,STATICTEXT,"FileFormat",DEFAULT,"File Format:",DEFAULT,12,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Options013=`009,073,110,108,GROUPBOX,"EmailOptions",DEFAULT,"Email Options",DEFAULT,13,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Options014=`003,061,044,012,CHECKBOX,"EmailYN",EmailYN,"Send Email?",1,14,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Options015=`037,081,076,012,EDITBOX,"EmailRecipient",EmailRecipient,DEFAULT,DEFAULT,15,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Options016=`013,083,018,008,STATICTEXT,"To",DEFAULT,"To:",DEFAULT,16,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Options017=`013,097,018,008,STATICTEXT,"From",DEFAULT,"From:",DEFAULT,17,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Options018=`037,095,076,012,EDITBOX,"EmailSender",EmailSender,DEFAULT,DEFAULT,15,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Options019=`013,111,020,008,STATICTEXT,"Subject",DEFAULT,"Subject:",DEFAULT,19,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Options020=`037,109,076,012,EDITBOX,"EmailSubject",EmailSubject,DEFAULT,DEFAULT,15,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Options021=`037,167,074,012,CHECKBOX,"EmailAttach",EmailAttach,"Attach Exported Report?",1,21,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Options022=`037,123,076,044,MULTILINEBOX,"EmailBody",EmailBody,DEFAULT,DEFAULT,220,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Options023=`013,123,044,012,STATICTEXT,"Message",DEFAULT,"Message",DEFAULT,230,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("Options")
;=========== End Output Options Dialog ===========

If ( ExitCode == "Cancel") Then Goto Clear

IniWritePvt(Section, "ExportYN", ExportYN, INIFile)
IniWritePvt(Section, "ExportFormat", ExportFormat, INIFile)
IniWritePvt(Section, "ExportFile", ExportFile, INIFile)
IniWritePvt(Section, "EmailYN", EmailYN, INIFile)
IniWritePvt(Section, "EmailRecipient", EmailRecipient, INIFile)
IniWritePvt(Section, "EmailSender", EmailSender, INIFile)
IniWritePvt(Section, "EmailSubject", EmailSubject, INIFile)
IniWritePvt(Section, "EmailBody", StrReplace(EmailBody,@CRLF,"CRLF"), INIFile)
IniWritePvt(Section, "EmailAttach", EmailAttach, INIFile)
IniWritePvt(Section, "ShowOut", ShowOut, INIFile)
IniWritePvt(Section, "ShowOutType", ShowOutType, INIFile)
IniWritePvt("","","",INIFile)

;For a fresh start, clears (almost!) all set variables
:Clear
DropWild ("C*")
DropWild ("D*")
DropWild ("E*")
DropWild ("F*")
DropWild ("inip*")
DropWild ("M*")
DropWild ("O*")
DropWild ("R*")
DropWild ("S*")
DropWild ("V*")

Goto Start


AutoCrystal.wbt

AddExtender("WWPST44I.dll")

CurrDir = DirGet ( )
INIFile = StrCat(CurrDir,"AutoCrystal.ini")
RunIndex = 0
ReRuns = ""
ReRunField = ""
Method = ""
LastDay = ""
LastMonth = ""
LastDay30 = ""
EmailAttachments = ""

If FileExist(INIFile) == @FALSE Then Goto MissingIni
   If Param0 == "1"
   Section = Param0
   Goto Start
EndIf

Section=IniItemizePvt("",INIFile)

:INIPrompt
INIPromptFormat=`WWWDLGED,6.2`

INIPromptCaption=`AutoCrystal`
INIPromptX=060
INIPromptY=060
INIPromptWidth=092
INIPromptHeight=051
INIPromptNumControls=003
INIPromptProcedure=`DEFAULT`
INIPromptFont=`DEFAULT`
INIPromptTextColor=`DEFAULT`
INIPromptBackground=`DEFAULT,DEFAULT`
INIPromptConfig=0

INIPrompt001=`047,031,036,012,PUSHBUTTON,"PushButton_Quit",DEFAULT,"Quit",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
INIPrompt002=`005,005,036,040,ITEMBOX,"ItemBox",Section,DEFAULT,DEFAULT,30,256,DEFAULT,DEFAULT,DEFAULT`
INIPrompt003=`047,005,036,012,PUSHBUTTON,"PushButton_Run",DEFAULT,"Run",2,40,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("INIPrompt")

If ( Section == "" ) Then Goto INIPrompt
:Start

Report = IniReadPvt(Section, "Report", "", INIFile)
ExportYN = IniReadPvt(Section, "ExportYN", "", INIFile)
ExportFormat = IniReadPvt(Section, "ExportFormat", "", INIFile)
ExportFile = IniReadPvt(Section, "ExportFile", "", INIFile)
ShowOut = IniReadPvt(Section, "ShowOut", "Yes", INIFile)
ShowOutType = IniReadPvt(Section, "ShowOutType", "Crystal", INIFile)
EmailYN = IniReadPvt(Section, "EmailYN", "", INIFile)
EmailRecipient = IniReadPvt(Section, "EmailRecipient", "", INIFile)
EmailSender = IniReadPvt(Section, "EmailSender", "", INIFile)
EmailSubject = IniReadPvt(Section, "EmailSubject", "", INIFile)
EmailAttach = IniReadPvt(Section, "EmailAttach", "", INIFile)
EmailBody = StrReplace(IniReadPvt(Section, "EmailBody", "", INIFile),"CRLF",@CRLF)

:Prepare
; ==== Start preparations ====
FieldNum = 1
FieldName1 = ""
FieldName2 = ""
FieldName3 = ""
FieldName4 = ""
FieldName5 = ""
FieldName6 = ""
FieldName7 = ""

CrystalReportApp = ObjectCreate("CrystalRuntime.Application")

  CrystalReport = CrystalReportApp.OpenReport(report)
    CrystalReport.DiscardSavedData()
    CrystalReport.EnableParameterPrompting() = 0
    CrystalReport.DisplayProgressDialog() = 0
    crpardefs = CrystalReport.ParameterFields
      crpardefs_h = ObjectCollectionOpen(crpardefs)
        While 1
          crpar = ObjectCollectionNext(crpardefs_h)
          If crpar == 0 Then Break
            FieldName%FieldNum% = IniReadPvt(Section,"FieldName%FieldNum%","",INIFile)
            FieldNum = FieldNum + 1
            crpar = ""
        EndWhile
      crpardefs_h = ""
    crpardefs = ""
  CrystalReport = ""
CrystalReportApp = ""
Drop (crpar,crpardefs_h,crpardefs,CrystalReport,CrystalReportApp)

FieldNum = FieldNum - 1

For Num = 1 To FieldNum
Value = FieldName%Num%
If StrIndex(Value,"{",0,@FWDSCAN) > 0 Then GoSub Calculation
FieldName%Num% = Value
Next
; ==== End of preparations ====

; ==== Generate the report ====
:ReRun
Loop = 0
RunIndex = RunIndex + 1

CrystalReportApp = ObjectCreate("CrystalRuntime.Application")
CrystalReport = CrystalReportApp.OpenReport(Report)
    CrystalReport.DiscardSavedData()
    crpardefs = CrystalReport.ParameterFields
      crpardefs_h = ObjectCollectionOpen(crpardefs)
        While 1
          crpar = ObjectCollectionNext(crpardefs_h)
          If crpar == 0 Then Break
            TimeDelay(2)
            Loop = Loop + 1
            If ReRunField == "FieldName%Loop%" Then Input = StrCat(Values[RunIndex - 1],"")
            If ReRunField != "FieldName%Loop%" Then Input = FieldName%Loop%
            crpar.SetCurrentValue(Input)
          crpar = ""
        EndWhile
      crpardefs_h = ""
    crpardefs = ""
    If ( ExportYN == "1" ) Then GoSub Export
    If ( ShowOut == "1" ) Then GoSub ShowOut
    If ReRuns != RunIndex
    CrystalReport = ""
    CrystalReportApp = ""
    Drop (crpar,crpardefs_h,crpardefs,CrystalReport,CrystalReportApp)
    Goto ReRun
    EndIf
    If ( EmailYN == "1" ) Then GoSub Email
CrystalReport = ""
CrystalReportApp = ""
Drop (crpar,crpardefs_h,crpardefs,CrystalReport,CrystalReportApp)
Exit

; ==== Complete! ====

:MissingINI
Display(2,"Error","INI File is missing%@CRLF%Please run configuration application")
Exit

; ==== Begin Export Section ====
:Export
    RepExport = CrystalReport.ExportOptions
    RepExport.Reset
    RepExport.DestinationType = 1

    If ( ExportFormat == "PDF" )
          RepExport.FormatType = 31
          RepExport.PDFExportAllPages = 1
    EndIf

    If ( ExportFormat == "XLS" )
          RepExport.FormatType = 29
    EndIf

    If ( ExportFormat == "DOC" )
          RepExport.FormatType = 14
          RepExport.WORDWExportAllPages = 1
    EndIf

    If ( ExportFormat == "HTM" )
          RepExport.FormatType = 32
    EndIf
    If ( StrIndexNC(ExportFile,"{TODAY}",0,@FWDSCAN) > 0 ) Then
    ExportFile = StrReplace ( ExportFile, "{TODAY}", StrReplace( StrSub(TimeYmdHms() ,1,10) ,":","-") )
    EndIf
    If ReRuns != "" Then
       FileName = StrCat(ExportFile,"-",StrClean(Values[RunIndex - 1],"_ ","-",@FALSE,1),".",ExportFormat)
       Else
       FileName = StrCat(ExportFile,".",ExportFormat)
    EndIf
    RepExport.DiskFileName = FileName
    CrystalReport.Export(BOOL:@FALSE)
    RepExport = ""
    Drop(RepExport)
    If ( EmailYN == "1" )
      If EmailAttachments == ""
         EmailAttachments = FileName
         Else
         EmailAttachments = StrCat(EmailAttachments,"|",FileName)
      EndIf
    EndIf

Return
; ==== End Export Section ====

; ==== Begin Show Output Section ====
:ShowOut
If ( ShowOutType == "2" )
    Run(FileName,"")
EndIf

If ( ShowOutType == "1" )
;============================================================

#DefineSubRoutine InitDialogConstants()
   ;DialogprocOptions Constants
   MSG_INIT=0                ; The one-time initialization
   MSG_TIMER=1               ; Timer event
   MSG_BUTTONPUSHED=2        ; Pushbutton or Picturebutton
   MSG_RADIOPUSHED=3         ; Radiobutton clicked
   MSG_CHECKBOX=4            ; Checkbox clicked
   MSG_EDITBOX=5             ; Editbox or Multilinebox
   MSG_FILESELECT=6          ; Filelistbox
   MSG_ITEMSELECT=7          ; Itembox
   MSG_COMBOCHANGE=8         ; Combobox/Droplistbox
   MSG_CALENDAR=9            ; Calendar date change
   MSG_SPINNER=10            ; Spinner number change
   MSG_CLOSEVIA49=11         ; Close clicked (Enabled via DialogProcOptions 1002
   MSG_FILEBOXDOUBLECLICK=12 ; Get double-click message on a FileListBox
   MSG_ITEMBOXDOUBLECLICK=13 ; Get double-click message on an ItemBox
   MSG_COMEVENT=14           ; COMCONTROL Event notification from DialogObject (NOT DialogProcOptions)

   DPO_DISABLESTATE=1000     ; codes -1=GetSetting 0=EnableDialog 1=DisableDialog
   DPO_CHANGEBACKGROUND=1001 ; -1=Get Current otherise bitmap or color string
   DPO_CHANGESYSMENU=1002    ; -1=Get Current 0=none 1=close 2=close/min 3=close/max 4=close/min/max
   DPO_CHANGETITLE=1003      ; Set/Get Dialog Title - (-1 to get)

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

   DCSTYLE_INVISIBLE=1       ; Set Control Invisible
   DCSTYLE_DISABLED=2        ; Set Control Disabled
   DCSTYLE_NOUSERDATA=4      ; Note: Setable via DialogControlState function ONLY SPINNER control only
   DCSTYLE_READONLY=8        ; Sets control to read-only (user cannot type in data) EDITBOX MULTILINEBOX SPINNER
   DCSTYLE_PASSWORD=16       ; Sets 'password mode' where only *'s are displayed EDITBOX
   DCSTYLE_DEFAULTBUTTON=32  ; Sets a button as the default button PUSHBUTTON PICTUREBUTTON
   DCSTYLE_DIGITSONLY=64     ; Set edit box to accept digits only EDITMOX MULTILINEBOX
   DCSTYLE_FLAT=128          ; Makes a 'flat' hyperlink-looking button PUSHBUTTON PICTUREBUTTON
   DCSTYLE_NOADJUST=256      ; Turns off auto-height adjustment  ITEMBOX FILELISTBOX
   DCSTYLE_TEXTCENTER=512    ; Center text in control VARYTEXT STATICTEXT
   DCSTYLE_TEXTRIGHT=1024    ; Flush-Right text in control VARYTEXT STATICTEXT
   DCSTYLE_NOSELCURLEFT=2048 ; No selection, cursor left EDITBOX MULTILINEBOX
   DCSTYLE_NOSELCURRIGHT=4096; No selection, cursor right EDITBOX MULTILINEBOX

   ;DialogControlSet / DialogControlGet Constants
   DC_CHECKBOX=1             ; CHECKBOX
   DC_RADIOBUTTON=2          ; RADIOBUTTON
   DC_EDITBOX=3              ; EDITBOX MULTILINEBOX
   DC_TITLE=4                ; PICTURE RADIOBUTTON CHECKBOX PICTUREBUTTON VARYTEXT STATICTEXT GROUPBOX PUSHBUTTON
   DC_ITEMBOXCONTENTS=5      ; ITEMBOX FILELISTBOX DROPLISTBOX
   DC_ITEMBOXSELECT=6        ; ITEMBOX FILELISTBOX DROPLISTBOX
   DC_CALENDAR=7             ; CALENDAR
   DC_SPINNER=8              ; SPINNER
   DC_MULTITABSTOPS=9        ; MULTILINEBOX
   DC_ITEMSCROLLPOS=10       ; ITEMBOX FILELISTBOX
   DC_BACKGROUNDCOLOR=11     ; RADIOBUTTON CHECKBOX VARYTEXT STATICTEXT GROUPBOX PUSHBUTTON ITEMBOX FILELISTBOX DROPLISTBOX SPINNER EDITBOX MULTILINEBOX
   DC_PICTUREBITMAP=12       ; PICTURE PICTUREBUTTON
   DC_TEXTCOLOR=13           ; RADIOBUTTON CHECKBOX VARYTEXT STATICTEXT GROUPBOX PUSHBUTTON ITEMBOX FIELLISTBOX DROPLISTBOX SPINNER EDITBOX MULTILINEBOX
   DC_ITEMBOXADD=14          ; ITEMBOX FILELISTBOX DROPLISTBOX
   DC_ITEMBOXREMOVE=15       ; ITEMBOX FILELISTBOX DROPLISTBOX
   DC_RADIOVALUE=16          ; RADIOBUTTON


   ;DialogObject constants
   DLGOBJECT_ADDEVENT=1      ; Call dialog callback when the specified event occurs
   DLGOBJECT_STOPEVENT=2     ; Stop calling dialog callback when an event previously requested with
   DLGOBJECT_GETOBJECT=3     ; Return an object references to the specified control
   DLGOBJECT_GETPICTURE=4    ; Create and return an object reference to a picture object

   ;Return code constants
   RET_DO_CANCEL=0           ; Cancels dialog
   RET_DO_DEFAULT= -1        ; Continue with default processing for control
   RET_DO_NOT_EXIT= -2       ; Do not exit the dialog

   Return
#EndSubRoutine
;============================================================

#DefineSubRoutine MyDialogCallbackProc(MyDialog_Handle,MyDialog_Message,MyDialog_Name,MyDialog_EventInfo,rsvd)
   InitDialogConstants()                                    ; Initialize Dialog Constants
   ON_EQUAL = @TRUE                                         ; Initialize variable ON_EQUAL
   Switch MyDialog_Message                                  ; Switch based on Dialog Message type
      Case MSG_INIT                                         ; Standard Initialization message
         DialogObject(MyDialog_Handle, "CrystalCom", DLGOBJECT_ADDEVENT, "DownloadFinished",14)
         DialogProcOptions(MyDialog_Handle,MSG_BUTTONPUSHED,@TRUE)
         CRViewer = DialogObject(MyDialog_Handle, "CrystalCom", DLGOBJECT_GETOBJECT)
         CRViewer.ReportSource = CrystalReport
         CRViewer.ViewReport
         Return(RET_DO_DEFAULT)

     Case MSG_BUTTONPUSHED
        Switch ON_EQUAL
           Case MyDialog_Name == "PushButton_Quit"       ; ID "PushButton_Cancel"  PushButton_Cancel
              If CRViewer.IsBusy == "0" Then Return(RET_DO_CANCEL)
              Return(RET_DO_NOT_EXIT)

        EndSwitch                                          ; MyDialog_Name
        Return(RET_DO_DEFAULT)
     Case MSG_COMEVENT
     DialogControlState( MyDialog_Handle, "PushButton_Quit", DCSTATE_REMOVESTYLE, DCSTYLE_DISABLED)
     Return(RET_DO_DEFAULT)

   EndSwitch                                                ; MyDialog_Message
   Return(RET_DO_DEFAULT)
#EndSubRoutine                                 ; End of Dialog Callback MyDialogCallbackProc

;============================================================

CRVFormat=`WWWDLGED,6.2`

CRVCaption=`Crystal Report Viewer`
CRVX=080
CRVY=058
CRVWidth=400
CRVHeight=300
CRVNumControls=002
CRVProcedure=`MyDialogCallbackProc`
CRVFont=`DEFAULT`
CRVTextColor=`DEFAULT`
CRVBackground=`DEFAULT,DEFAULT`
CRVConfig=0

CRV001=`-3,-1,402,280,COMCONTROL,"CrystalCom",DEFAULT,"CrystalReports.ActiveXReportViewer",DEFAULT,1,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
CRV002=`350,283,040,010,PUSHBUTTON,"PushButton_Quit",DEFAULT,"Quit",2,2,2,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("CRV")

EndIf

Return

; ==== End Show Output Section ====

:Calculation
;============================================================
;Date
If StrIndex(Value,"{Date",0,@FWDSCAN) > 0
   Value = StrClean(Value,"{cdatel:}","",@FALSE,1)
   TodayJul = TimeJulianDay(TimeYmdHms())
   ValueJul = TodayJul %Value%
   Value = StrReplace( StrSub(TimeJulToYmd (ValueJul) ,1,10) ,":","-")
EndIf
;Multiple
If StrIndex(Value,"{Mult",0,@FWDSCAN) > 0
   ReRuns = StrCnt(Value,",",0,StrLen(Value),@FALSE) + 1
   ReRunField = "FieldName%Num%"
   Value=StrReplace(StrReplace(Value,"{Multiple:",""),"}","")
   Values=Arrayize(Value,",")
EndIf
;LastMonth
If StrIndex(Value,"{LastMonth",0,@FWDSCAN) > 0
Method = StrReplace(Value,"{LastMonth:","")
;2009:07
   LastMonth = StrSub( TimeYmdHms(), 6, 2 ) - 1
   If LastMonth == "0" Then LastMonth = "12"
   If LastMonth < 10 Then LastMonth = StrCat("0",LastMonth)
   If Method == "Start}" Then
      Value = StrCat(StrSub(TimeYmdHms(),1,4),"-",LastMonth,"-01"  )
   Else
      LastDay30 = "04,06,09,11"
      If ItemLocate(LastMonth,LastDay30,",") != ""
         LastDay = "30"
      Else
         LastDay = "31"
      EndIf
      If LastMonth == "02" Then LastDay = "28"
      Value = StrCat(StrSub(TimeYmdHms(),1,4),"-",LastMonth,"-",LastDay)
   EndIf
EndIf
;Today
If StrIndex(Value,"{Today",0,@FWDSCAN) > 0
   Value = StrReplace( StrSub(TimeYmdHms() ,1,10) ,":","-")
EndIf
Drop (Method,LastDay,LastMonth,LastDay30,TodayJul,ValueJul)
Return
;============================================================

:Email
;============================================================
If ( EmailAttach == "0" ) Then EmailAttachments = ""
kInit("smtp.uct.ac.za",EmailSender,"","",'')
kDest(EmailRecipient,'','')
kSendText(EmailSubject,EmailBody,EmailAttachments,"")
Return

Article ID:   W18069
Filename:   Crystal Report Viewer.txt
File Created: 2009:07:16:11:25:46
Last Updated: 2009:07:16:11:25:46