Irony

Posted by Kaz on March 27, 2006, 3:28 p.m.

Now that the GMC is down I need help…

Anyway how would I get a variable to equal a number or string depending on another variable?

var q;q=show_message_ext("What value is it?","X","","Number")

if q=0

{global.A='X'}

if q=3

{global.A=get_integer("Whats angle A equal?","")}

When I set global.A to X an error pops up or nothing shows depending on what global.A is set to at create. Anyone have ideas?

Comments

membrain 18 years, 7 months ago

wut err do u get?

Kaz 18 years, 7 months ago

Wrong tyye of arguements to +(meaning string/real problem).

gamehawk 18 years, 7 months ago

Let's neaten up your code:

var q;

q=show_message_ext("What value is it?","X","","Number");

if(q==0)

{

global.A="X";

}

if (q==3)

{

global.A=get_integer("What's angel A equal?","");

}

Now that should work, what was the problem. Also, please try to neaten up your code.

Kaz 18 years, 7 months ago

The problem is that global.A can equal either a number or a letter, when I try to use the variable it says wrong type of arguments to something. I have to create the variable so it can be used as a letter or number.

Josea 18 years, 7 months ago

what I guess is when you try to use your variable you don't care if it is an string or a real.

If you're doing something like:

x += global.A

It'll crash into an error if the user selected "X".

What I ever suggest to people is to keep the type of a variable always the same through the whoel program, I mean, if you make a variable real, keep using it for storing real values, not change them for string, that leads to many errors that are a headhache.

membrain 18 years, 7 months ago

I see the problem, more or less… but I almost never deal with string handling so I don't really know how to fix it. Sorry man. (I'm sure your in the same possition though LoL)

hey gamehawk: Does it make you feel like a genius telling someone to "neaten up" their code… LoL, that's completly irrelevant right now. His code was ment only to show us wuts wrong ;0)

oh… dude, and Kaz.

Now that your avatar is animated… It's really freakin me out @_@

FAMILY GUY RULEZ!!!

edit: GML_josea has a good point. That is good practice.

Kaz 18 years, 7 months ago

Well I have to set it to something(real or string) at start, if I choose the other in the question it gives me an error. Im really not changing the type.

Yea I dont deal with strings much, if I do I dont have to use reals in the same problem.

Yes my avvy is awesome, who doesnt love evil insane babies making out with drunk intellectual dogs that can talk?

V 18 years, 7 months ago

um, i only read the part asking how to make one variable equal to another variable, wether its a string or not? i belive THIS would make your life so much easier.

variable=other variable

:)

noshenim 18 years, 6 months ago

your problem is:

-show message ext- returns only numbers not the strings (first str=1 second=2 third=3)