Jump to content
Sign in to follow this  
Smart Games

Change Text of an edit box

Recommended Posts

I want to change the text of an edit box, ctrlsettext and ctrlSetStructuredText doesnt work.

 

Any Ideas, 

thanks!

Share this post


Link to post
Share on other sites
6 minutes ago, Smart Games said:

I want to change the text of an edit box, ctrlsettext and ctrlSetStructuredText doesnt work.

 

Any Ideas, 

thanks!

You're out of luck if those commands really don't work.

Unless there's something you're doing wrong, just food for thought.

 

Cheers

Share this post


Link to post
Share on other sites
fnc_save =
{
	params ["_nr1","_nr2","_nr3"];
	_dialog = findDisplay 12345;
	_ctrl1 = _dialog displayCtrl _nr1;
	_ctrl2 = _dialog displayCtrl _nr2;
	_ctrl3 = _dialog displayCtrl _nr3;

	_am1 = ctrlText _ctrl1;
	_am2 = ctrlText _ctrl2;
	_am3 = ctrlText _ctrl3;

	if (_am1 < 200) then {_ctrl1 ctrlSetText "200"; player setVariable ["overall_distance",200]};
    if (_am1 > 5000) then {_ctrl1 ctrlSetText "5000"; player setVariable ["overall_distance",5000]};
    if (_am1 > 200 && _am1 < 5000) then {player setVariable ["overall_distance", _am1]};

    if (_am2 < 200) then {_ctrl2 ctrlSetText "200"; player setVariable ["object_distance",200]};
    if (_am2 > 5000) then {_ctrl2 ctrlSetText "5000"; player setVariable ["object_distance",5000]};
    if (_am2 > 200 && _am2 < 5000) then {player setVariable ["object_distance",_am2]};

    if (_am3 < 50) then {_ctrl3 ctrlSetText "50"; player setVariable ["shadow_distance",50]};
    if (_am3 > 300) then {_ctrl3 ctrlSetText "3000"; player setVariable ["shadow_distance",300]};
    if (_am3 > 50 && _am3 < 300) then {player setVariable ["shadow_distance",_am3]};

	[_am1,_am2,_am3] call fnc_distances;
};

https://www.bilder-upload.eu/bild-69858e-1566135772.png.html //the error

Share this post


Link to post
Share on other sites

It didn't work for me, i found an other solution for my problem 🙂

Share this post


Link to post
Share on other sites

Your problem is that in your conditions you are trying to compare text to a number ...

// Returns text
_am1 = ctrlText _ctrl1;
_am2 = ctrlText _ctrl2;
_am3 = ctrlText _ctrl3;

// Error - checking if text is less than a number
if (_am1 < 200) then {_ctrl1 ctrlSetText "200"; player setVariable ["overall_distance",200]};

The very simple fix for this is to parseNumber for those three variables

// Returns text
_am1 = parseNumber(ctrlText _ctrl1);
_am2 = parseNumber(ctrlText _ctrl2);
_am3 = parseNumber(ctrlText _ctrl3);

// No-error - Checking if a number is less than a number
if (_am1 < 200) then {_ctrl1 ctrlSetText "200"; player setVariable ["overall_distance",200]};

 

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  

×