Next: , Previous: Length byte, Up: Strings in GPC

3.4.4 Watch out when using strings as parameters

Q: Any “gotchas” with string parameters?

A: Be careful when passing string literals as parameters to routines accepting the string as a value parameter and that internally modify the value of the parameter. Inside the routine, the value parameter gets a fixed capacity – the length of the string literal that was passed to it. Any attempt to assign a longer value will not work.

This only applies if the value parameter is declared as String. If it is declared as a string with a given capacity (e.g., String (255)), it gets this capacity within the routine.