I know this might sound like a "beginner" question but I know most of the time strings in RPG have a fixed length (but more importantly, have a finite length). But I'm pretty much lost on how to write a procedure for string manipulation.
How can I write a procedure that takes care of a string of whatever length? Can I use this:
text = manip_str(text);
Would it work with all different lengths? Any help would be greatly appreciated.
Yes, a procedure could be defined to handle a string of any valid length. A description of what the procedure needs to do is needed, though. Also, because your example shows that 'text' is used as both the input parameter and the return values, it seems unlikely that you'd want to do this with fixed-length strings. Just from appearances, you should probably be using variable-length strings instead.
So while it's true that "most of the time" strings are fixed-length in RPG, you almost certainly wouldn't use one in this kind of case. The fixed-length strings generally come out of the record oriented data that RPG was designed to process. Such strings are rarely meaningful in "text manipulation" scenarios. Use definitions that are appropriate to the task.
Discuss This Question: 1  Reply
Yes, a procedure could be defined to handle a string of any valid length. A description of what the procedure needs to do is needed, though. Also, because your example shows that 'text' is used as both the input parameter and the return values, it seems unlikely that you'd want to do this with fixed-length strings. Just from appearances, you should probably be using variable-length strings instead.
So while it's true that "most of the time" strings are fixed-length in RPG, you almost certainly wouldn't use one in this kind of case. The fixed-length strings generally come out of the record oriented data that RPG was designed to process. Such strings are rarely meaningful in "text manipulation" scenarios. Use definitions that are appropriate to the task.
Tom