-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoprat.prg
176 lines (121 loc) · 4.81 KB
/
oprat.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
set talk off
set date british
# calculator area starts
do while .T.
input "$ " to x or accept to s or input to z
IF x = about
?" **********************************************"
?" * made with fun in Foxpro 2.5 *"
?" * name : calc1 v2 *"
?" * developer: Rohit Kumar *"
?" * All tradmarks reserved to its proprietary *"
?" * owner and developers don't try to copy. *"
?" * Ask me i will help *"
?" **********************************************"
?" "
?" "
?" You can now register yourself in this version. It stores your last login time"
?" and date and also your logout time in userdata."
ENDIF
# on exit final time calculation
if x = exit
# Calculating the time elapsed since last login
time2 = time()
timehf = substr(time2,1,2)
timemf = substr(time2,4,2)
timesf = substr(time2,7,2)
ttimef = val(timehf)*3600+val(timemf)*60+val(timesf)
ttime = ttimef-ttimei
if ttime <= 60
? "You elapsed ",ttime,"seconds"
else
if ttime > 60 and ttime < 3600
tm = int(ttime/60)
ts = int(mod(ttime,60))
? "You elapsed ",tm,"min",ts,"sec"
else
if ttime >= 3600
th = int(ttime/3600)
ts = ttime % 3600
if ts >= 60 and ts <= 3600
tm = int(val(ts)/60)
ts = int(mod(val(ts),60))
endif
?"You elapsed",th,"hrs",tm,"min",ts,"sec"
endif
endif
endif
# time calculation finished now exiting process starts
wait window "Thanks for being with us." NOWAIT
repl laslogdate with date(),laslogtime with timei
# close database.dbf and opening userdata.dbf to store user log and delete blank records and then closing all database file before exit
use
use userdata
append blank
repl name with named, logdate with date(),logintime with timei ,logouttime with time2, totaltime with ttime
delete for name = space(20)
pack
close all
exit
else
# calculator operators
do case
case s = 0 + 0
a = x + z
case s = 0 - 0
a = x - z
case s = 1 * 1
a = x * z
case s = 1 / 1
a = x / z
case s = 1 ^ 1
a = x ^ z
endcase
?"$ ",a
endif
if x = clear
clear
# main screen
?" You are logged in as : ",DATABASE.NAME," at",timei,"on", date()
?" "
?" Welcome to calc1, a prototype calculator developed in FoxPro 2.5, inspired by"
?" the Free Software Foundation's command line 'bc calculator'."
?"--------------------------------------------------------------------------------"
endif
# converter code starts
if x = ascii
?" Converter: ASCII <--> character"
?" "
do while .T.
input "Enter ASCII to convert : " to ch
if ch != exit
? "The character is :",chr(ch)
else
EXIT
endif
enddo
endif
# converter code ends
if x = sd
do sd
endif
if x = help
?" type 0 or exit to exit program "
?" type 1 or about to know more about calc1 "
?" type 2 or clear to clear screen "
?" type 3 or ascii to open ascii converter"
?" type 4 or sd to open digit adder of a number "
?" type 5 or help for this window "
endif
# automatic exit
time3 = time()
timehf = substr(time3,1,2)
timemf = substr(time3,4,2)
timesf = substr(time3,7,2)
ttimef = val(timehf) * 3600 + val(timemf) * 60 + val(timesf)
ttime = ttimef - ttimei
if ttime >= 3000
WAIT WINDOW "You are done!" NOWAIT
EXIT
endif
enddo