// A nice Odometer developed by a FiveWin user
#include "FiveWin.ch"
Static nGet
Static oBmp1, oBmp2, oBmp3, oBmp4, oBmp5
//----------------------------------------------------------------------------//
function Odo()
local oDlg, oFont1
LOCAL cNGanador := "333"
LOCAL aDatos:={"001","002","003","004","005","006","007","008","009","010",;
"011","012","013","014","015","016","017","018","019","020"}
DEFINE FONT oFont1 NAME "Arial" SIZE 0,-36 BOLD
DEFINE DIALOG oDlg FROM 0, 0 TO 15, 60 TITLE "PROBANDO EL CONTADOR"
/* Cada dígito es de 34 x 48 */
@ 0, 0 BITMAP oBmp1 FILE "..\bitmaps\display.bmp" OF oDlg
@ 0, 0 BITMAP oBmp2 FILE "..\bitmaps\display.bmp" OF oDlg
@ 0, 0 BITMAP oBmp3 FILE "..\bitmaps\display.bmp" OF oDlg
@ 0, 0 BITMAP oBmp4 FILE "..\bitmaps\display.bmp" OF oDlg
@ 0, 0 BITMAP oBmp5 FILE "..\bitmaps\display.bmp" OF oDlg
oBmp1:nTop := 28
oBmp1:nLeft := 80
oBmp1:nBottom := 52
oBmp1:nRight := 97
oBmp2:nTop := 28
oBmp2:nLeft := 98
oBmp2:nBottom := 52
oBmp2:nRight := 115
oBmp3:nTop := 28
oBmp3:nLeft := 116
oBmp3:nBottom := 52
oBmp3:nRight := 133
oBmp4:nTop := 28
oBmp4:nLeft := 134
oBmp4:nBottom := 52
oBmp4:nRight := 151
oBmp5:nTop := 28
oBmp5:nLeft := 152
oBmp5:nBottom := 52
oBmp5:nRight := 169
@ 73,50 SAY "Número ganador:" OF oDlg PIXEL
@ 66,110 SAY oSay1 VAR cNGanador OF oDlg PIXEL FONT oFont1 COLOR nRGB(175,0,0)
@ 10,100 BUTTON "&Sorteo" OF oDlg SIZE 40, 12 ;
ACTION Solo(aDatos,oSay1) PIXEL
ACTIVATE DIALOG oDlg CENTERED ;
ON INIT (oBmp1:nX:=-528,oBmp2:nX:=-528,oBmp3:nX:=-528,oBmp4:nX:=-528,oBmp5:nX:=-528,;
oSay1:Hide())
return nil
Function Solo(aDatos,oSay1)
Local i, nNumRam, nVeces := 10 // 50
oSay1:Hide()
for i = 1 to nVeces
nNumRam := Round(HB_Random(1,Len(aDatos)),0)
Pone(oBmp1, oBmp2, oBmp3, oBmp4, oBmp5, nNumRam)
if i==nVeces
oSay1:SetText(StrZero(nNumRam,5))
oSay1:Show()
endif
SysWait(0.2)
SysRefresh()
next i
return NIL
//---------------------------------------------------------------------------//
Function Pone ( oB1, oB2, oB3, oB4, oB5, nCantidad)
Local cNum := SPACE(5)
Local nLen := 0
Local nDig1 := 0
Local nDig2 := 0
Local nDig3 := 0
Local nDig4 := 0
Local nDig5 := 0
cNum := STR(nCantidad)
nLen := LEN(cNum)
nDig1 := VAL(SUBSTR(cNum, nLen - 4, 1))
if nDig1 = 0
oB1:nX := -528 // 0 - (11 * 48)
else
oB1:nX := 0 - (nDig1 * 48)
endif
nDig2 := VAL(SUBSTR(cNum, nLen - 3, 1))
if nDig2 = 0 .AND. nDig1 = 0
oB2:nX := -528
else
oB2:nX := 0 - (nDig2 * 48)
endif
nDig3 := VAL(SUBSTR(cNum, nLen - 2, 1))
if nDig3 = 0 .AND. nDig2 = 0 .AND. nDig1 = 0
oB3:nX := 0 // -528
else
oB3:nX := 0 - (nDig3 * 48)
endif
nDig4 := VAL(SUBSTR(cNum, nLen - 1, 1))
if nDig4 = 0 .AND. nDig3 = 0 .AND. nDig2 = 0 .AND. nDig1 = 0
oB4:nX := 0 // -528
else
oB4:nX := 0 - (nDig4 * 48)
endif
nDig5 := VAL(SUBSTR(cNum, nLen, 1))
oB5:nX := 0 - (nDig5 * 48)
oB5:Refresh( .F. )
oB4:Refresh( .F. )
oB3:Refresh( .F. )
oB2:Refresh( .F. )
oB1:Refresh( .F. )
SysRefresh()
return NIL