Author: tum_twish [ Thu Apr 17, 2003 9:58 am ] Post subject: String Substitution I have string that displays the sum of various numbers. The string is concatenated in a loop. However, at the end of the calculation, an extra "+" displays. How can I remove that plus sign? ie. 2+5+7+9+10+=33 How do I remove the last + sign? Thanx.

 Author: jamez [ Thu Apr 17, 2003 10:22 am ] Post subject: hmm can i see teh code?

 Author: Lone]2 [ Thu Apr 17, 2003 10:28 am ] Post subject: maybe you're just exiting the loop too late. try exiting the loop sooner so that the "+" wont show up at the end of your equation

Author:  tum_twish [ Thu Apr 17, 2003 10:41 am ]
Post subject:

 code: function Sum_Of_The_Proper_Factors (I_number : int, B_flag : boolean) : int     %This function calculates the sum of the proper factors of a number     %The function requires the number     %The function returns the sum of proper factors back.     var I_sum : int := 0     S_factorsString := ""     for I_factor : 1 .. (I_number - 1)         if I_number mod I_factor = 0 then             I_sum := I_sum + I_factor             S_factorsString := S_factorsString + intstr (I_factor) + "+"         end if     end for     result I_sum end Sum_Of_The_Proper_Factors S_sumOfFactorsString := intstr (Sum_Of_The_Proper_Factors (I_number,             B_flag)) GUI.SetText (I_factorsOutput, S_factorsString + "=" +                 S_sumOfFactorsString)

 Author: Blade [ Thu Apr 17, 2003 10:42 am ] Post subject: please, if you are having problems with code or anything like that, please post the code... or even give an example of what you want... in your case the example wont help much so please post the code...

 Author: tomako [ Thu Apr 17, 2003 10:47 am ] Post subject: im not good at programming, but logically speaking, y dont u just forget about displaying the "+"s? u can put a space or sumthing instead Author: Office of the Registar [ Thu Apr 17, 2003 2:29 pm ] Post subject: that's the kind of attitude that should get you kicked out of this field tomako Author: Office of the Registar [ Thu Apr 17, 2003 2:43 pm ] Post subject: i can't beleive you guys are just wasting time like this

 Author: Leafs Fan [ Thu Apr 17, 2003 2:45 pm ] Post subject: course heheh

 Author: Tony [ Thu Apr 17, 2003 2:56 pm ] Post subject: you can use substrings to get rid of the last character (the unwanted +) word := word(1..*-1) then you add "= whatever"

Author:  yuethomas [ Thu Apr 17, 2003 10:37 pm ]
Post subject:

Or, don't append the plus sign... do an if statement for it

 code: for I_factor : 1 .. (I_number - 1)         if I_number mod I_factor = 0 then             I_sum := I_sum + I_factor             S_factorsString := S_factorsString + intstr (I_factor) %--             if I_factor (notequal) I_Number - 1 then                 S_factorsString := S_factorsString + "+"             end if %--         end if     end for

notequal: I forgot the operator for it. ~=?

 :