@Dare: I like your idea for dealing with indent tabs/spaces for a continued line.
Regarding the inclusion of DoubleQuotes in a string I favor the use of "" for each double quote included. I've used this in other programming languages and found it readable and usable and simple.
Code: Select all
LStringVar="This is a long 'string' that _
can contain quotes, '""', _
spaces, line feeds And "_
+Chr(34)+" Until the doublequote _
at the End."
This includes the idea of long strings, long lines, and quotes and would be interpreted as this:
Code: Select all
LStringVar="This is a long 'string' that can contain quotes, '"', spaces, line feeds And "+Chr(34)+" Until the doublequote at the End."
The format for DoubleQuotes would give you these variations:
Code: Select all
"" = Null string
"""" = A single doublequote
"""""" = Two doublequotes
At the risk of being verbose, this means that for a quoted string it would always start with a doublequote and end with a doublequote and anywhere there was a pair of doublequotes withing it would include a single doublequote as a character in the string.
In dealing with the underscore character '_' used to show line continuation, it's rules would be as follows: If a string has been started with a doublequote then a underscore at the end of a line would show a continuation of the string or line (this would be interpreted as removing the underscore + CRLF + whitespace on next line, then appending the following line to this one). If while continuing a string a underscore character(s) is desired in the string this could be done by simply including the desired characters plus one more to show continuation.
In dealing with CRLF inclusion in a string, this could be down by using the continuation character at the beginning of a line (after indentation) and before the ending doublequotes appear.
To combine this jumble of rules together into a sample, it would appear thus:
Code: Select all
SstringVar = "This is the first ""short"" string."
LstringVar1 = "This is the first string, just _
long."
LstringVar2 = "This is a long string with an _
""_"" in it."
LstringVar3 = "This is a long string with an ""__
"" in it,
_and a carriage return."
LstringVar4 = "This is long string #" + str_num _
+ " with a
_carriage return and an ""_"" in _
it for the
_variable str_num."
avg_length = (82 / (78 + 4)) * total_string_lengths _
/ (str_num + 5 - (2 + 3))
It would produce the equivalent of:
Code: Select all
SstringVar = "This is the first "short" string."
LstringVar1 = "This is the first string, just long."
LstringVar2 = "This is a long string with an "_" in it."
LstringVar3 = "This is a long string with an "_" in it,
and a carriage return."
LstringVar4 = "This is long string #"+str_num+" with a
carriage return and an "_" in it for the
variable str_num."
avg_length = (82 / (78 + 4)) * total_string_lengths / (str_num + 5 - (2 + 3))
And to ramble on further, the caveats to these rules would be: no comments on a line that will be have the continuation character at the end (its long enough already!). If a variable name is present just before the continuation character, there must be a space between it and the continuation character (if an underscore is being used). Indentation will most likely be set for the continued lines, which means they may be difficult to read if no additional indentation is provided for them. When a continuation character is used at the end of a line, all tabs/spaces between it and the CRLF for that line have to be removed.
The rules mentioned IMHO would deal with most of the issues mentioned thus far. These being: CRLF in strings, long strings, continuation of lines, comments, included doublequotes (and in small part the "ugly" problem).
Exisiting code would still function fine with these rules implemented, thus allowing the use of existing code with no updates being made. Along the same lines, you can use any existing method such as macros, "line"+CRLF$+"next line", or extremely long lines with no penalty.
