In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

ayuda para corregir error en la función WaitOnMeter

Foro público de Xailer en español
Responder
jjgp2
Mensajes: 47
Registrado: Jue May 12, 2011 12:57 am
Ubicación: México
Contactar:

ayuda para corregir error en la función WaitOnMeter

Mensaje por jjgp2 »

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
Avatar de Usuario
ramonzea
Mensajes: 130
Registrado: Mar Sep 15, 2015 6:42 am
Ubicación: México
Contactar:

Re: ayuda para corregir error en la función WaitOnMeter

Mensaje por ramonzea »

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.
Avatar de Usuario
Hurricane
Mensajes: 262
Registrado: Mar Mar 24, 2015 10:21 am
Ubicación: Brasil
Contactar:

Re: ayuda para corregir error en la función WaitOnMeter

Mensaje por Hurricane »

Olá,

apenas troque a linha:

Código: Seleccionar todo

Appdata:AddData("oWaitOnMeter", Nil)  //Aquí es donde marcando el error
por:

Código: Seleccionar todo

   WITH OBJECT Appdata
      if :IsData( 'oWaitOnMeter' )
         :oWaitOnMeter:=NIL // ou :SetData( 'oWaitOnMeter', NIL )
      else
         :AddData("oWaitOnMeter", NIL)
      endif
   ENDWITH
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
regards,
Developments | Trainings | Projects
Site | E-mail | Messenger | YouTube
Avatar de Usuario
ramonzea
Mensajes: 130
Registrado: Mar Sep 15, 2015 6:42 am
Ubicación: México
Contactar:

Re: ayuda para corregir error en la función WaitOnMeter

Mensaje por ramonzea »

Esta es otra forma que uso con AppData:

Código: Seleccionar todo

          IF !__objHasData( AppData, "oWaitOnMeter") 
            AppData:AddData( "oWaitOnMeter", Nil ) ;
          ENDIF
          
jjgp2
Mensajes: 47
Registrado: Jue May 12, 2011 12:57 am
Ubicación: México
Contactar:

Re: ayuda para corregir error en la función WaitOnMeter

Mensaje por jjgp2 »

muchas gracias por su ayuda ya funciona la función
Responder