DUDA

  • Este debate tiene 4 respuestas, 2 mensajes y ha sido actualizado por última vez el 2 años, 10 meses por Avatardmillas. This post has been viewed 861 times
Mostrando 3 respuestas a los debates
  • Autor
    Entradas
    • #2176
      Avatardmillas
      Participante

      Hola.

      Ya lo he conseguido!! monto un array con las dimensiones de registros y guardo los valores que calculo y los sustituyo en pantalla.

      Me he quedado atascado con el "text into cSalida" guardo el mismo texto en una variable que llamo texto pero no me funciona al hacer oCGI:SendScript(TEXTO)

      la variable texto y cSalida son iguales y no lo entiendo.

      he probado

      cSalida = TEXTO

      oCGI:SendScript(TEXTO)

       

       

      #include "Xailer.ch"
      #include "Nefele.ch"

      //------------------------------------------------------------------------------

      PROCEDURE MainPage()
      LOCAL X,Y,REGISTROS
      REGISTROS := 5

      With Object TWebPage():New()
      :lValign := .T.
      with object WForm():New(:WO)
      :cid := "F_Tabla"
      :cFunction := "VISPARAM"
      FOR X=1 TO REGISTROS
      With Object WLabel():New(:WO)
      :cText := "DATO "+NFL_VALTOJS(X)
      :lBR := .T.
      :aWidth := {3,3,,}
      :Create()
      END WITH
      WITH OBJECT WEdit():New(:WO)
      :cId := "VALOR_"+NFL_VALTOJS(X)
      :cValue :=NFL_VALTOJS(1000+X)
      :lEnabled := .F.
      :aWidth := {0,3,,}
      :Create()
      END with
      WITH OBJECT WEdit():New(:WO)
      :cId := "MED_"+NFL_VALTOJS(X)
      :nTimeOut := 0.1
      :cAjaxTimeOut := "CALCULOS"
      :cTitle := "MED. MM"
      :lEnabled := .T.
      :aWidth := {3,2,,}
      FOR Y=1 TO REGISTROS
      :AddParam({"VALOR_"+NFL_VALTOJS(Y),"#VALOR_"+NFL_VALTOJS(Y)})
      IF (Y<>X, :AddParam({"MED_"+NFL_VALTOJS(Y),"#MED_"+NFL_VALTOJS(Y)}),)
      NEXT Y
      :Create()
      END with
      WITH OBJECT WEdit():New(:WO)
      :cId := "DIFERENCIA"+NFL_VALTOJS(X)
      :lEnabled := .F.
      :aWidth := {3,2,,}
      :Create()
      END with
      WITH OBJECT WEdit():New(:WO)
      :cId := "VARIACION"+NFL_VALTOJS(X)
      :lEnabled := .F.
      :aWidth := {3,2,,}
      :Create()
      END with
      NEXT X
      :Create()
      End With
      oCgi:SendPage( :Create() )
      End With
      RETURN

      //------------------------------------------------------------------------------

      PROCEDURE CALCULOS()
      LOCAL cSalida
      LOCAL X,TEXTO :=""
      LOCAL MED,DEST
      LOCAL TABLA :={}

      FOR X=1 TO 5
      IF X<2
      AAdd(TABLA,;
      {Val(oCGI:GetCgiValue("VALOR_"+NFL_VALTOJS(X)))-Val(oCGI:GetCgiValue("MED_"+NFL_VALTOJS(X))),;
      "",;
      "document.getElementById('diferencia"+NFL_VALTOJS(X)+"').value='[[diferencia"+NFL_VALTOJS(X)+"]]'",""})
      ELSE
      AAdd(TABLA,;
      {Val( oCGI:GetCgiValue("VALOR_"+NFL_VALTOJS(X)))-Val(oCGI:GetCgiValue("MED_"+NFL_VALTOJS(X))),;
      Abs((Val(oCGI:GetCgiValue("VALOR_"+NFL_VALTOJS(X)))-Val(oCGI:GetCgiValue("MED_"+NFL_VALTOJS(X))))-(Val(oCGI:GetCgiValue("VALOR_"+NFL_VALTOJS(X-1)))-Val(oCGI:GetCgiValue("MED_"+NFL_VALTOJS(X-1))))),;
      "document.getElementById('diferencia"+NFL_VALTOJS(X)+"').value='[[diferencia"+NFL_VALTOJS(X)+"]]'","document.getElementById('variacion"+NFL_VALTOJS(X)+"').value='[[variacion"+NFL_VALTOJS(X)+"]]'"})
      ENDIF
      NEXT

      FOR X=1 TO 5
      TEXTO =TEXTO+TABLA[X,3]
      NEXT
      FOR X=2 TO 5
      TEXTO =TEXTO+TABLA[X,4]
      NEXT

      //MED=(VAR2+VAR3+VAR4+VAR5)/4
      //DEST=SQRT(((VAR2-MED)^2+(VAR3-MED)^2+(VAR4-MED)^2+(VAR5-MED)^2)/4)

      TEXT into cSalida
      document.getElementById('diferencia1').value='[[diferencia1]]'
      document.getElementById('diferencia2').value='[[diferencia2]]'
      document.getElementById('diferencia3').value='[[diferencia3]]'
      document.getElementById('diferencia4').value='[[diferencia4]]'
      document.getElementById('diferencia5').value='[[diferencia5]]'
      document.getElementById('variacion2').value='[[variacion2]]'
      document.getElementById('variacion3').value='[[variacion3]]'
      document.getElementById('variacion4').value='[[variacion4]]'
      document.getElementById('variacion5').value='[[variacion5]]'
      endtext

      FOR X=1 TO 5
      cSalida := StrTran(cSalida, "[[diferencia"+NFL_VALTOJS(X)+"]]", NFL_VALTOJS(TABLA[X,1]))
      TEXTO := StrTran(TEXTO, "[[diferencia"+NFL_VALTOJS(X)+"]]", NFL_VALTOJS(TABLA[X,1]))
      IF(X>=2,cSalida := StrTran(cSalida, "[[variacion"+NFL_VALTOJS(X)+"]]",NFL_VALTOJS(TABLA[X,2])),)
      IF(X>=2,TEXTO := StrTran(TEXTO, "[[variacion"+NFL_VALTOJS(X)+"]]",NFL_VALTOJS(TABLA[X,2])),)
      NEXT
      NFL_CONSOLE(cSalida)
      NFL_CONSOLE(TEXTO)
      // oCGI:SendScript(TEXTO)
      oCGI:SendScript( cSalida )
      RETURN

      Loading spinner
    • #2177
      Avatardmillas
      Participante

      Hola.

      Ya lo he conseguido,

      solo faltaba por ; despues de cada linea "document.getElementById('diferenciax').value='[[diferenciax]]';"

       

       

      Loading spinner
    • #2178
      Alfredo SanzAlfredo Sanz
      Superadministrador

      Holaqtal.

      En teoría no tendría que hacer falta. Si hay un retorno de línea, en js se puede quitar el ;

      Mira el texto que se genera en el navegador y dime si las líneas están juntas o están en líneas diferentes.

       

       

      Loading spinner
    • #2179
      Avatardmillas
      Participante

      Hola.

      Sale todo junto ponga o no ponga ; la diferencia es que si pongo ; hace la sustitución y si no pongo ; no la hace.

      Loading spinner
Mostrando 3 respuestas a los debates
  • Debes estar registrado para responder a este debate.

Si continuas utilizando este sitio aceptas el uso de cookies. más información

Los ajustes de cookies de esta web están configurados para «permitir cookies» y así ofrecerte la mejor experiencia de navegación posible. Si sigues utilizando esta web sin cambiar tus ajustes de cookies o haces clic en «Aceptar» estarás dando tu consentimiento a esto.

Cerrar