You can use a custom function with recursion. I would look up/research Custom Functions with recursion. Someone will probably be able to help you here.
Some more info: What are the script parameters being passed, and can you give an actual example of what a passed string looks like, and what a character string looks like. A small sample file with some records would help.
Hi Steve, thanks for your answer.
The first parameter is the string to which I want to add characters, for example: "LCH"; the second parameter is the char I want to add, e.g. "0"; the third parameter is how many repetitions of the char I want to add e.g. "5", and the fourth parameter is what side of the passed string I want to concatenate the chr string:
if the script is called with: "LCH¶0¶5¶L" this will be the result "00000LCH"; if it is called with "LCH¶0¶5¶R", the results will be "LCH00000".
Do you have FileMaker Advanced so that you can define this as a recursive function?
There are websites where you can search out and find custom functions created by others and you may well find one for this already.
//CharPad ( String ; PChar ; Ln ; Loc )
// Pad text in String with Ln number of PChar characters as either leading or trailing characters
Case ( Ln < 1 ; String ;
Loc = L ; CharPad ( PChar & String ; PChar ; Ln - 1 ; Loc ) ;
CharPad ( String & PChar ; PChar ; Ln - 1 ; Loc )
Thanks Phil. I'll try it; yes I have Filemaker Pro Advanced. I've been in a few places but I couldn't find a specific solution. I'll keep trying.. Thanks a lot!