www.fireflysoftware.com

Help Screen to C++ String


Suppose you're re-doing the help screens for numerous console utility applications written in C++.  You have a choice.  You can either directly modify the necessary logic in each application which might look something like the following user-unfriendly multi-line statement...  

Help = "YesNo V1.0 -- Prompts for a yes/no response\n\n" +
"This 32-bit program prompts for a yes/no response from the user.\n\n" +
"Usage:\n\n" +
" YesNo <Prompt> [<Default>]\n\n" +
" where:\n\n" +
" <Prompt> is the string used to prompt the user.\n" +
" <Default> is the default response taken when <Enter> is pressed.\n\n" +
"Batch example:\n\n" +
" YesNo \"Install Communications Software (Y/N, Enter=Y)?\" Y\n" +
" if not errorlevel 1 goto END\n\n" +
" echo Installing Comm Software ...\n\n" +
" :END\n\n" +
"Find more FREE software utilities at www.fireflysoftware.com!\n";

... or you can use TEXTools like a form painter by carrying out the following steps:

1) First, run the utility without parameters in the console window to get it's help screen:

2) Copy the text from the help screen into TEXTools' input text memo and make all your desired changes.  No need to worry about syntax...  Just format it!

3) Copy the following pipe into TEXTools (or load it from the pipe, "Help Screen to C++ String.ttp" found in the "Sample Pipes" subfolder beneath TEXTool's installation folder):

; Remove any trailing spaces:

TrimLinesRight 

; Translate any existing quote marks to backslash and quote:

ReplStr '"' '\"'

; Surround with quotes and add a newline placeholder plus
; a concatenation placeholder at end of each line:

InsStr 1 '"'
AppendStr '[CR]"[~]'

; Join the lines and then move all newline placeholders 
; representing blank lines onto their prior lines:

JoinLines
ReplStr '[CR]"[~]"[CR]' '[CR][CR]' '[CR]"[~]"[CR]' '[CR][CR]'

; Remove placeholder appended to the last line and add ";":

StripChars 8
AppendStr '";'

; Replace "[~]" with string concatenation operator (+) and a 
; line break and translate the newline placeholders:

ReplStr '[~]' ' +#0d#0a' '[CR]' '\n'

4) Finally, run the pipe. What it outputs is the string constant shown at the beginning, (minus "Help = ") except that now, your changes are incorporated.

 

[Home] [Contact Us] [Downloads] [Purchase/Register]

Copyright © 2005 Firefly Software