Click here to Skip to main content
15,897,518 members

Comments by gmf (Top 2 by date)

gmf 13-Feb-11 11:35am View    
Thanks for every one's input for my question.

I am developing a tool to allow users to do a few things and I used command design pattern.
Users can use my tool to add user, add product, add file, ect to the database. The use use command line to run the tool like this:

>AddUser FirstName="" LastName="" MiddleName=""
>AddFile FileLocation=""
>AddProduct Name="" Price=""
...

So I have comamnds such as AddUser, AddFile and AddProduct. I am looking for a very generic way to parse inputs for all the commnads, at the mean time also handle spaces, ' "".

So I can not use any string functions. This is what I am doing:

In each command, I have properties, those properties will be the user's input. For each example,
AddUser command has properties such as FirstName, MiddleName, and LastName.

When I get the user's input, first I need to figure out which command it is, then I found all the properties from the command, use the name of property to get its value from the input string. So I really did not hard coded any thing.
gmf 12-Feb-11 12:54pm View    
Hi Manfred,

Thanks for the link. I read this link before, still can not figure it out.

I want to get all the information from the input string including Sid, but I only can do it one parameter at each time.

If I want to get all the parameters at one time, I works. The space bewteen the parameter name and = cause the problem. My pattern can not handle it.