convert to string error

RizbIT

Member
After converting from GMS 1 to GMS 2 i get some errors during runtime that i id not get with GMS1 after compiling.

in GMS 2 i think when you ask it to do real(variable) where the variable is "" or maybe has no digits it gives an error
unable to convert string "" to number.

ive fixed one of these errors by using if string_digits(variable)!=""

but there several more so is there a way to bypass or ignore these errors? as if the variable is "" then i want real(variable) to just return 0
 

FrostyCat

Redemption Seeker
GMS 2 stopped ignoring digit conversion errors in 2.2.3.

If the empty string is the only one causing you problems, just create a script called real_safe checking for that:
Code:
return (argument0 == "") ? 0 : real(argument0);
Then do a global search-and-replace for real( with real_safe(.
 

RizbIT

Member
GMS 2 stopped ignoring digit conversion errors in 2.2.3.

If the empty string is the only one causing you problems, just create a script called real_safe checking for that:
Code:
return (argument0 == "") ? 0 : real(argument0);
Then do a global search-and-replace for real( with real_safe(.
That is a fantastic reply, thanks it will work great


** EDIT **
Your solution works but only seems to work when using the Vm compilor, when using the YYC compilor i still get the same error which is strange.

but then i dound it happened after calling instance_activate_all(), in YCC maybe due to some bug or delay any code ive put directly after calling instance_activate_all() doesnt get execured.
 
Last edited:
Top