I know you fixed this, but just to give you some extra knowledge.
According to
MSDN, the "+" operator concatenates all expressions (joins two strings)
unless "both expressions are numeric or Boolean". This does not apply to any other mathematical operators though, including the multiplication operator (which can therefore be used to convert strings to numbers). For example:
code:
var Number = "123"; //Number is not a number, but a string with "123"
Number = Number + 56; //The addition operator has concatenated the strings "123" and "56" into "12356", not "179"
Number = Number * 1; //The multiplication operator has converted Number into a Number object
Number = Number + 25; //Number is a Number object, so the addition operator results in 12356 + 25 = 12381
This means that you could alternately have converted your string into a Number by doing this:
code:
if(ControlId=="arrow_left2"){
nudge=10; //just so you know the value
current = ConfigWnd.GetControlText("txt_width")*1
ConfigWnd.SetControlText("txt_width",current+nudge);
OnConfigEvent_CtrlClicked("", "btn_apply");
}
Note that in the original code,
ConfigWnd.GetControlText("txt_width") is actually a string, thereby concatenating
current+nudge, instead of adding. By adding the
*1,
current becomes a Number and the addition works normally.
The reason why
current-(-nudge) also works is because the subtraction operator functions mathematically regardless of whether either expression is a string (like the multiplication), so when you use it, the
current string is automatically converted to a Number object. The addition operator, on the other hand, tried to join the
current string with the
nudge number into one long string, instead of adding them like numbers.
Hope this helps make it easier for you to script with numbers!
NOTE: I haven't looked through the script, but if the
nudge variable is a string as well, that also needs to be converted into a number! Be careful to note that
nudge=10 is different to
nudge="10"! The first is a number, the second is a string!
EDIT: Hehe... missed by a minute, Mattike!