TextBox, keep a 01 value to prevent it to turn into a 1.

Get help using Construct 2

Post » Thu Feb 27, 2014 1:39 pm

TextBox, keep a 01 value to prevent it to turn into a 1.

That's exactly what I'm trying to do. If I type in 01 and send that value to a variable, I obtain a 1.
That's a disaster.

Any idea on how to solve this? I haven´t seen this on the manual.

Cheers!
B
17
S
4
G
1
Posts: 105
Reputation: 1,874

Post » Thu Feb 27, 2014 1:40 pm

Lol, still with the text boxes :)

Turn variable into text and save it as '01'
then when you need it turn it into number int(variable)
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,728

Post » Thu Feb 27, 2014 1:46 pm

DUTOIT!

Lol, I'm born to test your knowlegde about such a subject!

I'm going to try it and I'll tell you.

EDIT: It don't work.
B
17
S
4
G
1
Posts: 105
Reputation: 1,874

Post » Thu Feb 27, 2014 2:07 pm

Ok, Now it starts to work.

What I've did?

Create a Textbox and an Instance Variable Text Type.

Then limit the number of characters in the TextBox to take only up to two.

Define the value of the variable to these two characters

Then send it to a Text to show it.

But...¿What if I turn it into an int before make it visible on the Text element?
B
17
S
4
G
1
Posts: 105
Reputation: 1,874

Post » Thu Feb 27, 2014 2:08 pm

Then, if I turn it into an INT, the zero disappears and everything fails.
B
17
S
4
G
1
Posts: 105
Reputation: 1,874

Post » Thu Feb 27, 2014 2:08 pm

Why don't you use the Str() and int() functions?
B
14
S
3
G
1
Posts: 255
Reputation: 2,027

Post » Thu Feb 27, 2014 2:22 pm

hava a look at zeropad

zeropad(4,2)= "04"
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,892

Post » Thu Feb 27, 2014 2:23 pm

Because when I turn it into an int() from a Str(), the 01 turns into a 1
B
17
S
4
G
1
Posts: 105
Reputation: 1,874

Post » Thu Feb 27, 2014 2:26 pm

Heptagono wrote:Because when I turn it into an int() from a Str(), the 01 turns into a 1


Of course it does, in numbers you don't get 01. That is cosmetic 1 is 1
01 = 0 because 0x1=0

You can show user 01, but when you calculate you use 1.

Example below is to show 01 to use 1 as calculation just add int(variable)
You do not have the required permissions to view the files attached to this post.
Last edited by DUTOIT on Thu Feb 27, 2014 2:27 pm, edited 1 time in total.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,728

Post » Thu Feb 27, 2014 2:27 pm

RamPackWobble wrote:hava a look at zeropad

zeropad(4,2)= "04"



ZEROPAD was the answer.

RamPackWobble, thanks again!
B
17
S
4
G
1
Posts: 105
Reputation: 1,874

Next

Return to How do I....?

Who is online

Users browsing this forum: draiza, plinkie and 8 guests