forked from Falconisilvio/TCyclometric
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.prg
296 lines (207 loc) · 7.67 KB
/
test.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
#include "fivewin.ch"
#include "constant.ch"
// TCyclometric class for Italian Lottery
Function Test()
local oCicloMetric
local aCicloSmall:=array(11)
local oDlg,oFont,oBold
local oBtnPos,oBtnClose
local nBottom := 43
local nRight := 120
local nWidth := Max( nRight * DLG_CHARPIX_W, 180 )
local nHeight := nBottom * DLG_CHARPIX_H
local cUrl:="http://www.televideo.rai.it/televideo/pub/solotesto.jsp?pagina=786"
local adata:=TestUrl( cUrl )
local oBrw
local aColors:= {GetBackColor('blanchedalmond'),;
GetBackColor('bisque'),;
GetBackColor('blueviolet'),;
GetBackColor('chocolate'),;
GetBackColor('darkcyan'),;
GetBackColor('darkmagenta'),;
GetBackColor('firebrick'),;
GetBackColor('honeydew'),;
GetBackColor('lightcoral'),;
GetBackColor('palevioletred'),;
GetBackColor('seagreen')}
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-10
DEFINE FONT oBold NAME "TAHOMA" SIZE 0,-12 BOLD
DEFINE DIALOG oDlg SIZE nWidth, nHeight ;
PIXEL TRUEPIXEL FONT oFont ; //RESIZABLE
TiTle "Manage Ciclometric"
@ 200,500 XBROWSE oBrw OF oDlg SIZE 300,250 PIXEL NOBORDER;
COLS 1,2,3,4,5,6;
HEADERS "Ruota", "E1", "E2", "E3", "E4", "E5" ;
SIZES 80,30,30,30,30,30 ;
ARRAY adata ;
CELL LINES
WITH OBJECT oBrw
:nRowHeight := 20
:nClrBorder := CLR_GRAY
:lDrawBorder := .t.
:nColorBox := CLR_HRED
:lHeader := .f.
:lHscroll := .f.
:lvscroll := .f.
:l2007 := .F.
:l2015 := .t.
:nStretchCol := STRETCHCOL_WIDEST
:lAllowRowSizing := .F.
:lAllowColSwapping := .F.
:lAllowColHiding := .F.
:lRecordSelector := .F.
:nColDividerStyle := LINESTYLE_LIGHTGRAY
:nRowDividerStyle := LINESTYLE_LIGHTGRAY
:bClrStd := { || { CLR_BLACK, If( oBrw:KeyNo % 2 == 0, GetBackColor('lightblue') , CLR_WHITE ) } }
:bChange := { ||Showform(oBrw:nArrayAt,oCicloMetric,aColors,oBrw) }
:CreateFromCode()
End
//------------------------------------------------------------------------//
//Big Circle
oCicloMetric:= TCyclometric():New(90,15,510,510, oDlg,380)
oCicloMetric:lShowNumbers:=.t.
oCicloMetric:nDimPenCircle:= 3
oCicloMetric:nDimPenLine:= 3
@ 100,10 BUTTON oBtnClose PROMPT "Close" of oDlg SIZE 80,22 ACTION oDlg:End()
@ 100,10 BUTTON oBtnPos PROMPT "Test position" of oDlg SIZE 80,22 ;
ACTION NIL // Mostra_Form(aCicloSmall,aColors,oBrw)
oDlg:bResized := <||
local oRect := oDlg:GetCliRect()
oBtnClose:nLeft := oRect:nRight - 100
oBtnClose:nTop := oRect:nBottom - 45
oBtnPos:nLeft := oRect:nLeft +10
oBtnPos:nTop := oRect:nBottom - 45
RETURN NIL
>
ACTIVATE DIALOG oDlg CENTERED ;
ON INIT (aCicloSmall:=Mostra_Ciclo_Ruote(oBrw,oDlg,aCicloSmall) ,;
Eval(oDlg:bResized))
RELEASE FONT oFont, oBold
Return nil
//---------------------------------------------------------------------------//
Function Showform(nRecord,oCiclo,aColors,oBrw)
local aNumeri:= {}
local atemp:= {}
local cText
local num1,num2,num3,num4,num5
nColor:=aColors[ nRecord ]
AAdd(atemp,oBrw:aArrayData[ nRecord ] )
cText:=atemp[1][1] //text
num1 :=atemp[1][2]
num2 :=atemp[1][3]
num3 :=atemp[1][4]
num4 :=atemp[1][5]
num5 :=atemp[1][6]
aNumeri := {num1,num2,num3,num4,num5}
ASort( aNumeri, nil, nil, { |x,y| x < y } )
num1 :=aNumeri[1]
num2 :=aNumeri[2]
num3 :=aNumeri[3]
num4 :=aNumeri[4]
num5 :=aNumeri[5]
oCiclo:Paint()
oCiclo:Distance_Multiple(val(num1),val(num2),val(num3),val(num4),val(num5),nColor,oCiclo:apos)
Return nil
//-----------------------------------------------------------------------------------------/
Function TestUrl( cUrl )
local cRet:=""
local cData:=""
local cFile := "test.txt"
local cBuff
local nHndl
local aShow:={}
local nI
IF IsInternet()
cRet := WebPageContents( cUrl )
cData := WebPageContents( cUrl )
if Empty( cRet )
? "Invalid URL"
else
//per la data estrazione
cData := subStr( cData, at( "ALMANACCO", cData )+9 )
cData := allTrim( subStr( cData, 1, at("BARI", cData ) -1 ) )
// per il blocco Bari - Nazionale
cRet := subStr( cRet, at( "BARI", cRet ) )
cRet := allTrim( subStr( cRet, 1, at( "Controlla", cRet ) - 1 ) )
nHndl := fCreate( cFile )
fWrite( nHndl, cRet )
fClose( nHndl )
IF ( nHndl := fOpen( cFile ) ) < 1
msgStop( "UNABLE TO OPEN: " + cFile )
ELSE
aShow := {}
WHILE hb_fReadLine( nHndl, @cBuff, chr( 10 ) ) == 0
cBuff := allTrim( cBuff )
IF ! empty( cBuff )
aAdd( aShow, {} )
aAdd( aTail( aShow ), subStr( cBuff, 1, 11 ) )
FOR nI := 12 TO 28 STEP 4
aAdd( aTail( aShow ), subStr( cBuff, nI, 2 ) )
NEXT
ENDIF
ENDDO
* xBrowse( aShow )
ferase(cfile)
return aShow
ENDIF
endif
else
MsgAlert("Controlla la connessione su internet!","EasyLotto")
endif
return nil
//--------------------------------------------------//
Function Mostra_Ciclo_Ruote(oBrw,oDlg,aCicloMetric)
local nRuote:= 11,n
local nRow,nCol
local nDia,nHeight,nWidth
Local aRuote := {"Bari","Cagliari","Firenze","Genova",;
"Milano","Napoli","Palermo","Roma","Torino",;
"Venezia","Nazionale"}
local aNum:= {}
nRow:= 5
nCol:= 10
nDia:= 80
nHeight:=nDia+15
nWidth:= nDia+10
For n= 1 to 3
aCicloMetric[n]:= TCyclometric():New(nRow,nCol,nWidth,nHeight, oDlg,nDia)
aCicloMetric[n]:lShowNumbers:=.f.
aCicloMetric[n]:nDimPenCircle:= 1
@ nHeight+8,nWidth-20 say aRuote[n] size 55,10 PIXEL OF oDlg
nCol+=45+n
nWidth+=nCol
next
return aCicloMetric
Function Mostra_Form(aCicloMetric,aColors,oBrw)
local n
For n= 1 to len(aCicloMetric)
aNum:= Give_Numbers(oBrw,n)
nColor:=aColors[ n ]
num1 :=val(aNum[1])
num2 :=val(aNum[2])
num3 :=val(aNum[3])
num4 :=val(aNum[4])
num5 :=val(aNum[5])
aCicloMetric[n]:Distance_Multiple(num1,num2,num3,num4,num5,nColor)
next
return nil
Function Give_Numbers(oBrw,nrecord)
local aNumeri:= {}
local atemp:= {}
local cText
local num1,num2,num3,num4,num5
AAdd(atemp,oBrw:aArrayData[ nRecord ] )
cText:=atemp[1][1] //text
num1 :=atemp[1][2]
num2 :=atemp[1][3]
num3 :=atemp[1][4]
num4 :=atemp[1][5]
num5 :=atemp[1][6]
aNumeri := {num1,num2,num3,num4,num5}
ASort( aNumeri, nil, nil, { |x,y| x < y } )
num1 :=aNumeri[1]
num2 :=aNumeri[2]
num3 :=aNumeri[3]
num4 :=aNumeri[4]
num5 :=aNumeri[5]
Return aNumeri