WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Functions

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

ParseData Function


Question:

My problem is solved, but my question was about ParseData. Look at this:
data = "Alpha Bravo Charlie O'Neil O'Brian Delta"
ParseData(data)
Message("Substrings",param0)
reverse = StrCat(param5," ",param4," ",param3," ",param2," ",param1)
Message(data,reverse)
This code is from the help on ParseData, but appended the 2 names O'Neil and O'Brian. And then it's not reverse anymore.

Answer:

That is what the parsedata function may be dangerous when used for general purposes. It is attempting to emulate a command line interpreter
O'Niel O'Brian

is equivalent here to 'ONeil OBrian' User Reply: I would have thought that
O'Niel O'Brian
would have been interpreted as
O, 'Niel O', Brian

Answer:

Nope! This gets down into the murky depths of how ParseData() really works. Back before WinBatch could accept & parse more than 9 parameters, I had a need for more sophisticated command line parsing and so I figured out how it really works and then wrote some code to emulated it... but with support for an unlimited # of parameters.

In a nutshell, ParseData() accepts 3 different sorts of quoting characters that are used to denote parameters with embedded whitespace. The double quote, single quote and apostrophe are all quoting characters, and whenever one of them is encountered outside of what is already considered to be a quoted string, then the parser makes note of the fact, discards the quoting character, and reads on until it finds the end of what it is now interpreting as a quoted string. If there's no whitespace before the quoting character, then you'll find that the non-whitespace text before the quoting character becomes part of the parameter that contains embedded whitespace between the quoting characters.


Article ID:   W16976
File Created: 2007:07:03:14:27:26
Last Updated: 2007:07:03:14:27:26