/*
*! stmd dialog version 1.0.0, 24 July 2018, Doug Hemken, dehemken@wisc.edu
*!    for stmd version 1.3, 18 June 2018

Stata Markdown
--------------

stmd filename [ , saving(filename2) replace hardwrap noremove nomsg nostop ]

To install in User Statistics menu via Stata commands:
  
  . window menu append submenu "stUser" "Documents"
  . window menu append item "Documents" "Stata Markdown to HTML (&stmd)" "db stmd"

  . window menu refresh

To permanently install, place these commands in your -profile.do- file.
*/

VERSION 15 

POSITION . . 410 250

DIALOG main, label("stmd - Translate a document to HTML") tabtitle("Main")
BEGIN
  TEXT	tx_source			10  10   . ., label("Source document:")
  FILE     file_source      10 +20   390  ., error("Source document") ///
	label("Browse")
  TEXT	tx_target			10 +25 . ., label("Target document:")
  FILE     file_target      10 +20   390  ., error("Target document") ///
	label("Browse")
CHECKBOX cb_replace  15 +25 . ., label("replace target document")
CHECKBOX cb_hardwrap 15 +25 . ., label("hardwrap - line breaks preserved")
CHECKBOX cb_nomsg      15 +25 . ., label("nomsg - no output file note")
CHECKBOX cb_nostop   15 +25 . ., label("nostop - ignore errors")
END

OK ok1,      label("OK")
CANCEL can1, label("Cancel")
SUBMIT sub1, label("Submit")
HELP hlp1,   view("help stmd")
RESET res1
COPY copy1

PROGRAM command
BEGIN
    put "stmd "
    require main.file_source
    put `"""' main.file_source `"""' " "
    put ", "
	if main.file_target.isneq("") {
		put "saving(" `"""' main.file_target `"""' ") "
	}
	if main.cb_replace {
		put "replace "
	}
	if main.cb_hardwrap {
		put "hardwrap "
	}
	if main.cb_nomsg {
		put "nomsg "
	}
	if main.cb_nostop {
		put "nostop "
	}
END