Whatever follows the string parameter in memory will have first byte (or more, for large numbers) overwritten, if the string is declared as string[10].
Second, when forming temp_str, there's no terminating char added, so concatenation can go wrong depending on what was previously held in memory space assigned to temp_str. This goes with your description
Note also that changing code frequently means rearranging variables in RAM, so while your code runs now, it may stop again after another change.The space between celcius appear ok the first time, after the second press of the button, or the pic freeze or random char appear in the space...
Please try to correct your code by declaring tmp_str as string[11] and adding terminating char to temp_str after copying first four chars from tmp_str (temp_str[4]:=0;), and it should work with both concatenation ways.
BTW,
Code: Select all
strcat2(ButtonRound1_Caption,temp_str,' Celcius');
Code: Select all
ButtonRound1_Caption := ButtonRound1_Caption + temp_str + ' Celcius';
Code: Select all
ButtonRound1_Caption := temp_str + ' Celcius';