Conversión variable numérica a texto - Forum

Forum Navigation
You need to log in to create posts and topics.

Conversión variable numérica a texto

Hola,

Hay alguna forma de convertir una variable numérica a string. En el ejemplo siguiente no consigo substraer la primera cifra de  un número.  Debe ser porque la variable no es una cadena. ¿Es posible convertirla a cadena? He mirado los tutoriales y no encuentro ninguna función.

setVar [num] 28

StrCopy [num] 0 1 [num2]

 

Saludos,

Roger Rey

@rrey

Looks like VisualNEOWeb is missing the NumToString command ... but you can use the Javascript function called .toString() like so ...

SetVar [gkNum] 13456

BeginJS
$App.gkString = $App.gkNum.toString();
EndJS
... trim first digit
StrLen "[gkString]" [gkStringLen]
Math "[gkStringLen]-1" 0 [gkStringLenTrimmed]

... copy from second character (which is index 1)
StrCopy "[gkString]" 1 [gkStringLenTrimmed] [gkTrimmed]

AlertBox "gkTrimmed" "[gkTrimmed]" ""

... note that by using the value of StrLen - 1 in the StrCopy command, this code will work with numbers of all sizes (not just those with 2 integers).

@rrey para convertir una variable numérica a texto basta con sumarle una cadena vacía:

setVar [num] 28+""
StrCopy [num] 0 1 [num2]

 

danito has reacted to this post.
danito

Muchas gracias @gaev.

El código es muy completo y me ha servido también para comprender la relación de visualneo con javascritp.

Saludos,

Hola @luishp,

Muy curiosa y sencilla la solución. La verdad es que le había dado muchas vueltas para encontrar la solución.

Saludos y felices fiestas de fin de año.