Jump to content
Sign in to follow this  
R3DActual

[HELP] Checking for Empty RscEdit & making sure it's a integer

Recommended Posts

So, I'm working on trying to get it where it checks for both an empty value and checks to make sure the value is a number/int from an RscEdit

Reading if it's empty works fine but checking to see if it's an int/SCALAR no matter whether it's a number or text or returns the hint "Value must be an integer!"

_getVar = uiNamespace getVariable 'myVar';
_value = ctrlText _getVar;

if (_value == "") exitWith {
  hint parseText "<t color='#FF0000'>Value can't be empty!</t>";
};

if(typename _value != "SCALAR") exitWith {
   hint parseText "<t color='#FF0000'>Value must be an integer!</t>";
};
      
hint format["Value: $%1", _value];

 

Share this post


Link to post
Share on other sites

Always check the biki - https://community.bistudio.com/wiki/ctrlText

 

As you can see from the command's return value it always returns a string, so typeName will always return "STRING". You are going to need to convert the string to a number first using parseNumber:

_getVar = uiNamespace getVariable 'myVar';
_value = ctrlText _getVar;

if (_value == "") exitWith {
  hint parseText "<t color='#FF0000'>Value can't be empty!</t>";
};

_num = parseNumber _value;
      
hint format["Value: $%1", _num];

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×