Page 1 of 1

Pasar variables de una pagina a otra, se puede?

PostPosted: Sat Mar 07, 2015 1:17 pm
by gusgusl
Estoy creando una aplicacion y mi pregunta es como le hago para pasar los valores de una variable determinada a otra pagina de la misma aplicacion.
Lo que hago es lo siguiente:

Math "2015+1" -1 [Año2]
Math "2015+2" -1 [Año3]
Math "2015+3" -1 [Año4]
SetVar [Año1] 2015
GotoPage "SeleccionAño"

Y en la siguiente pagina simplemente hay unos botones que contienen como "Caption" el valor de estas variables

Re: Pasar variables de una pagina a otra, se puede?

PostPosted: Sat Mar 07, 2015 5:12 pm
by Gaev
gusgusl:

Put this code in the page-enter code section of the page where the buttons are located ...
Code: Select all
SetObjectHTML "PushButtonX1" "[Año1]"
SetObjectHTML "PushButtonX2" "[Año2]"
SetObjectHTML "PushButtonX3" "[Año3]"
SetObjectHTML "PushButtonX4" "[Año4]"
... just replace the values of PushButtonX1 to PushButtonX4 to correspond with the ObjectId's in your App.

Re: Pasar variables de una pagina a otra, se puede?

PostPosted: Sat Mar 07, 2015 5:34 pm
by gusgusl
esta es la unica manera de pasar el valor de una pagina a otra? o es porque esta en face Beta? no se puede mantener el valor a traves de toda la aplicacion como en neobook?

Re: Pasar variables de una pagina a otra, se puede?

PostPosted: Sat Mar 07, 2015 6:33 pm
by Gaev
gusgusl:

Translation ...
This is the only way to pass the value from one page to another ? Or is it because this en face Beta? can not maintain the value through the entire application and NeoBook ?

The value (i.e. variable) is globally available ... but (I believe) the object only exists when its page is in view ... so you have to request change to its properties (like the caption of the button) when its page is being displayed.

Re: Pasar variables de una pagina a otra, se puede?

PostPosted: Sun Mar 08, 2015 2:11 am
by luishp
gusgusl, el problema está en el nombre de las variables. Sustituye la "Ñ".
Esto no creo que sea culpa de NeoAppBuilder, sino de JavaScript.
Lo que dice Gaev es cierto, pero si es posible utilizar las variables entre pa´ginas tal y como estás intentándolo sin ningún problema.
Tampoco es recomendable utilizar guiones u otros símbolos especiales para nombrar variables y objetos.

Quick translation:

The problem is in the "Ñ" symbol.

Re: Pasar variables de una pagina a otra, se puede?

PostPosted: Sun Mar 08, 2015 5:47 am
by Gaev
luishp:

The problem is in the "Ñ" symbol.

I tried it with variable [Ano1] ... same result ... SetObjectHTML "PushButtonX1" "[Ano1]" ... only changes the caption of the PushButton when the command is invoked from the same page as the PushButton.

Re: Pasar variables de una pagina a otra, se puede?

PostPosted: Sun Mar 08, 2015 6:10 am
by luishp
This is quite strange. For me it's working fine, but only avoiding "Ñ" character.
I don't need to use SetObjectHTML wich works as you say, just the [varname]

Published:
http://sinlios.com/apps/test

Source:
http://sinlios.com/apps/test/prueba.neoapp

Re: Pasar variables de una pagina a otra, se puede?

PostPosted: Sun Mar 08, 2015 6:43 am
by Gaev
luishp:

I don't need to use SetObjectHTML wich works as you say, just the [varname]

Confirmed ... if I specify [Ano1] for the Caption property of the PushButton, it works ... looks like just the SetObjectHTML command needs to be invoked on the same page ... @Dave: bug or by design ?

Re: Pasar variables de una pagina a otra, se puede?

PostPosted: Sun Mar 08, 2015 9:22 am
by gusgusl
Hola, hize la prueba de cambiar la letra "ñ" como dice Gaev y funciono perfectamente ahora.
Ahora mi pregunta es si existe manera de usar alguna variable predifinida ya como en el caso de Neobook es la variable [Year] para que me de el año actual sin tener que ingresarla manualmente al programar la aplicacion.

Re: Pasar variables de una pagina a otra, se puede?

PostPosted: Sun Mar 08, 2015 10:23 am
by luishp
Con este código creas las variables [Day] [Month] y [Year]:
With this code you generate [Day] [Month] & [Year] vars:

Code: Select all
BeginJS
  var fechaActual = new Date()
  $rootScope.Day = fechaActual.getDate();
  $rootScope.Month = fechaActual.getMonth() + 1;
  $rootScope.Year = fechaActual.getFullYear();
EndJS

Re: Pasar variables de una pagina a otra, se puede?

PostPosted: Mon Mar 09, 2015 12:36 pm
by Neosoft Support
Variables used in NeoAppBuilder must be compatible with JavaScript. The general rules for JavaScript variable names are:

Names can contain letters*, digits, underscores, and dollar signs
Names must begin with a letter
Names can also begin with $ and _
Names are case sensitive ("MyVar" and "myvar" are different variables)
JavaScript keywords cannot be used as variable names

*It appears that JavaScript permits variable names containing extended/Unicode characters like "ñ", but AngularJS does not. (I'm still researching this.)

... looks like just the SetObjectHTML command needs to be invoked on the same page ... @Dave: bug or by design ?


If you use a variable for your object's caption/text then changes will be retained when switching pages. If you modify and object using SetObjectHTML, SetAttribute or via JavaScript then changes will be lost. This is because only one page can reside in memory at a time. When you leave a page, it's objects are released from memory to make room for the new page's objects. Any changes made to those objects are lost. This is how HTML works. Sometimes it's helpful and sometimes it's not. There may be ways to compensate for this behavior - I'm looking into them.