Hello Statalisters,
I am trying to write a program with an option that the user can specify as true or false. If the property is given as "option(true)", I want the command to do one thing, if it's given as "option(false)", I want it to do something else.
How could I write a Stata command that accepts a boolean property?
Here is the code for my ado file:
Here is the code I type in the console to run this program:
This code returns the error "invalid syntax" for the line "syntax, red(boolean)". I have successfully passed strings, varnames and varlists with syntax to custom commands I've written in the past with similar code--can I pass a boolean like this? If so, how?
Thank you and please let me know if I can clarify this question in any way.
I am trying to write a program with an option that the user can specify as true or false. If the property is given as "option(true)", I want the command to do one thing, if it's given as "option(false)", I want it to do something else.
How could I write a Stata command that accepts a boolean property?
Here is the code for my ado file:
Code:
syntax, red(boolean) if red == true{ di in red "Hello world" } if else { di "Hello world" } end
Code:
set trace on helloworld, red(true)
Thank you and please let me know if I can clarify this question in any way.
Comment