-
Notifications
You must be signed in to change notification settings - Fork 0
/
NETFUNC.PRG
179 lines (168 loc) · 6.04 KB
/
NETFUNC.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
177
178
179
// Œ®¤ã«ì á á¥â¥¢ë¬¨ äãªæ¨ï¬¨
#define NET_WAIT 0.5 // Seconds to wait between between retries
#define NET_SECS 2 // Number of seconds to continue retry
// „®¡ ¢«¥¨¥ § ¯¨á¨ ¢ á¥â¨
FUNCTION NetAppend( nWaitSeconds )
LOCAL lForever // ¥áª®¥çë¥ ¯®¯ë⪨ ?
LOCAL win:=win_save(maxrow(),1,maxrow(),30),clr:=setcolor()
nWaitSeconds:=IF(nWaitSeconds==NIL,30,nWaitSeconds)
set color to g*/r+
@ maxrow(),1 say "„®¡ ¢«¥¨¥ "
nRetry:=nWaitSeconds
APPEND BLANK
IF !NETERR()
win_rest(win); setcolor(clr)
RETURN ( .T. ) // ‡ ¯¨áì ¤®¡ ¢«¥ ãá¯¥è® !!!
ENDIF
lForever:=(nWaitSeconds==0)
//------------------------- Ž¦¨¤ î áï⨥ ¡«®ª¨à®¢ª¨ ¤«ï ¤®¡ ¢«¥¨ï § ¯¨á¨...
DO WHILE ( lForever .OR. ( nWaitSeconds > 0 ) )
@ maxrow(),1 say "„®¡ «¥¨¥ "
APPEND BLANK
IF !NETERR()
win_rest(win); setcolor(clr)
RETURN ( .T. ) // „®¦¤ «¨áì !!!
ENDIF
INKEY( NET_WAIT ) // †¤ã NET_WAIT ᥪ㤠¤«ï á«¥¤ãî饩 ¯®¯ë⪨
nWaitSeconds -= NET_WAIT
IF .not.(nWaitSeconds>0)
IF al_box({" § ¤ ëå § ïâ ¤à㣨¬ ¯®«ì§®¢ ⥫¥¬",;
"®¢â®à¨âì ®¦¨¤ ¨¥ ®á¢®¡®¦¤¥¨ï ¡ §ë"},2,;
{" ®¢â®à¨âì "," Žâ¬¥¨âì "})==1
nWaitSeconds:=nRetry
ELSE
win_rest(win); setcolor(clr)
return .F. // ¥ ¤®¦¤ «¨áì...
ENDIF
ENDIF
ENDDO
win_rest(win); setcolor(clr)
RETURN ( .F. ) // ¥ ¤®¦¤ «¨áì :-(
// «®ª¨à®¢ ¨¥ § ¯¨á¨ ¢ á¥â¨
FUNCTION RecLock( nSeconds )
LOCAL lForever // ¥áª®¥çë¥ ¯®¯ë⪨?
LOCAL nRetry
LOCAL win:=win_save(maxrow(),1,maxrow(),30),clr:=setcolor()
nSeconds:=if(nSeconds==NIL,30,nSeconds)
nRetry:=nSeconds
set color to g*/r+
@ maxrow(),1 say "«®ª¨à®¢ ¨¥ "
IF RLOCK()
win_rest(win); setcolor(clr)
RETURN ( .T. ) // ‡ ¡«®ª¨à®¢ ®.
ENDIF
lForever := ( nSeconds == 0 )
//------------------------- Ž¦¨¤ î áï⨥ ¡«®ª¨à®¢ª¨ ¤«ï ¤®¡ ¢«¥¨ï § ¯¨á¨...
DO WHILE ( lForever .OR. ( nSeconds > 0 ) )
IF RLOCK()
win_rest(win); setcolor(clr)
RETURN ( .T. ) // „®¦¤ «¨áì
ENDIF
@ maxrow(),1 say "«®ª¨à®¢ª "
INKEY( NET_WAIT ) // †¤ã NET_WAT ᥪã¤...
nSeconds -= NET_WAIT
if .not.(nSeconds>0)
IF al_box({" § ¤ ëå § ïâ ¤à㣨¬ ¯®«ì§®¢ ⥫¥¬",;
"®¢â®à¨âì ®¦¨¤ ¨¥ ®á¢®¡®¦¤¥¨ï ¡ §ë"},2,;
{" ®¢â®à¨âì "," Žâ¬¥¨âì "})==1
nSeconds:=nRetry
ELSE
win_rest(win); setcolor(clr)
return .F. // ¥ ¤®¦¤ «¨áì...
ENDIF
endif
ENDDO
win_rest(win); setcolor(clr)
RETURN ( .F. ) // ¥ ¤®¦¤ «¨áì
********************************************************************
* LOGICAL netuse(cdatabase, lopenmode, nseconds)
* CHARACTER cdatabase - ˆ¬ï ¡ §ë ¤ ëå
* LOGICAL lopenmode - ¥¦¨¬ ®âªàëâ¨ï. .T. ¬®®¯®«ìë©, .F. à §¤¥«ï¥¬ë©
* NUMERIC nseconds - —¨á«® ᥪ㤠®¦¨¤ ¨ï (0 = ¦¤ âì ¤® 㯮à )
* ‚Ž‡‚€’ - .T., ¥á«¨ ãᯥè , .F., ¥á«¨ ¥â
* Nantucket äãªæ¨ï netuse á® ¢§ ¨¬®¤¥©á⢨¥¬ á ¯®«ì§®¢ ⥫¥¬, ¥á«¨ USE
* § ¢¥à訫 áì ¢ ਩®
* Ž¡à §¥æ ¢ë§®¢ : IF netuse("calls", .F., 5)
*
FUNCTION netuse(cDatabase, lOpenMode, nSeconds, cAlias,lAsk)
LOCAL forever, restart, Wait_Time
LOCAL win:=win_save(maxrow(),1,maxrow(),MaxCol()),clr:=setcolor()
lOpenMode:=if(lOpenMode==NIL,.F.,lOpenMode)
nSeconds:=if(nSeconds==NIL,30,nSeconds)
cAlias:=if(cAlias==NIL,"",cAlias)
lAsk:=if(lAsk==NIL,.T.,lAsk)
restart = .T.
forever = (nseconds = 0)
DO WHILE restart
Wait_Time = nSeconds
DO WHILE (forever .OR. Wait_Time > 0)
@ maxrow(),1 say "Žâªàë⨥ "+cDatabase
IF !Empty(cAlias)
IF lOpenMode
USE (cdatabase) EXCLUSIVE Alias &cAlias
ELSE
USE (cdatabase) SHARED Alias &cAlias
ENDIF
ELSE
IF lOpenMode
USE (cdatabase) EXCLUSIVE
ELSE
USE (cdatabase) SHARED
ENDIF
ENDIF
IF !neterr()
win_rest(win); setcolor(clr)
RETURN .T.
ENDIF
inkey(0.3)
Wait_Time --
ENDDO
* «®ª¨à®¢ ¨¥ ¥ 㤠«®áì, á¯à®á¨¬ ¯®«ì§®¢ ⥫ï, ¯à®¤®«¦ âì «¨
IF lAsk
restart = IF(Al_Box({"Žè¨¡ª ¡«®ª¨à®¢ª¨ (®âªàëâ¨ï) " + cdatabase },2,;
{" ®¢â®à¨âì "," ‚ë室 "})==1,.T.,.F.)
ELSE
Restart:=.F.
ENDIF
ENDDO
win_rest(win); setcolor(clr)
RETURN .F.
********************************************************************
* LOGICAL fillock(nseconds)
* NUMERIC nseconds
* ‚Ž‡‚€’ - .T., ¥á«¨ ãᯥè , .F., ¥á«¨ ¥â
* à®æ¥¤ãà ¡«®ª¨à®¢ ¨ï ä ©« á® ¢§ ¨¬®¤¥©á⢨¥¬ á ¯®«ì§®¢ ⥫¥¬, ¥á«¨
* ¡«®ª¨à®¢ ¨¥ ¥ 㤠«®áì
* Ž¡à §¥æ ¢ë§®¢ :
* IF fillock(5)
*
FUNCTION FileLock(nseconds)
LOCAL lforever, restart, wait_time
LOCAL win:=win_save(maxrow(),1,maxrow(),MaxCol()),clr:=setcolor()
nSeconds:=IF(nSeconds=NIL,0,nSeconds)
set color to g*/r+
@ maxrow(),1 say "«®ª¨à®¢ ¨¥ "
// sound(700,2)
IF flock()
win_rest(win); setcolor(clr)
RETURN (.T.) && ‡ ¡«®ª¨à®¢
ENDIF
Wait_Time:=nSeconds
restart = .T.
lforever = IF(nSeconds=0,.T.,.F.)
DO WHILE restart
wait_time = nseconds
DO WHILE (lforever .OR. wait_time > 0)
inkey(.5) && ¦¤ âì 1/2 ᥪã¤ë
wait_time = wait_time - .5
IF flock()
win_rest(win); setcolor(clr)
RETURN (.T.) && ‡ ¡«®ª¨à®¢
ENDIF
ENDDO
* «®ª¨p®¢ ¨¥ ¥ 㤠«®áì, á¯à®á¨¬ ¯®«ì§®¢ ⥫ï, ¯à®¤®«¦ âì «¨
restart = IF(Al_Box({"Žè¨¡ª ¡«®ª¨à®¢ª¨ ä ©« " + cdatabase },2,;
{" ®¢â®à¨âì "," ‚ë室 "}),.T.,.F.)
ENDDO
win_rest(win); setcolor(clr)
RETURN (.F.) && ¥ § ¡«®ª¨à®¢