Side effect with string buffer and function calls

Language reference ›› Procedures and functions ››
Parent Previous Next

In processors smaller than PIC18, PMP uses only one string temporary buffer for space reduction.

In another side, there's no stack where to save a string buffer.

In this context there is a special side effect when there is a function call in a string expression if there is also a string expression in the called function.


Consider the following code:



FUNCTION Func1: string;
 BEGIN
   // assume that Var1 contains #13
   Func1 := '-foo' + Var1 + 'bar-';
 END;

StringVar := 'hello' + Func1 + 'world';


StringVar will contain '-foo' + #13 + 'bar-' + 'world' because 'hello' was pushed in the string buffer and the string buffer has been destroyed in the Func1 function.