-
Notifications
You must be signed in to change notification settings - Fork 1
/
sample.prg
104 lines (77 loc) · 2.73 KB
/
sample.prg
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
* The reason we have a separate MyApp procedure is if the user chooses Quit, it
* does a RETURN TO MASTER, so the program will terminate.
do MyApp
do ShutDown
procedure MyApp
* Get the "debug" mode setting.
llDebugMode = .F.
* Set up the global error handler. No need to declare it PUBLIC: it'll be
* available in all code called from this main program.
release oError
oError = newobject('SFErrorMgr', 'SFErrorMgr.vcx', '', 'My Application', .T., ;
'oError')
with oError
* If we're in "debug" mode, display a developer's dialog when an error occurs.
if llDebugMode
.lShowDebug = .T.
.cMessageClass = 'SFErrorMessage'
.cMessageLibrary = 'SFErrorMgr.vcx'
endif llDebugMode
* Set properties to customize the behavior.
.cAppName = 'My Application'
.cVersion = '1.0'
.lScreenShot = .T.
&& take a screen shot when an error occurs
* Set the current user's name and email address. These would likely be set once
* the user has logged in. If they aren't set, it isn't a problem because the
* user can specify the values in the error dialog.
.cContact = 'Someone'
.cEmail = 'someone@someaddress.com'
* Get the email settings for the demo. To run this on your machine, put the
* correct settings into these properties.
set library to VFPEncryption71
.cRecipient = 'Put email address of recipient here'
.cSenderEmail = 'Put email address of sender here'
.cMailServer = 'Put address of mail server here'
.nSMTPPort = 'Put port number for mail server here'
.cUserName = 'Put user name for mail server here'
.cPassword = Encrypt('Put password for mail server here', .cUserName)
* Set the localizer settings (these are the defaults but are set here to show
* how to change them).
.cLanguage = 'English'
.cResourceTable = 'Resource.dbf'
endwith
* Display the main form.
do form Sample
* Start the event loop. Note that we use a separate routine rather than an
* inline READ EVENTS statement here; it works better that way because we can
* set the cReturnToOnCancel property of the error object to the name of the
* routine containing the READ EVENTS statement.
do ReadEvents
do ShutDown
procedure ShutDown
* Clean up before we exit (some of this stuff is generic and not actually
* needed in this sample; e.g. we didn't open any tables so don't really need
* CLOSE DATABASES ALL).
clear events
close databases all
try
clear all
catch
endtry
if version(2) = 2
release oError
on shutdown
on error
set path to
clear
else
quit
endif version(2) = 2
* The procedure containing the READ EVENTS statement. We'll set the cReturnToOn
* properties of the error object indicating where to go now that we're in the
* event loop.
procedure ReadEvents
oError.cReturnToOnCancel = 'ReadEvents'
oError.cReturnToOnQuit = 'MASTER'
read events