Buenas tardes
favor de ayudarme a terminar de corregir la siguiente función WaitOnMeter que se encuentra en MESSAGES.PRG en la cual marca el siguiente error al terminar el proceso, Por su ayuda mil gracias
------------------------- Información del compilador --------------------------
Versión Xailer: Xailer 8.2.3
Compilador: Harbour 3.2.0dev (r1912031042)
Compilador C/C++: MinGW GNU C 7.3 (32-bit)
Plataforma: Windows 10 10.0
----------------------- Información detallada del error -----------------------
Subsistema: XAILER
Código de error: 0
Estado: .F.
Descripción: Class member already exists. Data can not be created
Operación: TAppData:AddData( 'oWaitOnMeter', ... )
Argumentos:
Fichero:
Código error SO: 0
Pila de llamadas:
TAPPDATA:ADDDATA (59)
WAITONMETER (571)
TFORM1:BUTTON35CLICK (270)
TBUTTON:ONCLICK (0)
TBUTTON:CLICK (100)
(b)XCONTROL (156)
TBUTTON:COMMAND (0)
TSCROLLINGWINCONTROL:WMCOMMAND (275)
TFORM1:WMCOMMAND (969)
RUNFORM (0)
TAPPLICATION:RUN (292)
MAIN (15)
*****************************************************************
* MENSAJE CON BARRA DE PROGRESO QUE QUEDA EN PANTALLA MIENTRAS *
* SE HACE OTRO PROCESO Y HASTA QUE SE EJECUTE WAITOFF() *
*****************************************************************
FUNCTION WaitOnMeter( cText, cTitle, nTotalValue, cImage, cSound )
LOCAL oImage
LOCAL nWidth := 0, nHeight := 0, nLine := 1
LOCAL nTitleWidth := 0, nTitleHeight := 0
LOCAL nTextWidth := 0, nTextHeight := 0
LOCAL nTotalWidth := 0, nTotalHeight := 0
Default cText TO ""
Default cTitle TO "Espere un momento por favor..."
Default nTotalValue TO 100
Default cImage TO ""
Default cSound TO ""
IF Application:oActiveform <> Nil
oPrevForm := Application:oActiveform
oPrevForm:lEnabled := .F.
ENDIF
Appdata:AddData("oWaitOnMeter", Nil) //Aquí es donde marcando el error
Application:lBusy := .T.
cText := Alltrim(cText)
cTitle := Alltrim(cTitle)
// Calcular tamaños respecto al fuente
nTitleWidth := Application:oFont:GetTextWidth(cTitle) * 1.2
nTitleHeight := Application:oFont:GetTextHeight(cTitle) * 1.2
nHeight := Application:oFont:GetTextHeight(cTitle) * 1.2
nTotalHeight := Max((nHeight * (Mlcount(cText) + 1)) + 35, If(!Empty(cImage), 85, 0))
nWidth := nTitleWidth
FOR nLine := 1 TO Mlcount(cText)
nWidth := Max(nWidth, Application:oFont:GetTextWidth(Alltrim(Memoline(cText,,nLine))) * 1.2)
NEXT
nTotalWidth := nWidth + If(!Empty(cImage), 55, 0) + 20
nTotalWidth := If(nTotalWidth >= Screen:nWidth, Application:oMainform:nClientWidth - 60, nTotalWidth)
// Si no se ha llamado a Waitoff antes de un segundo WaitOn se provoca
IF Valtype(oFormWait) <> 'U'
WaitOff()
ENDIF
// Ventana de mensaje con barra de progreso en espera hasta que se ejecuta WaitOff
DEFINE FORM oFormWait SIZE nTotalWidth, nTotalHeight + 20 BORDERSTYLE bsSPLASH OF Application:oActiveform
@ 1, 5 LABEL cTitle VAR oWaitTitle SIZE nTitleWidth, nTitleHeight OF oFormWait
IF !Empty(cImage)
@ 30, 10 Image oImage SIZE 40, 40 FILE cImage Transparent NONE ;
NoTabStop OF oFormWait
@ nHeight + 10, 55 LABEL cText VAR oWaitSay Size nWidth, nHeight * Mlcount(cText) OF oFormWait ALIGNMENT taCenter
oWaitSay:nVAlignment := vaCenter
ELSE
@ nHeight + 10, 10 LABEL cText VAR oWaitSay Size nWidth, nHeight * Mlcount(cText) OF oFormWait ALIGNMENT taCenter
oWaitSay:nVAlignment := vaCenter
ENDIF
IF !Empty(cSound)
PlaySound(cSound)
ENDIF
@ nTotalHeight - 10, 10 PROGRESSBAR Appdata:oWaitOnMeter OF oFormWait ;
SIZE nTotalWidth - 25, 15 ;
RANGE 0, nTotalValue ;
SMOOTH
Appdata:oWaitOnMeter:nStep := nTotalValue / 100
Appdata:oWaitOnMeter:nValue := 0
ACTIVATE FORM oFormWait CENTER
RETURN Nil
ayuda para corregir error en la función WaitOnMeter
Re: ayuda para corregir error en la función WaitOnMeter
Yo uso una variable estática a nivel PRG y me ha funcionado bien siempre.
STATIC oFormWait
y Comparo:
If Valtype(oFormWait) <> 'U'
WaitOff()
oFormWait := Nil
EndIf
Saludos.
STATIC oFormWait
y Comparo:
If Valtype(oFormWait) <> 'U'
WaitOff()
oFormWait := Nil
EndIf
Saludos.
Re: ayuda para corregir error en la función WaitOnMeter
Olá,
apenas troque a linha:
por:
apenas troque a linha:
Código: Seleccionar todo
Appdata:AddData("oWaitOnMeter", Nil) //Aquí es donde marcando el error
Código: Seleccionar todo
WITH OBJECT Appdata
if :IsData( 'oWaitOnMeter' )
:oWaitOnMeter:=NIL // ou :SetData( 'oWaitOnMeter', NIL )
else
:AddData("oWaitOnMeter", NIL)
endif
ENDWITH
regards,jjgp2 escribió: ↑Sab Mar 09, 2024 1:41 am favor de ayudarme a terminar de corregir la siguiente función WaitOnMeter que se encuentra en MESSAGES.PRG en la cual marca el siguiente error al terminar el proceso,
Descripción: Class member already exists. Data can not be created
Operación: TAppData:AddData( 'oWaitOnMeter', ... )
Appdata:AddData("oWaitOnMeter", Nil) //Aquí es donde marcando el error
Re: ayuda para corregir error en la función WaitOnMeter
Esta es otra forma que uso con AppData:
Código: Seleccionar todo
IF !__objHasData( AppData, "oWaitOnMeter")
AppData:AddData( "oWaitOnMeter", Nil ) ;
ENDIF
Re: ayuda para corregir error en la función WaitOnMeter
muchas gracias por su ayuda ya funciona la función