• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Windows Unable to convert string "..." to int64

G

Gizmo

Guest
So i am tring to compare user inputed txt in an if statment, but i keep getting this error. On my last game, finished just last night, i had the same issue but i managed to get it to work my making a copy Var and checking against the copied var, but this time it will not work. What i don't understand is why the if statment would try and convert my string to an int in the first place. I think it might be because it is an instance var and it is checking against its refrence number. This post is my last resort, have googled it over 20 times but can't find anything concreate, also checked forms.
Code:
___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Alarm Event for alarm 0
for object O_Play_Button:

unable to convert string "Please Enter Name" to int64
 at gml_Object_O_Play_Button_Alarm_0 (line 2) - if(string(name2) == "Please Enter Name" | string(name2) == ""){
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_O_Play_Button_Alarm_0 (line 2)
My Code...
Code:
name2 = O_nameTag.nameCopy;;
if(string(name2) == "Please Enter Name" | string(name2) == ""){
}else{
    room_goto(1);
}
Where nameCopy is set...(Different object)
Code:
if(clicked){
    name = keyboard_string;
}
nameCopy = name;
 
What i don't understand is why the if statment would try and convert my string to an int in the first place.
It is doing this because you are using the bitwise | operator. You want to be using the "or" operator which is ||
So change this code
Code:
if(string(name2) == "Please Enter Name" | string(name2) == ""){
to be
Code:
if(string(name2) == "Please Enter Name" || string(name2) == ""){
and see if that works.
 
G

Gizmo

Guest
It is doing this because you are using the bitwise | operator. You want to be using the "or" operator which is ||
So change this code
Code:
if(string(name2) == "Please Enter Name" | string(name2) == ""){
to be
Code:
if(string(name2) == "Please Enter Name" || string(name2) == ""){
and see if that works.
You are the BEST! thank you so much.
 
Top