*! v 1.0.0 ARB 15Jul98 STB-46 dm63 program define winset version 5.0 local varlist "opt exist" local options "LIst" if _N == 0 { exit } parse "`*'" if "`list'" == "list" { di in gr _n "WinShow settings for " in ye "$S_FN" parse "`varlist'", parse(" ") while "`1'" != "" { local vlab : var label `1' local len : char `1'[len] local ed : char `1'[noedit] if "`ed'" == "1" { local ed "Yes" } else { local ed "No" } local req : char `1'[req] if "`req'" == "1" { local req "Yes" } else { local req "No" } local vtype : type `1' local vform : format `1' local date 0 if substr("`vform'",1,2) == "%d" { local date 1 local vtype "`vtype', date" } local nostr = (substr("`vtype'",1,3) != "str") local vallab : value label `1' local range : char `1'[range] local def : char `1'[default] di in gr _dup(79) "-" di in ye "`1'" in gr " (`vtype') " in ye "`vlab'" _n if `nostr' & !`date' { if "`vallab'" == "" { di in gr "No value labels defined" } else { di in gr "This variable has value labels," label list `vallab' } } if "`def'" != "" { di in gr "Default value: " in ye "`def'" } di in gr "Edit box length: " in ye "`len'" di in gr "Must enter: " in ye "`req'" di in gr "Editing prohibited: " in ye "`ed'" if "`range'" != "" { local rlo : word 1 of `range' local rhi : word 2 of `range' local rst : word 3 of `range' if "`rst'" != "" { local rst strictly } di in gr "Valid range: " in red "`rst' " in ye "`rlo'" in gr " to " in ye "`rhi'" _c if `date' { di in gr " (" in ye `vform' `rlo' in gr " to " in ye `vform' `rhi' in gr ")" } else { di } } mac shift } exit } global GWSvarl "`varlist'" global GWSt1 "Choose a variable:" global GWSt2 "Variable label (30 max):" global GWSt3 "Valid range:" global GWSt4 "to" global GWSt6 "Length of edit box (characters):" global GWSt7 "Default:" global GWSt8 "Does not apply to string variable" global GWSretr "goretr" global GWScanc "exit 3000" global GWSsave "saveset" global GWSback "exit 3002" global GWShelp "whelp winset" global GWSmod 0 /* Modified settings tripswitch */ chosvar cap exit 1 while _rc != 3000 & _rc !=0 { cap nois window dialog "WinShow settings" . . 180 160 if _rc == 3001 { retrieve } else if _rc == 3002 { chosvar } } if $GWSmod == 1 { window stopbox note "To make your settings permanent you" "should save your dataset now." } macro drop GWS* end program define goretr version 5.0 if "$GWSvar" == "" { window stopbox stop "You must choose a variable first." } exit 3001 end program define chosvar version 5.0 window control static GWSt1 10 10 65 8 window control ssimple GWSvarl 10 18 60 120 GWSvar window control button "Retrieve current settings ->" 80 17 85 12 GWSretr window control button "Cancel" 90 121 60 12 GWScanc end program define retrieve version 5.0 global GWSvlab : var label $GWSvar global GWSlen : char $GWSvar[len] global GWSed : char $GWSvar[noedit] global GWSreq : char $GWSvar[req] global GWSdef : char $GWSvar[default] local vtype : type $GWSvar local vform : format $GWSvar if substr("`vform'",1,2) == "%d" { local vtype "`vtype', date" } local nostr = (substr("`vtype'",1,3) != "str") local vallab : value label $GWSvar if "`vallab'" == "" { global GWSvalab "No value labels defined" } else { global GWSvalab "This variable has value labels" } local range : char $GWSvar[range] if "`range'" == "" { global GWSrlo global GWSrhi global GWSrst } else { global GWSrlo : word 1 of `range' global GWSrhi : word 2 of `range' global GWSrst : word 3 of `range' global GWSrst = ("$GWSrst" == "strict") } global GWSt5 "Settings for: $GWSvar (`vtype')" window control static GWSt5 10 5 115 8 window control static GWSvalab 115 15 60 30 center window control static GWSt6 10 15 100 7 window control edit 10 23 20 8 GWSlen window control static GWSt2 10 35 100 7 window control edit 10 43 100 8 GWSvlab maxlen 30 window control check "Cannot be edited?" 10 55 100 8 GWSed window control check "Must enter?" 10 66 100 8 GWSreq window control static GWSt3 10 80 50 7 window control static GWSt7 110 80 50 7 if `nostr' { window control edit 10 88 30 8 GWSrlo window control static GWSt4 43 88 8 8 window control edit 52 88 30 8 GWSrhi window control check "Never accept values outside this range?" 10 100 135 8 GWSrst } else { window control static GWSt8 10 88 60 20 } window control edit 110 88 50 8 GWSdef window control button "<- Back" 15 115 40 12 GWSback window control button "Save settings" 60 115 60 12 GWSsave window control button "Help" 125 115 40 12 GWShelp window control button "Cancel" 60 132 60 12 GWScanc end program define saveset version 5.0 local vtype : type $GWSvar local str = (substr("`vtype'",1,3) == "str") if "$GWSrlo" != "" | "$GWSrhi" != "" { if `str' { window stopbox stop "You cannot specify a range for a string variable." } } if "$GWSrst" == "1" & ("$GWSrlo" == "" | "$GWSrhi" == "") { window stopbox stop "You have not specified a range." } if ("$GWSrlo" == "" & "$GWSrhi" != "") | ("$GWSrlo" != "" & "$GWSrhi" == "") { window stopbox stop "You must specify both limits of the range." } if "$GWSrlo" != "" & "$GWSrhi" != "" { cap confirm number $GWSrlo if _rc { window stopbox stop "Lower range limit not valid." } cap confirm number $GWSrhi if _rc { window stopbox stop "Upper range limit not valid." } if $GWSrlo > $GWSrhi { window stopbox stop "The lower limit of your range exceeds the upper limit." } if "$GWSrst" == "1" { local rtype "strict" } char $GWSvar[range] "$GWSrlo $GWSrhi `rtype'" } else { char $GWSvar[range] } if "$GWSdef" != "" & `str' == 0 { cap confirm number $GWSdef if _rc { window stopbox stop "Default value not valid -" "$GWSvar is numeric." } } char $GWSvar[default] $GWSdef label var $GWSvar "$GWSvlab" char $GWSvar[len] $GWSlen char $GWSvar[noedit] $GWSed char $GWSvar[req] $GWSreq global GWSmod 1 window stopbox note "The WinShow settings for the $GWSvar" "variable have been saved." end