help me please i need to replace " in a string

Get help using Construct 2

Post » Tue Jun 28, 2016 1:45 am

im getting data from a websocket server but its comeing through as a string separated by "

so eg

"1253.22"

is there any way i can delete the " " ether side as when i display as text its showing as "1253.22"
B
6
S
2
Posts: 45
Reputation: 1,138

Post » Tue Jun 28, 2016 7:22 am

One way would be to set up a empty variable and set its value to your string with left(), right() or mid() and repeat until you have what you need, but than your string has to be always the same length. A better way would be to use Regex: Exploring Regex in Construct 2
B
11
S
4
G
5
Posts: 74
Reputation: 3,435

Post » Tue Jun 28, 2016 9:37 am

Another way would be to "save" the incoming information in a "number" variable using float() at worst to cast the value as a floating value.
This will directly set the value of the variable to a number and will prevent you having to do any string manipulation.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
288
S
111
G
94
Posts: 7,332
Reputation: 69,160

Post » Tue Jun 28, 2016 9:46 am

Kyatric wrote:Another way would be to "save" the incoming information in a "number" variable using float() at worst to cast the value as a floating value.
This will directly set the value of the variable to a number and will prevent you having to do any string manipulation.

That works best ;) This will come in Handy, i thoght that would make an error, but it work.
B
11
S
4
G
5
Posts: 74
Reputation: 3,435

Post » Tue Jun 28, 2016 2:46 pm

If you have the text in a var you can remove the " with:

set var to replace(var, """", "")
B
92
S
32
G
106
Posts: 5,272
Reputation: 69,455


Return to How do I....?

Who is online

Users browsing this forum: fearfulelephants and 26 guests