I have a need to process template file which will contain a few place holders like for example <<>>.
I have never had to do this type of work so I don’t know as to how to load a user selected text file and replace a few place holders with user entered text.
I want to read the original file, make changes to its content and then save it to a temp file in the application folder under a different name.
Use folderitem.ShowOpenFileDialog() to get the user-selected file
Open it as a textinputstream and use ReadAll to read it into a string
Use string.IndexOf or a regex to find your placeholders. Note that if the placeholder can also occur elsewhere, e.g. inside a string or comment, you may need more sophisticated parsing to correctly identify the placeholders.
Find the beginning and end of each placeholder, and then update the string something like:
Note that you’ll need to be careful about including the placeholder delimiters, as well as keep in mind that middle() and index() are now zero-based – watch out for off-by-one errors.
Work through the source string, repeating for all placeholders.
Save the string back out by creating the new file as a textoutputstream and writing the string to it.