Hi all,
I am working on a command that uses syntax to parse user input. One option, rowlabel, allows for sub-options (there are more options but they are omitted here for simplicity). I use syntax to parse the user input like this:
where the option rowlabel both has keywords and sub-options, for example, like this:
Instead of the keyword label the user could also enter name. After syntax parses the user input, I have a local called rowlabel that holds the string "label , text(divorce divorce rate)". I would then like to do something similar to using syntax again to parse the content of the local rowlabel. Is there any best practice how to parse that so that I get the following three locals:
I could manually parse that myself using gettoken, but since this should be fairly common I thought that there might be a tool for this. I am considering creating a sub-command that takes the content of local rowlabel as input that parse the string using syntax and return it as locals in the r() results. That might be the best way, but I wanted to ask if there is an even better way out there.
With the sub-command I would first remove the comma in rowlabel, pass the content of rowlabel as input to the sub-commandand then use syntax like this:
Any better ideas?
I am working on a command that uses syntax to parse user input. One option, rowlabel, allows for sub-options (there are more options but they are omitted here for simplicity). I use syntax to parse the user input like this:
Code:
syntax varlist , rowlabel(string)
Code:
rowlabel(label , text(divorce divorce rate))
Code:
local label "label" local name "" local text "divorce divorce rate"
With the sub-command I would first remove the comma in rowlabel, pass the content of rowlabel as input to the sub-commandand then use syntax like this:
Code:
syntax , [label name text(string)] return local name "`name'" return local label "`label'" return local text `"`text'"'
Comment