/3.1
(Extension.1
	Name:	"CAP_MAPX"
	Dependencies:	"$AVBIN/avdlog.dll\n$AVEXT/spatial.avx\n"
	FirstRootClassName:	"PMenu"
	Roots:	2
	Roots:	22
	Roots:	25
	Roots:	39
	Roots:	94
	Roots:	137
	Roots:	163
	Roots:	208
	Roots:	227
	Roots:	250
	Roots:	282
	Roots:	301
	Roots:	321
	Roots:	345
	Roots:	346
	Roots:	347
	Roots:	348
	Roots:	349
	Roots:	350
	Roots:	351
	Roots:	352
	Roots:	353
	Roots:	354
	Roots:	355
	Roots:	356
	Roots:	357
	Roots:	358
	Roots:	359
	Roots:	360
	Roots:	361
	Roots:	362
	Roots:	363
	Roots:	364
	Roots:	365
	Roots:	366
	Roots:	367
	Roots:	368
	Roots:	369
	Roots:	370
	Roots:	371
	Roots:	372
	Roots:	373
	Roots:	374
	Roots:	375
	Roots:	376
	Roots:	377
	Roots:	378
	Roots:	379
	Roots:	380
	Roots:	381
	Roots:	382
	Roots:	383
	Roots:	3
	Roots:	384
	Roots:	385
	Roots:	386
	Roots:	387
	Roots:	388
	Roots:	389
	Roots:	390
	Roots:	391
	Roots:	392
	Roots:	393
	Roots:	394
	Roots:	395
	Roots:	396
	Roots:	397
	Roots:	398
	Roots:	399
	Roots:	400
	Roots:	401
	Roots:	402
	Roots:	403
	Roots:	404
	Roots:	405
	Roots:	406
	Roots:	407
	Roots:	408
	Roots:	409
	Roots:	410
	Roots:	411
	Roots:	412
	Roots:	413
	Roots:	414
	Roots:	415
	Roots:	416
	Roots:	417
	Roots:	418
	Roots:	419
	Roots:	420
	Roots:	421
	Roots:	422
	Roots:	423
	Roots:	424
	Roots:	425
	Roots:	426
	Roots:	427
	Roots:	428
	Roots:	429
	Roots:	430
	Roots:	431
	Roots:	432
	Roots:	433
	Roots:	434
	Roots:	435
	Roots:	436
	Roots:	437
	Roots:	438
	Roots:	439
	Roots:	440
	Roots:	441
	Roots:	442
	Roots:	443
	Roots:	444
	Roots:	445
	Roots:	446
	Roots:	447
	Roots:	448
	Roots:	449
	Roots:	450
	Roots:	451
	Roots:	452
	Roots:	453
	Roots:	454
	Roots:	455
	Roots:	456
	Roots:	457
	Roots:	458
	Roots:	459
	Roots:	460
	Roots:	461
	Roots:	462
	Roots:	463
	Roots:	464
	Roots:	465
	Roots:	466
	Roots:	467
	Roots:	468
	Roots:	469
	Roots:	470
	Roots:	471
	Roots:	472
	Version:	31
	About:	"CAP Proto 1.1.8 - HL Option"
	CanUnloadScript:	357
	UnloadScript:	406
	InstallScript:	388
	UninstallScript:	404
	ExtVersion:	1
)

(PMenu.2
	ObjectTag:	3
	Child:	4
	Child:	5
	Child:	6
	Child:	7
	Child:	8
	Child:	9
	Child:	10
	Child:	11
	Child:	12
	Child:	13
	Child:	14
	Child:	15
	Child:	16
	Child:	17
	Child:	18
	Child:	19
	Child:	20
	Child:	21
	Label:	"&CAP"
)

(Nil.3
)

(Choice.4
	Label:	"&Setup"
	Click:	"cap.setup"
	Shortcut:	"Keys.None"
)

(Choice.5
	Help:	"RFCView must be active"
	Label:	"&Pre-compute Statistics"
	Click:	"cap.prestatistics"
	Shortcut:	"Keys.None"
)

(Choice.6
	Disabled:	1
	Help:	"Clip data for selected basin and create a new subbasin view."
	Tag:	"bmdc2"
	Update:	"cap.createsubview.update"
	Label:	"Create SubView for Selected Basin"
	Click:	"cap.createsubview"
	Shortcut:	"Keys.None"
)

(Space.7
)

(Choice.8
	Disabled:	1
	Update:	"cap.subviewactive.update"
	Label:	"&Plot Graph"
	Click:	"cap.rundlg_xygraph"
	Shortcut:	"Keys.None"
)

(Choice.9
	Disabled:	1
	Update:	"cap.subviewactive.update"
	Label:	"Subdivide Basin"
	Click:	"cap.rundlg_sub"
	Shortcut:	"Keys.None"
)

(Choice.10
	Disabled:	1
	Update:	"cap.subviewactive.update"
	Label:	"Statistics"
	Click:	"cap.rundlg_stats"
	Shortcut:	"Keys.None"
)

(Choice.11
	Disabled:	1
	Update:	"cap.subviewactive.update"
	Label:	"Snow Data"
	Click:	"cap.snowview"
	Shortcut:	"Keys.None"
)

(Space.12
)

(Space.13
)

(Choice.14
	Update:	"ofs.dialog.update"
	Label:	"OFS PPINIT"
	Click:	"ofs.dialog.open"
	Shortcut:	"Keys.None"
)

(Choice.15
	Update:	"ofs.dialog.update"
	Label:	"Run @ORDER"
	Click:	"util.ofs.runorder"
	Shortcut:	"Keys.None"
)

(Choice.16
	Label:	"Load OFS PPINIT Data"
	Click:	"util.ofs.loadOfs"
	Shortcut:	"Keys.None"
)

(Space.17
)

(Choice.18
	Label:	"Clear Object Tags"
	Click:	"cap.clearobjecttags"
	Shortcut:	"Keys.None"
)

(Choice.19
	Label:	"View Object Tags"
	Click:	"util.viewobjecttags"
	Shortcut:	"Keys.None"
)

(Choice.20
	Label:	"Edit Object Tags"
	Click:	"util.editobjecttags"
	Shortcut:	"Keys.None"
)

(Space.21
)

(Butn.22
	Help:	"Provides an option to convert legend display units for the active Theme "
	ObjectTag:	23
	Icon:	24
	Click:	"util.legendconversion"
)

(Nil.23
)

(AVIcon.24
	Name:	"U"
	Res:	"Icons.U"

)

(AVDLog.25
	Name:	"dlg_coords"
	X:	64
	Y:	201
	W:	183
	H:	329
	ConstrainedControlNames:	26
	ConstrainedControlNames:	27
	Constraints:	28
	Constraints:	29
	Server:	3
	ControlPanel:	30
	ObjectTag:	3
	Title:	"X-Y Coordinates"
	EscapeEnabled:	1
	Resizable:	1
	AlwaysOnTop:	1
	HasTitleBar:	1
	Closeable:	1
	DefaultButton:	38
)

(AVStr.26
	S:	"lbt_ok"
)

(AVStr.27
	S:	"lbt_copy"
)

(Numb.28
	N:	85.00000000000000
)

(Numb.29
	N:	85.00000000000000
)

(CPanel.30
	Child:	31
	Child:	33
	Child:	34
	ResBox:	35
	ResBox:	36
	ResBox:	37
	Listening:	1
)

(TextBox.31
	InternalName:	"tbx_coords"
	Listening:	1
	Constraints:	0x55
	VerticalScroll:	1
	NextControl:	32
)

(Nil.32
)

(LButn.33
	InternalName:	"lbt_ok"
	Label:	"OK"
	Click:	"cap.xygraph.dlg_coords.lbt_ok.click"
)

(LButn.34
	InternalName:	"lbt_copy"
	Help:	"Copy ALL (not just displayed) text to the system clipboard."
	Label:	"Copy"
	Click:	"cap.xygraph.dlg_coords.lbt_copy.click"
)

(RectD.35
	Left:	26.00000000000000
	Top:	257.00000000000000
	Right:	160.00000000000000
	Bottom:	25.00000000000000
)

(RectD.36
	Left:	98.00000000000000
	Top:	302.00000000000000
	Right:	146.00000000000000
	Bottom:	277.00000000000000
)

(RectD.37
	Left:	32.00000000000000
	Top:	302.00000000000000
	Right:	81.00000000000000
	Bottom:	277.00000000000000
)

(Nil.38
)

(AVDLog.39
	Name:	"dlg_stats"
	X:	33
	Y:	68
	W:	434
	H:	438
	ConstrainedControlNames:	40
	ConstrainedControlNames:	41
	Constraints:	42
	Constraints:	43
	Server:	3
	ControlPanel:	44
	ObjectTag:	3
	Title:	"Compute Statistics"
	EscapeEnabled:	1
	Resizable:	1
	AlwaysOnTop:	1
	HasTitleBar:	1
	Closeable:	1
	Open:	"cap.dlg_stats.open"
	DefaultButton:	93
)

(AVStr.40
	S:	"lbt_ok"
)

(AVStr.41
	S:	"lbt_cancel"
)

(Numb.42
	N:	85.00000000000000
)

(Numb.43
	N:	85.00000000000000
)

(CPanel.44
	Child:	45
	Child:	46
	Child:	47
	Child:	48
	Child:	49
	Child:	50
	Child:	51
	Child:	52
	Child:	53
	Child:	54
	Child:	55
	Child:	56
	Child:	57
	Child:	58
	Child:	60
	Child:	62
	Child:	63
	Child:	64
	Child:	65
	Child:	66
	Child:	67
	Child:	68
	Child:	69
	ResBox:	70
	ResBox:	71
	ResBox:	72
	ResBox:	73
	ResBox:	74
	ResBox:	75
	ResBox:	76
	ResBox:	77
	ResBox:	78
	ResBox:	79
	ResBox:	80
	ResBox:	81
	ResBox:	82
	ResBox:	83
	ResBox:	84
	ResBox:	85
	ResBox:	86
	ResBox:	87
	ResBox:	88
	ResBox:	89
	ResBox:	90
	ResBox:	91
	ResBox:	92
	Listening:	1
)

(AVCBox.45
	InternalName:	"chk_elev"
	Listening:	1
	Label:	"Elevation"
	Constraints:	0x55
)

(AVCBox.46
	InternalName:	"chk_ppt"
	Listening:	1
	Label:	"Precipitation"
	Constraints:	0x55
)

(AVCBox.47
	InternalName:	"chk_forest"
	Listening:	1
	Label:	"Forest Density"
	Constraints:	0x55
)

(AVCBox.48
	InternalName:	"chk_detforest"
	Listening:	1
	Label:	"Detailed Forest Types"
	Constraints:	0x55
)

(TextLabel.49
	InternalName:	"aTextLabel40"
	Constraints:	0x55
	Label:	"Winter:"
	Listening:	1
)

(LButn.50
	InternalName:	"lbt_ok"
	Label:	"OK"
	Click:	"cap.dlg_stats.lbt_ok2.click"
)

(LButn.51
	InternalName:	"lbt_cancel"
	Label:	"Cancel"
	Click:	"cap.dlg_stats.lbt_cancel.click"
)

(AVCBox.52
	InternalName:	"chk_seasonal"
	Listening:	1
	Label:	"Define Seasons for Precip, Temp, and PE Calculations"
	Click:	"cap.dlg_stats.chk_seasonal"
	Constraints:	0x55
)

(AVCBBox.53
	InternalName:	"cbx_winter_from"
	NextControl:	32
	ContentKind:	4
	Constraints:	0x55
	Listening:	1
	Select:	"cap.dlg_stats.cbx_winter.select"
)

(AVCBBox.54
	InternalName:	"cbx_winter_to"
	NextControl:	32
	ContentKind:	4
	Constraints:	0x55
	Listening:	1
	Select:	"cap.dlg_stats.cbx_winter.select"
)

(TextLabel.55
	InternalName:	"aTextLabel15"
	Constraints:	0x55
	Label:	"From Beginning of:"
	Listening:	1
)

(TextLabel.56
	InternalName:	"aTextLabel16"
	Constraints:	0x55
	Label:	"To end of:"
	Listening:	1
)

(CPanel.57
	InternalName:	"aControlPanel2"
	Constraints:	0x55
	Listening:	1
)

(TextLine.58
	InternalName:	"txl_summer_from"
	Label:	" "
	Constraints:	0x55
	Listening:	1
	ReadOnly:	1
	TextType:	59
	NextControl:	32
)

(AVEnum.59
	Name:	"TEXTLINE_TYPE_ALL"
)

(TextLine.60
	InternalName:	"txl_summer_to"
	Label:	" "
	Constraints:	0x55
	Listening:	1
	ReadOnly:	1
	TextType:	61
	NextControl:	32
)

(AVEnum.61
	Name:	"TEXTLINE_TYPE_ALL"
)

(TextLabel.62
	InternalName:	"aTextLabel3"
	Constraints:	0x55
	Label:	"Summer:"
	Listening:	1
)

(AVCBox.63
	InternalName:	"chk_all"
	Listening:	1
	Label:	"Compute All Statistics"
	Click:	"cap.dlg_stats.chk_all.click"
	Constraints:	0x55
)

(AVCBox.64
	InternalName:	"chk_zonal"
	Listening:	1
	Label:	"Make Zonal Calculations"
	Constraints:	0x55
)

(CPanel.65
	InternalName:	"aControlPanel4"
	Constraints:	0x55
	Listening:	1
)

(AVCBox.66
	InternalName:	"chk_sacsma"
	Listening:	1
	Label:	"Mean Soil-based SAC-SMA "
	Constraints:	0x55
)

(AVCBox.67
	InternalName:	"chk_tmp"
	Disabled:	1
	Invisible:	1
	Listening:	1
	Label:	"Temperature"
	Constraints:	0x55
)

(AVCBox.68
	InternalName:	"chk_pe"
	Listening:	1
	Label:	"Potential Evaporation"
	Constraints:	0x55
)

(TextLabel.69
	InternalName:	"txt_selstats"
	Constraints:	0x55
	Label:	"Only Selected Stats:"
	Listening:	1
)

(RectD.70
	Left:	45.00000000000000
	Top:	184.00000000000000
	Right:	168.00000000000000
	Bottom:	165.00000000000000
)

(RectD.71
	Left:	43.00000000000000
	Top:	133.00000000000000
	Right:	178.00000000000000
	Bottom:	108.00000000000000
)

(RectD.72
	Left:	236.00000000000000
	Top:	146.00000000000000
	Right:	379.00000000000000
	Bottom:	130.00000000000000
)

(RectD.73
	Left:	238.00000000000000
	Top:	172.00000000000000
	Right:	396.00000000000000
	Bottom:	156.00000000000000
)

(RectD.74
	Left:	29.00000000000000
	Top:	315.00000000000000
	Right:	88.00000000000000
	Bottom:	297.00000000000000
)

(RectD.75
	Left:	231.00000000000000
	Top:	50.00000000000000
	Right:	304.00000000000000
	Bottom:	23.00000000000000
)

(RectD.76
	Left:	318.00000000000000
	Top:	49.00000000000000
	Right:	394.00000000000000
	Bottom:	23.00000000000000
)

(RectD.77
	Left:	30.00000000000000
	Top:	257.00000000000000
	Right:	319.00000000000000
	Bottom:	233.00000000000000
)

(RectD.78
	Left:	99.00000000000000
	Top:	321.00000000000000
	Right:	234.00000000000000
	Bottom:	295.00000000000000
)

(RectD.79
	Left:	264.00000000000000
	Top:	325.00000000000000
	Right:	387.00000000000000
	Bottom:	295.00000000000000
)

(RectD.80
	Left:	107.00000000000000
	Top:	289.00000000000000
	Right:	212.00000000000000
	Bottom:	266.00000000000000
)

(RectD.81
	Left:	281.00000000000000
	Top:	278.00000000000000
	Right:	364.00000000000000
	Bottom:	265.00000000000000
)

(RectD.82
	Left:	19.00000000000000
	Top:	219.00000000000000
	Right:	332.00000000000000
	Bottom:	210.00000000000000
)

(RectD.83
	Left:	101.00000000000000
	Top:	356.00000000000000
	Right:	236.00000000000000
	Bottom:	336.00000000000000
)

(RectD.84
	Left:	260.00000000000000
	Top:	355.00000000000000
	Right:	389.00000000000000
	Bottom:	335.00000000000000
)

(RectD.85
	Left:	26.00000000000000
	Top:	360.00000000000000
	Right:	90.00000000000000
	Bottom:	341.00000000000000
)

(RectD.86
	Left:	30.00000000000000
	Top:	40.00000000000000
	Right:	201.00000000000000
	Bottom:	19.00000000000000
)

(RectD.87
	Left:	30.00000000000000
	Top:	69.00000000000000
	Right:	223.00000000000000
	Bottom:	40.00000000000000
)

(RectD.88
	Left:	18.00000000000000
	Top:	82.00000000000000
	Right:	330.00000000000000
	Bottom:	73.00000000000000
)

(RectD.89
	Left:	96.00000000000000
	Top:	215.00000000000000
	Right:	311.00000000000000
	Bottom:	199.00000000000000
)

(RectD.90
	Left:	188.00000000000000
	Top:	133.00000000000000
	Right:	270.00000000000000
	Bottom:	108.00000000000000
)

(RectD.91
	Left:	45.00000000000000
	Top:	164.00000000000000
	Right:	219.00000000000000
	Bottom:	139.00000000000000
)

(RectD.92
	Left:	25.00000000000000
	Top:	109.00000000000000
	Right:	172.00000000000000
	Bottom:	91.00000000000000
)

(Nil.93
)

(AVDLog.94
	Name:	"dlg_subbsn"
	X:	74
	Y:	65
	W:	424
	H:	244
	ConstrainedControlNames:	95
	ConstrainedControlNames:	96
	ConstrainedControlNames:	97
	ConstrainedControlNames:	98
	Constraints:	99
	Constraints:	100
	Constraints:	101
	Constraints:	102
	Server:	3
	ControlPanel:	103
	ObjectTag:	3
	Title:	"Basin Subdivision"
	EscapeEnabled:	1
	Resizable:	1
	AlwaysOnTop:	1
	HasTitleBar:	1
	Closeable:	1
	DefaultButton:	136
)

(AVStr.95
	S:	"lbt_ok"
)

(AVStr.96
	S:	"aLabelButton19"
)

(AVStr.97
	S:	"aLabelButton2"
)

(AVStr.98
	S:	"lbt_reset"
)

(Numb.99
	N:	85.00000000000000
)

(Numb.100
	N:	85.00000000000000
)

(Numb.101
	N:	85.00000000000000
)

(Numb.102
	N:	85.00000000000000
)

(CPanel.103
	Child:	104
	Child:	106
	Child:	107
	Child:	108
	Child:	109
	Child:	110
	Child:	112
	Child:	114
	Child:	115
	Child:	116
	Child:	117
	Child:	119
	Child:	121
	ResBox:	123
	ResBox:	124
	ResBox:	125
	ResBox:	126
	ResBox:	127
	ResBox:	128
	ResBox:	129
	ResBox:	130
	ResBox:	131
	ResBox:	132
	ResBox:	133
	ResBox:	134
	ResBox:	135
	Listening:	1
)

(TextLine.104
	InternalName:	"txtln1"
	Constraints:	0x55
	Listening:	1
	TextType:	105
	NextControl:	32
)

(AVEnum.105
	Name:	"TEXTLINE_TYPE_ALL"
)

(LButn.106
	InternalName:	"lbt_ok"
	Label:	"OK"
	Click:	"cap.dlg_subbsn.lbt_ok.click"
)

(LButn.107
	InternalName:	"aLabelButton19"
	Label:	"Cancel"
	Click:	"cap.dlg_subbsn.lbt_close.click"
)

(LButn.108
	InternalName:	"aLabelButton2"
	Label:	"Equal Interval"
	Click:	"cap.dlg_subbsn.lbt_eqint.click"
)

(LButn.109
	InternalName:	"lbt_reset"
	Label:	"Clear"
	Click:	"cap.dlg_subbsn.lbt_clear.click"
)

(TextLine.110
	InternalName:	"txl_min"
	Label:	"From Min:"
	Constraints:	0x55
	Listening:	1
	ReadOnly:	1
	TextType:	111
	NextControl:	32
)

(AVEnum.111
	Name:	"TEXTLINE_TYPE_ALL"
)

(TextLine.112
	InternalName:	"txl_max"
	Label:	"To Max:"
	Constraints:	0x55
	Listening:	1
	ReadOnly:	1
	TextType:	113
	NextControl:	32
)

(AVEnum.113
	Name:	"TEXTLINE_TYPE_ALL"
)

(TextLabel.114
	InternalName:	"aTextLabel1"
	Constraints:	0x55
	Label:	"Number of Elev Breaks"
	Listening:	1
)

(TextLabel.115
	InternalName:	"txl1"
	Constraints:	0x55
	Label:	"ELEVATION BREAKS (m)"
	Listening:	1
)

(AVCBBox.116
	InternalName:	"cbx_numbreaks"
	Update:	"cap.dlg_subbsn.cbx_numbreaks.update"
	NextControl:	32
	ContentKind:	4
	Constraints:	0x55
	Listening:	1
	Select:	"cap.dlg_subbsn.cbx_numbreaks.update"
)

(TextLine.117
	InternalName:	"txtln4"
	Update:	"cap.dlg_subbsn.txtln4.update"
	Constraints:	0x55
	Listening:	1
	TextType:	118
	NextControl:	32
)

(AVEnum.118
	Name:	"TEXTLINE_TYPE_ALL"
)

(TextLine.119
	InternalName:	"txtln3"
	Update:	"cap.dlg_subbsn.txtln3.update"
	Constraints:	0x55
	Listening:	1
	TextType:	120
	NextControl:	32
)

(AVEnum.120
	Name:	"TEXTLINE_TYPE_ALL"
)

(TextLine.121
	InternalName:	"txtln2"
	Update:	"cap.dlg_subbsn.txtln2.update"
	Constraints:	0x55
	Listening:	1
	TextType:	122
	NextControl:	32
)

(AVEnum.122
	Name:	"TEXTLINE_TYPE_ALL"
)

(RectD.123
	Left:	78.00000000000000
	Top:	105.00000000000000
	Right:	201.00000000000000
	Bottom:	85.00000000000000
)

(RectD.124
	Left:	279.00000000000000
	Top:	192.00000000000000
	Right:	396.00000000000000
	Bottom:	168.00000000000000
)

(RectD.125
	Left:	279.00000000000000
	Top:	228.00000000000000
	Right:	395.00000000000000
	Bottom:	204.00000000000000
)

(RectD.126
	Left:	281.00000000000000
	Top:	117.00000000000000
	Right:	392.00000000000000
	Bottom:	94.00000000000000
)

(RectD.127
	Left:	281.00000000000000
	Top:	158.00000000000000
	Right:	391.00000000000000
	Bottom:	135.00000000000000
)

(RectD.128
	Left:	12.00000000000000
	Top:	68.00000000000000
	Right:	195.00000000000000
	Bottom:	48.00000000000000
)

(RectD.129
	Left:	27.00000000000000
	Top:	228.00000000000000
	Right:	205.00000000000000
	Bottom:	208.00000000000000
)

(RectD.130
	Left:	242.00000000000000
	Top:	37.00000000000000
	Right:	392.00000000000000
	Bottom:	17.00000000000000
)

(RectD.131
	Left:	13.00000000000000
	Top:	39.00000000000000
	Right:	193.00000000000000
	Bottom:	18.00000000000000
)

(RectD.132
	Left:	280.00000000000000
	Top:	108.00000000000000
	Right:	387.00000000000000
	Bottom:	37.00000000000000
)

(RectD.133
	Left:	78.00000000000000
	Top:	197.00000000000000
	Right:	205.00000000000000
	Bottom:	177.00000000000000
)

(RectD.134
	Left:	77.00000000000000
	Top:	169.00000000000000
	Right:	203.00000000000000
	Bottom:	149.00000000000000
)

(RectD.135
	Left:	76.00000000000000
	Top:	138.00000000000000
	Right:	200.00000000000000
	Bottom:	118.00000000000000
)

(Nil.136
)

(AVDLog.137
	Name:	"dlg_xygraph"
	X:	35
	Y:	160
	W:	400
	H:	172
	ConstrainedControlNames:	138
	ConstrainedControlNames:	139
	Constraints:	140
	Constraints:	141
	Server:	3
	ControlPanel:	142
	ObjectTag:	3
	Title:	"Create XYGraph for rckn6"
	EscapeEnabled:	1
	Resizable:	1
	AlwaysOnTop:	1
	HasTitleBar:	1
	Closeable:	1
	Open:	"cap.dlg_xygraph.open"
	DefaultButton:	162
)

(AVStr.138
	S:	"lbt_plot"
)

(AVStr.139
	S:	"lbt_cancel"
)

(Numb.140
	N:	85.00000000000000
)

(Numb.141
	N:	85.00000000000000
)

(CPanel.142
	Child:	143
	Child:	144
	Child:	145
	Child:	146
	Child:	147
	Child:	148
	Child:	149
	Child:	150
	Child:	151
	ResBox:	153
	ResBox:	154
	ResBox:	155
	ResBox:	156
	ResBox:	157
	ResBox:	158
	ResBox:	159
	ResBox:	160
	ResBox:	161
	Listening:	1
)

(TextLabel.143
	InternalName:	"txt_graphtype"
	Constraints:	0x55
	Label:	"Select Graph Type"
	Listening:	1
)

(TextLabel.144
	InternalName:	"txt_subdiv"
	Constraints:	0x55
	Label:	"Plot Graph For:"
	Listening:	1
)

(AVCBBox.145
	InternalName:	"cbx_subdiv"
	NextControl:	32
	ContentKind:	4
	Constraints:	0x55
	Listening:	1
)

(LButn.146
	InternalName:	"lbt_plot"
	Update:	"cap.dlg_xygraph.update"
	Label:	"Plot"
	Click:	"cap.dlg_xygraph.plot"
)

(LButn.147
	InternalName:	"lbt_cancel"
	Label:	"Cancel"
	Click:	"cap.dlg.cancel"
)

(RButn.148
	InternalName:	"rad_ae"
	Constraints:	0x55
	Listening:	1
	Label:	"Area vs. Elevation"
	Click:	"cap.dlg_xygraph.radio"
)

(RButn.149
	InternalName:	"rad_pcp"
	Constraints:	0x55
	Listening:	1
	Label:	"PRISM PPT vs. Elevation"
	Click:	"cap.dlg_xygraph.radio"
)

(RButn.150
	InternalName:	"aRadioButton3"
	Disabled:	1
	Constraints:	0x55
	Listening:	1
	Label:	"PRISM TMP vs. Elevation"
	Click:	"cap.dlg_xygraph.radio"
)

(TextLine.151
	InternalName:	"txl_numpts"
	Text:	"12"
	Label:	"# of Points"
	Constraints:	0x55
	Listening:	1
	TextType:	152
	NextControl:	32
)

(AVEnum.152
	Name:	"TEXTLINE_TYPE_ALL"
)

(RectD.153
	Left:	17.00000000000000
	Top:	43.00000000000000
	Right:	119.00000000000000
	Bottom:	23.00000000000000
)

(RectD.154
	Left:	178.00000000000000
	Top:	46.00000000000000
	Right:	263.00000000000000
	Bottom:	27.00000000000000
)

(RectD.155
	Left:	196.00000000000000
	Top:	136.00000000000000
	Right:	290.00000000000000
	Bottom:	49.00000000000000
)

(RectD.156
	Left:	313.00000000000000
	Top:	49.00000000000000
	Right:	365.00000000000000
	Bottom:	29.00000000000000
)

(RectD.157
	Left:	314.00000000000000
	Top:	76.00000000000000
	Right:	365.00000000000000
	Bottom:	58.00000000000000
)

(RectD.158
	Left:	25.00000000000000
	Top:	67.00000000000000
	Right:	137.00000000000000
	Bottom:	43.00000000000000
)

(RectD.159
	Left:	25.00000000000000
	Top:	90.00000000000000
	Right:	188.00000000000000
	Bottom:	68.00000000000000
)

(RectD.160
	Left:	25.00000000000000
	Top:	116.00000000000000
	Right:	186.00000000000000
	Bottom:	90.00000000000000
)

(RectD.161
	Left:	179.00000000000000
	Top:	119.00000000000000
	Right:	274.00000000000000
	Bottom:	99.00000000000000
)

(Nil.162
)

(AVDLog.163
	Name:	"ofs-mapx-define"
	X:	43
	Y:	65
	W:	615
	H:	437
	ConstrainedControlNames:	164
	ConstrainedControlNames:	165
	ConstrainedControlNames:	166
	Constraints:	167
	Constraints:	168
	Constraints:	169
	Server:	3
	ControlPanel:	170
	ObjectTag:	3
	Title:	"Define OFS MAPX Area"
	EscapeEnabled:	1
	Resizable:	1
	AlwaysOnTop:	1
	HasTitleBar:	1
	Closeable:	1
	Update:	" "
	DefaultButton:	207
)

(AVStr.164
	S:	"mapxexport"
)

(AVStr.165
	S:	"close"
)

(AVStr.166
	S:	"mapxno_export"
)

(Numb.167
	N:	85.00000000000000
)

(Numb.168
	N:	85.00000000000000
)

(Numb.169
	N:	85.00000000000000
)

(CPanel.170
	Child:	171
	Child:	174
	Child:	176
	Child:	177
	Child:	178
	Child:	180
	Child:	181
	Child:	182
	Child:	183
	Child:	185
	Child:	187
	Child:	188
	Child:	189
	Child:	190
	Child:	191
	ResBox:	192
	ResBox:	193
	ResBox:	194
	ResBox:	195
	ResBox:	196
	ResBox:	197
	ResBox:	198
	ResBox:	199
	ResBox:	200
	ResBox:	201
	ResBox:	202
	ResBox:	203
	ResBox:	204
	ResBox:	205
	ResBox:	206
	Listening:	1
)

(TextLine.171
	InternalName:	"mapxid"
	Update:	" "
	Text:	" "
	Label:	"MAPX Area ID       "
	Constraints:	0x55
	Listening:	1
	TextType:	172
	Size:	8
	NextControl:	173
)

(AVEnum.172
	Name:	"TEXTLINE_TYPE_ALL"
)

(Nil.173
)

(TextLine.174
	InternalName:	"mapxdescription"
	Label:	"MAPX Area Description"
	Constraints:	0x55
	Listening:	1
	TextType:	175
	Size:	20
	NextControl:	173
)

(AVEnum.175
	Name:	"TEXTLINE_TYPE_ALL"
)

(LButn.176
	InternalName:	"mapxexport"
	Label:	"Export MAPX Area Definition"
	Click:	"mapx.dialog.ok"
)

(LButn.177
	InternalName:	"close"
	Label:	"Close"
	Click:	"mapx.dialog.close"
)

(AVLBox.178
	InternalName:	"1hrmapxlistbox"
	Update:	"mapx.listbox.update"
	NextControl:	173
	ContentKind:	4
	Constraints:	0x55
	ColumnCount:	1
	HorizontalScroll:	1
	Listening:	1
	VerticalScroll:	1
	Select:	"mapx.listbox.apply"
	SelectionStyle:	179
	Apply:	"mapx.listbox.apply"
)

(AVEnum.179
	Name:	"LISTBOX_SELECTION_SINGLECELL"
)

(RButn.180
	InternalName:	"inputbasintheme"
	Constraints:	0x55
	Listening:	1
	Label:	"Basin Input Theme"
	Click:	"mapx.basininputtheme.click"
)

(RButn.181
	InternalName:	"basinidfield"
	Constraints:	0x55
	Listening:	1
	Label:	"Basin ID Field"
	Click:	"mapx.basinidfield.click"
)

(RButn.182
	InternalName:	"basindescriptionfield"
	Constraints:	0x55
	Listening:	1
	Label:	"Basin Description Field"
	Click:	"mapx.basindescriptionfield.click"
)

(TextLine.183
	InternalName:	"basindescription"
	Label:	"Enter a Basin Description"
	Constraints:	0x55
	Listening:	1
	TextType:	184
	Size:	20
	Apply:	"mapx.basindescription.apply"
	Changed:	"mapx.basindescription.changed"
	NextControl:	173
)

(AVEnum.184
	Name:	"TEXTLINE_TYPE_ALL"
)

(TextLine.185
	InternalName:	"basinid"
	Update:	" "
	Text:	" "
	Label:	"Enter a Basin ID"
	Constraints:	0x55
	Listening:	1
	TextType:	186
	Size:	8
	Apply:	"mapx.basinid.apply"
	Changed:	"mapx.basinid.changed"
	NextControl:	173
)

(AVEnum.186
	Name:	"TEXTLINE_TYPE_ALL"
)

(RButn.187
	InternalName:	"basinmeanelevationfield"
	Constraints:	0x55
	Listening:	1
	Label:	"Basin Mean Elevation Field"
	Click:	"mapx.basinmeanelevation.click"
)

(LButn.188
	InternalName:	"mapxno_export"
	Label:	"View MAPX Area Definition"
	Click:	"mapx.dialog.ok"
)

(TextLabel.189
	InternalName:	"fmaplabel"
	Constraints:	0x55
	Label:	"FMAP ID"
	Listening:	1
)

(AVCBox.190
	InternalName:	"newcheckbox"
	Listening:	1
	Label:	"New"
	Constraints:	0x55
)

(AVCBox.191
	InternalName:	"oldcheckbox"
	Disabled:	1
	Listening:	1
	Label:	"Old"
	Constraints:	0x55
)

(RectD.192
	Left:	12.00000000000000
	Top:	47.00000000000000
	Right:	214.00000000000000
	Bottom:	27.00000000000000
)

(RectD.193
	Left:	11.00000000000000
	Top:	86.00000000000000
	Right:	374.00000000000000
	Bottom:	66.00000000000000
)

(RectD.194
	Left:	10.00000000000000
	Top:	395.00000000000000
	Right:	217.00000000000000
	Bottom:	372.00000000000000
)

(RectD.195
	Left:	442.00000000000000
	Top:	393.00000000000000
	Right:	605.00000000000000
	Bottom:	370.00000000000000
)

(RectD.196
	Left:	242.00000000000000
	Top:	320.00000000000000
	Right:	536.00000000000000
	Bottom:	157.00000000000000
)

(RectD.197
	Left:	11.00000000000000
	Top:	174.00000000000000
	Right:	158.00000000000000
	Bottom:	152.00000000000000
)

(RectD.198
	Left:	14.00000000000000
	Top:	223.00000000000000
	Right:	162.00000000000000
	Bottom:	201.00000000000000
)

(RectD.199
	Left:	14.00000000000000
	Top:	271.00000000000000
	Right:	224.00000000000000
	Bottom:	248.00000000000000
)

(RectD.200
	Left:	175.00000000000000
	Top:	227.00000000000000
	Right:	564.00000000000000
	Bottom:	207.00000000000000
)

(RectD.201
	Left:	177.00000000000000
	Top:	231.00000000000000
	Right:	393.00000000000000
	Bottom:	211.00000000000000
)

(RectD.202
	Left:	12.00000000000000
	Top:	323.00000000000000
	Right:	226.00000000000000
	Bottom:	300.00000000000000
)

(RectD.203
	Left:	237.00000000000000
	Top:	394.00000000000000
	Right:	426.00000000000000
	Bottom:	371.00000000000000
)

(RectD.204
	Left:	14.00000000000000
	Top:	123.00000000000000
	Right:	90.00000000000000
	Bottom:	101.00000000000000
)

(RectD.205
	Left:	248.00000000000000
	Top:	32.00000000000000
	Right:	323.00000000000000
	Bottom:	10.00000000000000
)

(RectD.206
	Left:	355.00000000000000
	Top:	31.00000000000000
	Right:	430.00000000000000
	Bottom:	10.00000000000000
)

(Nil.207
)

(AVDLog.208
	Name:	"ofs-mapx-delete"
	X:	22
	Y:	51
	W:	397
	H:	189
	ConstrainedControlNames:	209
	ConstrainedControlNames:	210
	Constraints:	211
	Constraints:	212
	Server:	3
	ControlPanel:	213
	ObjectTag:	3
	Title:	"Delete OFS MAPX Area"
	EscapeEnabled:	1
	Resizable:	1
	AlwaysOnTop:	1
	HasTitleBar:	1
	Closeable:	1
	DefaultButton:	226
)

(AVStr.209
	S:	"delete"
)

(AVStr.210
	S:	"close"
)

(Numb.211
	N:	85.00000000000000
)

(Numb.212
	N:	85.00000000000000
)

(CPanel.213
	Child:	214
	Child:	216
	Child:	218
	Child:	219
	Child:	220
	ResBox:	221
	ResBox:	222
	ResBox:	223
	ResBox:	224
	ResBox:	225
	Listening:	1
)

(TextLine.214
	InternalName:	" "
	Update:	" "
	Text:	" "
	Label:	"Enter a Basin ID"
	Constraints:	0x55
	Listening:	1
	TextType:	215
	Size:	14
	Apply:	"mapx.basinid.apply"
	Changed:	"mapx.basinid.changed"
	NextControl:	173
)

(AVEnum.215
	Name:	"TEXTLINE_TYPE_ALL"
)

(AVLBox.216
	InternalName:	"mapxdeletelist"
	Update:	"mapx.deletelistbox.update"
	NextControl:	173
	ContentKind:	4
	Constraints:	0x55
	ColumnCount:	1
	Listening:	1
	VerticalScroll:	1
	Select:	"mapx.dump.listbox.apply"
	SelectionStyle:	217
	Apply:	"mapx.delete.click"
)

(AVEnum.217
	Name:	"LISTBOX_SELECTION_MULTIROW"
)

(LButn.218
	InternalName:	"delete"
	Label:	"Delete Selected"
	Click:	"mapx.delete.click"
)

(LButn.219
	InternalName:	"close"
	Label:	"Close"
	Click:	"mapx.dialog.close"
)

(TextLabel.220
	InternalName:	"mapxid"
	Constraints:	0x55
	Label:	"select mapx areas"
	Listening:	1
)

(RectD.221
	Left:	154.00000000000000
	Top:	-50.00000000000000
	Right:	381.00000000000000
	Bottom:	-70.00000000000000
)

(RectD.222
	Left:	161.00000000000000
	Top:	175.00000000000000
	Right:	389.00000000000000
	Bottom:	49.00000000000000
)

(RectD.223
	Left:	14.00000000000000
	Top:	103.00000000000000
	Right:	143.00000000000000
	Bottom:	81.00000000000000
)

(RectD.224
	Left:	16.00000000000000
	Top:	159.00000000000000
	Right:	147.00000000000000
	Bottom:	137.00000000000000
)

(RectD.225
	Left:	193.00000000000000
	Top:	32.00000000000000
	Right:	326.00000000000000
	Bottom:	10.00000000000000
)

(Nil.226
)

(AVDLog.227
	Name:	"ofs-mapx-dump"
	X:	22
	Y:	60
	W:	416
	H:	174
	ConstrainedControlNames:	228
	ConstrainedControlNames:	229
	ConstrainedControlNames:	230
	Constraints:	231
	Constraints:	232
	Constraints:	233
	Server:	3
	ControlPanel:	234
	ObjectTag:	3
	Title:	"Dump OFS MAPX Area"
	EscapeEnabled:	1
	Resizable:	1
	AlwaysOnTop:	1
	HasTitleBar:	1
	Closeable:	1
	DefaultButton:	249
)

(AVStr.228
	S:	"import"
)

(AVStr.229
	S:	"close"
)

(AVStr.230
	S:	"importall"
)

(Numb.231
	N:	85.00000000000000
)

(Numb.232
	N:	85.00000000000000
)

(Numb.233
	N:	85.00000000000000
)

(CPanel.234
	Child:	235
	Child:	237
	Child:	238
	Child:	239
	Child:	240
	Child:	241
	ResBox:	243
	ResBox:	244
	ResBox:	245
	ResBox:	246
	ResBox:	247
	ResBox:	248
	Listening:	1
)

(TextLine.235
	InternalName:	" "
	Update:	" "
	Text:	" "
	Label:	"Enter a Basin ID"
	Constraints:	0x55
	Listening:	1
	TextType:	236
	Size:	14
	Apply:	"mapx.basinid.apply"
	Changed:	"mapx.basinid.changed"
	NextControl:	173
)

(AVEnum.236
	Name:	"TEXTLINE_TYPE_ALL"
)

(LButn.237
	InternalName:	"import"
	Label:	"Import Selected"
	Click:	"mapx.import.click"
)

(LButn.238
	InternalName:	"close"
	Label:	"Close"
	Click:	"mapx.dialog.close"
)

(TextLabel.239
	InternalName:	"mapxid"
	Constraints:	0x55
	Label:	"select mapx areas"
	Listening:	1
)

(LButn.240
	InternalName:	"importall"
	Label:	"Import All"
	Click:	"mapx.importall.click"
)

(AVLBox.241
	InternalName:	"mapxdumplist"
	NextControl:	173
	ContentKind:	4
	Constraints:	0x55
	ColumnCount:	1
	Listening:	1
	VerticalScroll:	1
	SelectionStyle:	242
	Apply:	"mapx.import.click"
)

(AVEnum.242
	Name:	"LISTBOX_SELECTION_MULTIROW"
)

(RectD.243
	Left:	154.00000000000000
	Top:	-59.00000000000000
	Right:	381.00000000000000
	Bottom:	-79.00000000000000
)

(RectD.244
	Left:	22.00000000000000
	Top:	71.00000000000000
	Right:	151.00000000000000
	Bottom:	49.00000000000000
)

(RectD.245
	Left:	21.00000000000000
	Top:	153.00000000000000
	Right:	152.00000000000000
	Bottom:	131.00000000000000
)

(RectD.246
	Left:	193.00000000000000
	Top:	23.00000000000000
	Right:	326.00000000000000
	Bottom:	1.00000000000000
)

(RectD.247
	Left:	21.00000000000000
	Top:	111.00000000000000
	Right:	150.00000000000000
	Bottom:	88.00000000000000
)

(RectD.248
	Left:	178.00000000000000
	Top:	161.00000000000000
	Right:	379.00000000000000
	Bottom:	32.00000000000000
)

(Nil.249
)

(AVDLog.250
	Name:	"ofs-basin-define"
	X:	31
	Y:	72
	W:	534
	H:	215
	ConstrainedControlNames:	251
	ConstrainedControlNames:	252
	ConstrainedControlNames:	253
	Constraints:	254
	Constraints:	255
	Constraints:	256
	Server:	3
	ControlPanel:	257
	ObjectTag:	3
	Title:	"Define OFS Basin "
	EscapeEnabled:	1
	Resizable:	1
	AlwaysOnTop:	1
	HasTitleBar:	1
	Closeable:	1
	Update:	" "
	DefaultButton:	281
)

(AVStr.251
	S:	"basinexport"
)

(AVStr.252
	S:	"close"
)

(AVStr.253
	S:	"basinno_export"
)

(Numb.254
	N:	85.00000000000000
)

(Numb.255
	N:	85.00000000000000
)

(Numb.256
	N:	85.00000000000000
)

(CPanel.257
	Child:	258
	Child:	259
	Child:	260
	Child:	262
	Child:	263
	Child:	264
	Child:	265
	Child:	267
	Child:	269
	Child:	270
	ResBox:	271
	ResBox:	272
	ResBox:	273
	ResBox:	274
	ResBox:	275
	ResBox:	276
	ResBox:	277
	ResBox:	278
	ResBox:	279
	ResBox:	280
	Listening:	1
)

(LButn.258
	InternalName:	"basinexport"
	Label:	"Export Basin Definition"
	Click:	"mapx.dialog.ok"
)

(LButn.259
	InternalName:	"close"
	Label:	"Close"
	Click:	"mapx.dialog.close"
)

(AVLBox.260
	InternalName:	"1hrmapxlistbox"
	Update:	"mapx.listbox.update"
	NextControl:	173
	ContentKind:	4
	Constraints:	0x55
	ColumnCount:	1
	HorizontalScroll:	1
	Listening:	1
	VerticalScroll:	1
	Select:	"mapx.listbox.apply"
	SelectionStyle:	261
	Apply:	"mapx.listbox.apply"
)

(AVEnum.261
	Name:	"LISTBOX_SELECTION_SINGLECELL"
)

(RButn.262
	InternalName:	"inputbasintheme"
	Constraints:	0x55
	Listening:	1
	Label:	"Basin Input Theme"
	Click:	"mapx.basininputtheme.click"
)

(RButn.263
	InternalName:	"basinidfield"
	Constraints:	0x55
	Listening:	1
	Label:	"Basin ID Field"
	Click:	"mapx.basinidfield.click"
)

(RButn.264
	InternalName:	"basindescriptionfield"
	Constraints:	0x55
	Listening:	1
	Label:	"Basin Description Field"
	Click:	"mapx.basindescriptionfield.click"
)

(TextLine.265
	InternalName:	"basindescription"
	Label:	"Enter a Basin Description"
	Constraints:	0x55
	Listening:	1
	TextType:	266
	Size:	20
	Apply:	"mapx.basindescription.apply"
	Changed:	"mapx.basindescription.changed"
	NextControl:	173
)

(AVEnum.266
	Name:	"TEXTLINE_TYPE_ALL"
)

(TextLine.267
	InternalName:	"basinid"
	Update:	" "
	Text:	" "
	Label:	"Enter a Basin ID"
	Constraints:	0x55
	Listening:	1
	TextType:	268
	Size:	8
	Apply:	"mapx.basinid.apply"
	Changed:	"mapx.basinid.changed"
	NextControl:	173
)

(AVEnum.268
	Name:	"TEXTLINE_TYPE_ALL"
)

(RButn.269
	InternalName:	"basinmeanelevationfield"
	Constraints:	0x55
	Listening:	1
	Label:	"Basin Mean Elevation Field"
	Click:	"mapx.basinmeanelevation.click"
)

(LButn.270
	InternalName:	"basinno_export"
	Label:	"View Basin Definition"
	Click:	"mapx.dialog.ok"
)

(RectD.271
	Left:	11.00000000000000
	Top:	191.00000000000000
	Right:	169.00000000000000
	Bottom:	168.00000000000000
)

(RectD.272
	Left:	358.00000000000000
	Top:	190.00000000000000
	Right:	507.00000000000000
	Bottom:	167.00000000000000
)

(RectD.273
	Left:	226.00000000000000
	Top:	136.00000000000000
	Right:	468.00000000000000
	Bottom:	6.00000000000000
)

(RectD.274
	Left:	9.00000000000000
	Top:	37.00000000000000
	Right:	157.00000000000000
	Bottom:	15.00000000000000
)

(RectD.275
	Left:	8.00000000000000
	Top:	75.00000000000000
	Right:	156.00000000000000
	Bottom:	52.00000000000000
)

(RectD.276
	Left:	10.00000000000000
	Top:	106.00000000000000
	Right:	196.00000000000000
	Bottom:	83.00000000000000
)

(RectD.277
	Left:	148.00000000000000
	Top:	73.00000000000000
	Right:	513.00000000000000
	Bottom:	53.00000000000000
)

(RectD.278
	Left:	146.00000000000000
	Top:	74.00000000000000
	Right:	370.00000000000000
	Bottom:	54.00000000000000
)

(RectD.279
	Left:	9.00000000000000
	Top:	136.00000000000000
	Right:	214.00000000000000
	Bottom:	112.00000000000000
)

(RectD.280
	Left:	185.00000000000000
	Top:	191.00000000000000
	Right:	343.00000000000000
	Bottom:	169.00000000000000
)

(Nil.281
)

(AVDLog.282
	Name:	"ofs-basin-delete"
	X:	22
	Y:	60
	W:	407
	H:	176
	ConstrainedControlNames:	283
	ConstrainedControlNames:	284
	Constraints:	285
	Constraints:	286
	Server:	3
	ControlPanel:	287
	ObjectTag:	3
	Title:	"Delete OFS  Basins"
	EscapeEnabled:	1
	Resizable:	1
	AlwaysOnTop:	1
	HasTitleBar:	1
	Closeable:	1
	DefaultButton:	300
)

(AVStr.283
	S:	"delete"
)

(AVStr.284
	S:	"close"
)

(Numb.285
	N:	85.00000000000000
)

(Numb.286
	N:	85.00000000000000
)

(CPanel.287
	Child:	288
	Child:	290
	Child:	292
	Child:	293
	Child:	294
	ResBox:	295
	ResBox:	296
	ResBox:	297
	ResBox:	298
	ResBox:	299
	Listening:	1
)

(TextLine.288
	InternalName:	" "
	Update:	" "
	Text:	" "
	Label:	"Enter a Basin ID"
	Constraints:	0x55
	Listening:	1
	TextType:	289
	Size:	14
	Apply:	"mapx.basinid.apply"
	Changed:	"mapx.basinid.changed"
	NextControl:	173
)

(AVEnum.289
	Name:	"TEXTLINE_TYPE_ALL"
)

(AVLBox.290
	InternalName:	"basindeletelist"
	Update:	"basin.deletelistbox.update"
	NextControl:	173
	ContentKind:	4
	Constraints:	0x55
	ColumnCount:	1
	Listening:	1
	VerticalScroll:	1
	Select:	"mapx.dump.listbox.apply"
	SelectionStyle:	291
	Apply:	"basin.delete.click"
)

(AVEnum.291
	Name:	"LISTBOX_SELECTION_MULTIROW"
)

(LButn.292
	InternalName:	"delete"
	Label:	"Delete Selected"
	Click:	"basin.delete.click"
)

(LButn.293
	InternalName:	"close"
	Label:	"Close"
	Click:	"mapx.dialog.close"
)

(TextLabel.294
	InternalName:	"basinid"
	Constraints:	0x55
	Label:	"select basins"
	Listening:	1
)

(RectD.295
	Left:	154.00000000000000
	Top:	-59.00000000000000
	Right:	381.00000000000000
	Bottom:	-79.00000000000000
)

(RectD.296
	Left:	173.00000000000000
	Top:	164.00000000000000
	Right:	390.00000000000000
	Bottom:	24.00000000000000
)

(RectD.297
	Left:	19.00000000000000
	Top:	97.00000000000000
	Right:	148.00000000000000
	Bottom:	75.00000000000000
)

(RectD.298
	Left:	17.00000000000000
	Top:	145.00000000000000
	Right:	148.00000000000000
	Bottom:	123.00000000000000
)

(RectD.299
	Left:	190.00000000000000
	Top:	21.00000000000000
	Right:	323.00000000000000
	Bottom:	-1.00000000000000
)

(Nil.300
)

(AVDLog.301
	Name:	"ofs-basin-dump"
	X:	22
	Y:	60
	W:	414
	H:	173
	ConstrainedControlNames:	302
	ConstrainedControlNames:	303
	ConstrainedControlNames:	304
	Constraints:	305
	Constraints:	306
	Constraints:	307
	Server:	3
	ControlPanel:	308
	ObjectTag:	3
	Title:	"Dump OFS Basin "
	EscapeEnabled:	1
	Resizable:	1
	AlwaysOnTop:	1
	HasTitleBar:	1
	Closeable:	1
	Update:	" "
	DefaultButton:	320
)

(AVStr.302
	S:	"import"
)

(AVStr.303
	S:	"close"
)

(AVStr.304
	S:	"import_all"
)

(Numb.305
	N:	85.00000000000000
)

(Numb.306
	N:	85.00000000000000
)

(Numb.307
	N:	85.00000000000000
)

(CPanel.308
	Child:	309
	Child:	310
	Child:	311
	Child:	313
	Child:	314
	ResBox:	315
	ResBox:	316
	ResBox:	317
	ResBox:	318
	ResBox:	319
	Listening:	1
)

(LButn.309
	InternalName:	"import"
	Label:	"Import Selected"
	Click:	"basin.import.click"
)

(LButn.310
	InternalName:	"close"
	Label:	"Close"
	Click:	"mapx.dialog.close"
)

(AVLBox.311
	InternalName:	"basindumplist"
	Update:	"mapx.dump.listbox.update"
	NextControl:	173
	ContentKind:	4
	Constraints:	0x55
	ColumnCount:	1
	Listening:	1
	VerticalScroll:	1
	Select:	"mapx.dump.listbox.apply"
	SelectionStyle:	312
	Apply:	"basin.import.click"
)

(AVEnum.312
	Name:	"LISTBOX_SELECTION_MULTIROW"
)

(TextLabel.313
	InternalName:	"aTextLabel1"
	Constraints:	0x55
	Label:	"Select Basins"
	Listening:	1
)

(LButn.314
	InternalName:	"import_all"
	Label:	"Import All"
	Click:	"basin.importall.click"
)

(RectD.315
	Left:	29.00000000000000
	Top:	63.00000000000000
	Right:	159.00000000000000
	Bottom:	40.00000000000000
)

(RectD.316
	Left:	28.00000000000000
	Top:	144.00000000000000
	Right:	162.00000000000000
	Bottom:	120.00000000000000
)

(RectD.317
	Left:	181.00000000000000
	Top:	170.00000000000000
	Right:	392.00000000000000
	Bottom:	24.00000000000000
)

(RectD.318
	Left:	223.00000000000000
	Top:	25.00000000000000
	Right:	376.00000000000000
	Bottom:	3.00000000000000
)

(RectD.319
	Left:	28.00000000000000
	Top:	103.00000000000000
	Right:	162.00000000000000
	Bottom:	80.00000000000000
)

(Nil.320
)

(AVDLog.321
	Name:	"ofs-ppinit"
	X:	22
	Y:	79
	W:	361
	H:	220
	ConstrainedControlNames:	322
	Constraints:	323
	Server:	3
	ControlPanel:	324
	ObjectTag:	3
	Title:	"PPINIT"
	EscapeEnabled:	1
	AlwaysOnTop:	1
	HasTitleBar:	1
	Closeable:	1
	DefaultButton:	344
)

(AVStr.322
	S:	"close"
)

(Numb.323
	N:	85.00000000000000
)

(CPanel.324
	Child:	325
	Child:	327
	Child:	328
	Child:	329
	Child:	330
	Child:	331
	Child:	332
	Child:	333
	Child:	334
	ResBox:	335
	ResBox:	336
	ResBox:	337
	ResBox:	338
	ResBox:	339
	ResBox:	340
	ResBox:	341
	ResBox:	342
	ResBox:	343
	Listening:	1
)

(AVLBox.325
	InternalName:	"ofslistbox"
	Update:	"ofs.listbox.update"
	NextControl:	173
	ContentKind:	4
	Constraints:	0x55
	ColumnCount:	1
	Listening:	1
	Select:	"ofs.listbox.apply"
	SelectionStyle:	326
	Apply:	"ofs.listbox.apply"
)

(AVEnum.326
	Name:	"LISTBOX_SELECTION_SINGLECELL"
)

(RButn.327
	InternalName:	"basin"
	Constraints:	0x55
	Listening:	1
	Label:	"Basins"
	Click:	"ofs.radiobutton.click"
)

(RButn.328
	InternalName:	"area"
	Constraints:	0x55
	Listening:	1
	Label:	"Areas"
	Click:	"ofs.radiobutton.click"
)

(RButn.329
	InternalName:	"station"
	Disabled:	1
	Constraints:	0x55
	Listening:	1
	Label:	"Stations"
	Click:	"ofs.radiobutton.click"
)

(LButn.330
	InternalName:	"close"
	Label:	"Close"
	Click:	"ofs.dialog.close"
)

(AVCBox.331
	InternalName:	"Delete"
	Listening:	1
	Label:	"Delete"
	Click:	"ofs.checkbox.click"
	Constraints:	0x55
)

(AVCBox.332
	InternalName:	"define"
	Listening:	1
	Label:	"Define"
	Click:	"ofs.checkbox.click"
	Constraints:	0x55
)

(AVCBox.333
	InternalName:	"Dump"
	Listening:	1
	Label:	"Dump"
	Click:	"ofs.checkbox.click"
	Constraints:	0x55
)

(TextLabel.334
	InternalName:	"aTextLabel3"
	Constraints:	0x55
	Label:	"Select Command and Type of PPINIT Group"
	Listening:	1
)

(RectD.335
	Left:	111.00000000000000
	Top:	186.00000000000000
	Right:	321.00000000000000
	Bottom:	76.00000000000000
)

(RectD.336
	Left:	14.00000000000000
	Top:	139.00000000000000
	Right:	88.00000000000000
	Bottom:	117.00000000000000
)

(RectD.337
	Left:	15.00000000000000
	Top:	97.00000000000000
	Right:	89.00000000000000
	Bottom:	75.00000000000000
)

(RectD.338
	Left:	12.00000000000000
	Top:	179.00000000000000
	Right:	86.00000000000000
	Bottom:	157.00000000000000
)

(RectD.339
	Left:	174.00000000000000
	Top:	216.00000000000000
	Right:	250.00000000000000
	Bottom:	194.00000000000000
)

(RectD.340
	Left:	182.00000000000000
	Top:	68.00000000000000
	Right:	257.00000000000000
	Bottom:	46.00000000000000
)

(RectD.341
	Left:	103.00000000000000
	Top:	70.00000000000000
	Right:	178.00000000000000
	Bottom:	48.00000000000000
)

(RectD.342
	Left:	261.00000000000000
	Top:	67.00000000000000
	Right:	336.00000000000000
	Bottom:	45.00000000000000
)

(RectD.343
	Left:	30.00000000000000
	Top:	31.00000000000000
	Right:	316.00000000000000
	Bottom:	9.00000000000000
)

(Nil.344
)

(Script.345
	Name:	"basin.clockwise"
	SourceCode:	"'*** I MAY NOT NEED THIS SCRIPT AV ALWAYS WRITES CLOCKWISE\n\ntheList=SELF.get(0)\ntheView=av.getActiveDoc\ntheRect=theView.returnExtent\ntheScript=Script.The\ntheScript.setNumberFormat(\"d.dddd\")\ntheNList={}\ntheMaxX=-9999999999\ntheMinX=9999999999\ntheMaxY=-9999999999\ntheMinY=9999999999\n\n'***Build Albers Projection ***\ntheAPrj=Albers.Make(theRect)\ntheAPrj.setCentralMeridian(-96)\ntheAPrj.setFalseEasting(0)\ntheAPrj.setFalseNorthing(0)\ntheAPrj.setReferenceLatitude(23)\ntheAPrj.setUpperStandardParallel(29.5)\ntheAPrj.set
LowerStandardParallel(45.5)\ntheAPrj.reCalculate\n\nfor each pt in theList\n   thePt=pt.returnUnprojected(theAprj)\n   theX=thePt.getX\n   if(theX>theMaxX)then\n      theMaxX=theX\n      theMaxXPt=pt\n   elseif(theX<theMinX)then\n      theMinX=theX\n      theMinXPt=pt\n   end\nend\nfor each pt in theList\n   thePt=pt.returnUnprojected(theAprj)\n   theY=thePt.getY\n   if(theY>theMaxY)then\n      theMaxY=theY\n      theMaxYPt=pt\n   elseif(theY<theMinY)then\n      theMinY=theY\n      theMinYPt=pt\n   end\nend\ntheCX=(theMinX+theMaxX)
/2\ntheCY=(theMinY+theMaxY)/2\n\n'*** Check to see which quadrant first point is in\n   thePt = theList.Get(0)\n   theX=thePt.getX\n   theY=thePt.getY\n\n   if(theX>=theCX)then\n      'It is either quadrant I or IV\n      if(theY>=theCY)then\n         theQuad=1\n      else\n         theQuad=4\n      end\n   else\n      ' It is either quadrant II or III\n      if(theY>=theCY)then\n         theQuad=2\n      else\n         theQuad=3\n      end\n   end\n'check to see which direction the points are going (clockwise or counter)\ntheDire
ction=\"\"\ncnt=0\nfor each pt in theList\n   thePt=pt.returnUnprojected(theAprj)\n   theX=thePt.getX\n   theY=thePt.getY\n   if(theX>=theCX)then\n      'It is either quadrant I or IV\n      if(theY>=theCY)then\n         theNQuad=1\n      else\n         theNQuad=4\n      end\n   else\n      ' It is either quadrant II or III\n      if(theY>=theCY)then\n         theNQuad=2\n      else\n         theNQuad=3\n      end\n   end\n   if(theNQuad<>theQuad)then\n      if((theQuad=1) AND (theNQuad=4))then\n         theDirection=\"clockwise\"\n  
    elseif((theQuad=1) AND (theNQuad=2))then\n         theDirection=\"counter-clockwise\"\n      elseif((theQuad=2) AND (theNQuad=1))then\n         theDirection=\"clockwise\"\n      elseif((theQuad=2) AND (theNQuad=3))then\n         theDirection=\"counter-clockwise\"\n      elseif((theQuad=3) AND (theNQuad=2))then\n         theDirection=\"clockwise\"\n      elseif((theQuad=3) AND (theNQuad=4))then\n         theDirection=\"counter-clockwise\"\n      elseif((theQuad=4) AND (theNQuad=3))then\n         theDirection=\"clockwise\"\n    
  elseif((theQuad=4) AND (theNQuad=1))then\n         theDirection=\"counter-clockwise\"\n      end\n      if(theDirection=\"\")then\n         Continue\n      end\n      msgBox.info(theQuad.asString++theNQuad.asString++theDirection,\"\")\n      Break\n      'theQuad=theNQuad\n   end\n   cnt=cnt+1\nend\nmsgBox.info(theDirection,\"\")\n'thePointList={}\n'for each pt in 0..cnt\n'   thePointList.Add(theList.Get(pt))\n'end\n'thePointTheme=av.Run(\"mapx.util_themecreating\",{\"thepoints\",Point,{},{},thePointList})\ntheView=av.getActiveDoc\n'th
eView.addTheme(thePointTheme)\n'theView.Invalidate\n\nif(theDirection=\"\")then\n   msgBox.ERROR(\"Direction cannot be determined\",\"Error in\"++Script.The.getName)\nelseif(theDirection=\"counter-clockwise\")then\n   for each pt in (theList.Count-1..0)\n      theNList.Add(theList.get(pt))\n   end\n   return theNList\nelse\n   return theList\nend\n"
)

(Script.346
	Name:	"basin.delete.click"
	SourceCode:	"'basin.delete.click\n'this script uses the selected basins to run the @DELETE command\n\ntheProject=av.getProject\ntheView=av.getActiveDoc\ntheDialog=av.findDialog(\"ofs-basin-delete\")'SELF.getDialog\ntheListBox=theDialog.FindByName(\"basindeletelist\")\ntheDictionary=theDialog.getObjectTag\ntheButton=SELF.getName \ntheSelectList= theListBox.getSelection\n\n \n'*** run the following ofs command and return the punch file ***'\ntheString=\"@DELETE BASIN\"\ntheAList=\"\"\nfor each a in theSelectList\n   theAList=theAlist++a+NL\nend\nt
heString=theString+theAList\ntheCompletionCode=av.Run(\"util.RunOFS\",{theString,\"mapx_area\",\"delete\",\"screen\"})\nif(theCompletionCode=0)then\n   '***remove areas and definition from dump-basin dialog dictionary \n   '*** the next set of code uses the index from the list of basins to look into thenewentrylist\n   '*** the newentrylist gives the line number in the totalbasinlist for the give area\n   '*** using this info rows are deleted from the totalbasinlist \n   for each a in theSelectList\n      theDialog=av.find
Dialog(\"ofs-basin-dump\")\n      theDictionary=theDialog.getObjectTag\n      theBasinTotalList=theDictionary.Get(\"BASINTOTALLIST\")\n      theBasinList=theDictionary.Get(\"BASINLIST\")\n      theNewEntryList=theDictionary.Get(\"NEWENTRYLIST\")     \n      theBasinListC={}\n      theBasinTotalListC={}\n      theNewEntryListC={}\n      theIndex=theBasinList.FindByValue(a)\n      theStart=theNewEntryList.Get(theIndex)\n      if(theIndex=(theBasinList.Count-1))then\n         theEnd=theBasinTotalList.Count-1\n      else\n         
theEnd=theNewEntryList.Get(theIndex+1)\n      end\n      '*** remove elements from basinlist  \n      theCount=theBasinList.Count\n      for each i in 0..(theCount-1)\n         if(i=theIndex)then\n            continue\n         else\n            theBasinListC.Add(theBasinList.get(i))\n         end\n      end\n      '*** remove elements from newentrylist\n      theCount=theNewEntryList.Count\n      for each i in 0..(theCount-1)\n         if(i<theIndex)then\n            theNewEntryListC.Add(theNewEntryList.get(i))\n         
elseif(i>=(theIndex+1))then\n            theDiff=theNewEntryList.get(theIndex+1)-theNewEntryList.get(theIndex)\n            theNewEntryListC.Add(theNewEntryList.get(i)-theDiff)\n         end\n      end\n      '*** remove lines form basintotallist\n      theCount=theBasinTotalList.Count\n      for each i in 0..(theCount-1)\n         if((i>=theStart) AND (i<theEnd))then\n            continue\n         else\n            theBasinTotalListC.Add(theBasinTotalList.get(i))\n         end\n      end  \n      theBasinList=theBasinL
istC.DeepClone\n      theBasinTotalList=theBasinTotalListC.DeepClone\n      theNewEntryList=theNewEntryListC.DeepClone\n      theDialogB=av.findDialog(\"ofs-basin-delete\")\n      theDictionaryB=theDialogB.getObjectTag\n      theDictionary.Set(\"BASINLIST\",theBasinList)\n      theDictionaryB.Set(\"BASINLIST\",theBasinList)\n      theDictionary.Set(\"BASINTOTALLIST\",theBasinTotalList)\n      theDictionary.Set(\"NEWENTRYLIST\",theNewEntryList)   \n   end\nend\ntheListBox.Update"
)

(Script.347
	Name:	"basin.deletelistbox.update"
	SourceCode:	"theDialog=SELF.getDialog\ntheListBox=theDialog.FindByName(\"basindeletelist\")\ntheDictionary=theDialog.getObjectTag\ntheBasinList=theDictionary.Get(\"BASINLIST\")\ntheListBox.defineFromList(theBasinList)\n"
)

(Script.348
	Name:	"basin.import.click"
	SourceCode:	"'basin.import.click\n'this script reads the output file from a ppinit/dump/basin and creates a basin boundary theme\n\n\ntheProject=av.getProject\ntheView=av.getActiveDoc\ntheClassName=theView.getClass.getClassName\nif(theClassName<>\"View\")then'\n   msgBox.Error(\"View Must Be Active Document\",\"Error in importing basins\")\n   exit\nend\ntheDialog=av.FindDialog(\"ofs-basin-dump\")\ntheListBox=theDialog.FindByName(\"basindumplist\")\ntheDictionary=theDialog.getObjectTag\ntheRect=theView.returnExtent\n\n'***Build Albers Projection
 ***\ntheAPrj=Albers.Make(theRect)\ntheAPrj.setCentralMeridian(-96)\ntheAPrj.setFalseEasting(0)\ntheAPrj.setFalseNorthing(0)\ntheAPrj.setReferenceLatitude(23)\ntheAPrj.setUpperStandardParallel(29.5)\ntheAPrj.setLowerStandardParallel(45.5)\ntheAPrj.reCalculate\n\n \ntheButton=SELF.getName\n'*** get the BASIN DUMP FILE\ntheLineList=theDictionary.Get(\"BASINTOTALLIST\")\ntheBasinList=theDictionary.Get(\"BASINLIST\")\ntheFirstEntryList=theDictionary.GEt(\"NEWENTRYLIST\")\ntheBasins=theListBox.getSelection\ntheSize=theLineList.Count\n'
*** read basin information for all basins ***'\ntheLine=0\ntheBcount=theBasins.Count \nbasin=0\nWhile(basin<>theBcount)\n   theIndex=theBasinList.FindByValue(theBasins.get(basin))\n   theLine=theFirstEntryList.get(theIndex)\n   thePos=0\n   '*** the 1st line 2nd entry is the basin name ***\n   thePos=thePos+1\n   theBasinName=theLineList.get(theLine).get(thePos)\n   basin=basin+1\n   thePos=thePos+1\n   '*** from thePos...n (where n is the entry w/ the number of basins\n   theDescription=\"\"\n   while(theLineList.get(theLi
ne).get(thePos)<>\"(\") \n      theDescription=theDescription++theLineList.get(theLine).get(thePos)\n      thePos=thePos+1\n   end\n   theDescription=theDescription.Substitute(\"'\",\"\")\n   '*** line 2.... has lat lon points\n   ''*** read the rest of the file to get the lat/lon points\n   theLine=theLine+1\n   theLatList={}\n   theLonList={} \n   while(theLineList.get(theLine).get(0).isNumber)\n      theTempList=theLineList.get(theLine) \n      theNumOfPairs=theTempList.Count/2\n      for each p in 0..(theNumOfPairs-1)\n   
      theLat=theTempList.get(p*2).asNumber.setFormatPrecision(4)\n         theLon=theTempList.get(p*2+1).asNumber.setFormatPrecision(4)\n         if(theLon>0)then\n            theLon=(-1.000*theLon).setFormatPrecision(4)\n         end\n         theLatList.Add(theLat)\n         theLonList.Add(theLon)    \n      end\n      theLine=theLine+1\n   end\n   '*** get area and elevation information ***'\n   theInfoList=theLineList.get(theLine)\n   theICount=theInfoList.Count\n   if(theICount>=2)then\n      theAreaString=theInfoLi
st.get(1)\n      theBeg=theAreaString.Indexof(\"(\")\n      theEnd=theAreaString.Indexof(\")\")\n      theNChars=theEnd-theBeg \n      theArea=theAreaString.Middle(theBeg+1,theNChars-1).asNumber\n   else\n      theArea=-999\n   end\n   if(theICount>=3)then\n      theElevationString=theInfoList.get(2) \n      theBeg=theElevationString.Indexof(\"(\")\n      theEnd=theElevationString.Indexof(\")\")\n      theNChars=theEnd-theBeg\n      theElevation=theElevationString.Middle(theBeg+1,theNChars-1).asNumber\n   else\n      theElevation
=-999\n   end\n   theValues={theBasinName,theDescription,theArea,theElevation}\n   theExtraFields={\"Basin Name\",#FIELD_CHAR,20,0,\"Description\",#FIELD_CHAR,20,0,\"Area [MI2]\",#FIELD_LONG,6,0,\"Mean Elevation [FT]\",#FIELD_LONG,6,0}\n   theCount=theLatList.Count\n   theList={}\n   thePList={}\n   thePolygonList={}\n   thePolygon=Polygon.MakeNull\n   for each r in 0..(theCount-1)   \n      av.setStatus((r/theCount-1)*100)\n      theList.Add(Point.Make(theLonList.get(r),theLatList.get(r)).returnProjected(theAprj)) \n   end\n  
 thePList.Add(theList)\n   thePolygonList.Add(Polygon.Make(thePList))\n   thePolygon=av.Run(\"mapx.util.ThemeCreating\",{theBasinName+\".shp\",Polygon,theExtraFields,theValues,thePolygonList})\n   theView.AddTheme(thePolygon)\n   theLine=theLine+1 \nend\nr = theView.ReturnExtent\n\nif (r.IsEmpty) then\n  return nil\nelseif ( r.ReturnSize = (0@0) ) then\n  theView.GetDisplay.PanTo(r.ReturnOrigin)\nelse\n  theView.GetDisplay.SetExtent(r.Scale(1.1))\n  av.GetProject.SetModified(true)\nend\n\ntheView.Invalidate"
)

(Script.349
	Name:	"basin.import.click.wbasmapx"
	SourceCode:	"'basin.import.click\n'this script reads the wbasmapx file and creates an hrapp and basin boundary theme\n\n\ntheProject=av.getProject\ntheView=av.getActiveDoc\ntheRect=theView.returnExtent\n\n'***Build Albers Projection ***\ntheAPrj=Albers.Make(theRect)\ntheAPrj.setCentralMeridian(-96)\ntheAPrj.setFalseEasting(0)\ntheAPrj.setFalseNorthing(0)\ntheAPrj.setReferenceLatitude(23)\ntheAPrj.setUpperStandardParallel(29.5)\ntheAPrj.setLowerStandardParallel(45.5)\ntheAPrj.reCalculate\n\n \ntheButton=SELF.getName\ntheExistingDir = Filena
me.getCWD.asString\n\n\n\n\n'***get ofs input directory ***\nSystem.Execute(\"gad ofs_input>temp.txt\")\ntheTempFileName = (theExistingDir+\"/temp.txt\").asFileName\ntheTFile = LineFile.Make(theTempFileName,#FILE_PERM_READ)\ntheTFile.setScratch(TRUE)\ntheInputDir=theTFile.ReadElt\ntheTFile.Close\n'***get ofs output directory ***\nSystem.Execute(\"gad my_output>temp.txt\")\ntheTempFileName = (theExistingDir+\"/temp.txt\").asFileName\ntheTFile = LineFile.Make(theTempFileName,#FILE_PERM_READ)\ntheTFile.setScratch(TRUE)\ntheOutputDir=t
heTFile.ReadElt\ntheTFile.Close\n\n'***get ofs rls directory ***\nSystem.Execute(\"gad ofs_rls>temp.txt\")\ntheTempFileName = (theExistingDir+\"/temp.txt\").asFileName\ntheTFile = LineFile.Make(theTempFileName,#FILE_PERM_READ)\ntheTFile.setScratch(TRUE)\ntheBinDir=theTFile.ReadElt\ntheTFile.Close \n\n\n'**** this is input for wbasmapx\ntheInputFile = (theInputDir+\"/ppinit/wbasmapx.input\").asFileName\ntheInputFileName = theInputFile.getName\ntheIFile = LineFile.Make(theInputFile,#FILE_PERM_WRITE)\n\n'*** this file is returned fr
om wbasmapx ***\n'theOutputFile= (theExistingDir+\"/wbasmapx.output\").asFileName\n'theOutputFileName = theOutputFile.getName\n'theOFile = LineFile.Make(theOutputFile,#FILE_PERM_READ)\n\n'###########################################\ntheOutputDir.asFileName.SetCWD\ntheOutputFileName = FileDialog.Show(\"*.out\", \".out Files\", \"Please Specify the Data File for Loading Basin(s)\")\nif (theOutputFileName = nil) then\n  exit\nend\nif (File.Exists(theOutputFileName)) then\n  filePointer = LineFile.Make(theOutputFileName, #FILE_PER
M_READ)\n  if (filePointer = nil) then\n    MsgBox.Warning(\"Cann't open file: \"+filePointer.GetFullName, \"Error\")\n    exit\n  end  \n else\n  MsgBox.Warning(\"File \"+theOutputFileName.getFullName++\"not exist\", \"Error\")\n  exit\nend\ntheOFile = LineFile.Make(theOutputFileName,#FILE_PERM_READ)\ntheExistingDir.asFileName.SetCWD\n\nif(theButton=\"no_import\")then\n   System.Execute(\"gad xsets_editor>temp.txt\")\n   theTempFileName = (theExistingDir+\"/temp.txt\").asFileName\n   theTFile = LineFile.Make(theTempFileName,#FILE_PERM_R
EAD)\n   theTFile.setScratch(TRUE)\n   theEditor=theTFile.ReadElt\n   theTFile.Close\n   theCallB=theEditor++theOutputFileName.asString\n   System.Execute(theCallB)  \nelseif(theButton=\"Import\")then   \n   'theCallA=theBinDir+\"/wbasmapx\"++theInputFileName++theOutputFileName\n   'System.Execute(theCallA)\n   theSize=0\n   theTline={}\n   while(theOfile.getSize<>theSize)      \n      theOfile.Read(theTline,theOfile.getSize)\n      theSize=theOfile.getSize\n   end\nend \ntheFileList={}\nfor each i in 0..(theSize-1)\n   theFileL
ist.Add(theTline.get(i).asTokens(\" \"))\nend\n'*** the 2nd line 1st entry is the basin name ***\ntheBasinName=theFileList.get(1).get(0)\n'*** the 3rd line 2nd entry has number of linesegs \"LINESEGS num\" ***'\n'*** build a list of hrapp points   ***'\ntheHrappPoints={}\ntheHrappList={}\ntheRowList={}\ntheColList={}\ntheLatList={}\ntheLonList={}\ntheNumLinesegs=theFileList.get(2).get(1).asNumber\nfor each i in 0..(theNumLinesegs-1)\n   theLineSeg=theFileList.get(3+i)\n   theRow=theLineSeg.get(1).asNumber\n   theBegC=theLineSe
g.get(2).asNumber\n   theEndC=theLineSeg.get(3).asNumber\n   for each j in 0..(theEndC-theBegC)\n      theHrappPoints.Add(Point.Make(theBegC+j+0.5,theRow+0.5))\n      theColList.Add(theBegC+j)\n      theRowList.Add(theRow)\n   end\nend\ntheGeoPoints={}\n'*** convert points from hrapp to geographic\nfor each pt in theHrappPoints\n   theHrapx=pt.getX\n   theHrapy=pt.getY\n   theLatLonList=av.Run(\"coord.hraptoll\",{theHrapx,theHrapy})\n   theLon=theLatLonList.get(0).setFormatPrecision(4)\n   theLat=theLatLonList.get(1).setFor
matPrecision(4)\n   theLatList.Add(theLat)\n   theLonList.Add(theLon)\n   thePt=Point.Make(theLon,theLat)\n   theGeoPoints.Add(thePt)\nend\n \n'*** convert points from geographic to albers ***\ntheAlbersPoints={}\nfor each pt in theGeoPoints\n   thePt=pt.returnProjected(theAprj)\n   theAlbersPoints.Add(thePt)\nend\n''*** output the Hrapp points shapefile ***'\ntheCount=theColList.Count\nfor each pt in 0..(theCount-1)\n   theHrappList.Add(theColList.get(pt))\n   theHrappList.Add(theRowList.get(pt))\n   theHrappList.Add(theLat
List.get(pt))\n   theHrappList.Add(theLonList.get(pt))\nend\ntheType={\"Hrapp X\",#FIELD_LONG,6,0,\"Hrapp Y\",#FIELD_LONG,6,0,\"Lat\",#FIELD_FLOAT,8,4,\"Lon\",#FIELD_FLOAT,9,4}\nthePointsTheme=av.Run(\"mapx.util.ThemeCreating\",{theBasinName+\"_hrapp\"+\".shp\",Point,theType,theHrappList,theAlbersPoints})\ntheView.AddTheme(thePointsTheme)\n\n'*** get the number of lat/lon points at line:3+theNumLinesegs\nthePos=3+theNumLinesegs\ntheNumLatLonPoints=theFileList.get(thePos).get(1)\n''*** read the rest of the file to get the lat/lon p
oints\nthePos=thePos+1\ntheLatList={}\ntheLonList={}\ntheLatLonList={}\ntheHrappList={}\nfor each l in 0..(theSize-thePos-2)\n   theTempList=theFileList.get(thePos+l) \n   for each c in theTempList\n      theTempList2=c.asString.asTokens(\",\")\n      theLat=theTempList2.get(0).asNumber.setFormatPrecision(4)\n      theLon=theTemPList2.get(1).asNumber.setFormatPrecision(4)\n      if(theLon>0)then\n         theLon=-1*theLon\n      end\n      theLatList.Add(theLat)\n      theLonList.Add(theLon)   \n   end\nend\ntheCount=theLatList
.Count\ntheList={}\nthePList={}\nthePolygonList={}\nthePolygon=Polygon.MakeNull\nfor each r in 0..(theCount-1)   \n   theList.Add(Point.Make(theLonList.get(r),theLatList.get(r)).returnProjected(theAprj)) \nend\nthePList.Add(theList)\nthePolygonList.Add(Polygon.Make(thePList))\nthePolygon=av.Run(\"mapx.util.ThemeCreating\",{theBasinName+\".shp\",Polygon,{},{},thePolygonList})\ntheView.AddTheme(thePolygon)"
)

(Script.350
	Name:	"basin.importall.click"
	SourceCode:	"theProject=av.getProject\ntheView=av.getActiveDoc\ntheDialog=SELF.getDialog\ntheListBox=theDialog.FindByName(\"basindumplist\")\ntheBox=theListBox.returnBox\ntheOrigin=0@0 \ntheRowCount=theListBox.getRowCount\ntheRect=Rect.Make(theOrigin,1@theRowCount)\ntheListBox.setSelection(theRect,FALSE)\ntheList=theListBox.getSelection\nav.Run(\"basin.import.click\",{}) "
)

(Script.351
	Name:	"basin.setdefineinfo.click"
	SourceCode:	"theDialog=av.FindDialog(\"ofs-basin-define\")\ntheDialog.open\n'***Set menu Option as object tag\ntheView=av.getActiveDoc\nif(theView.getClass.getClassName<>\"View\")then\n   msgBox.Error(\"a View must be the active document\",\"ERROR\")\n   exit\nend\ntheThemes=theView.GetThemes\n\ntheDictionary=theDialog.getObjectTag\nif(theDictionary = NIL)then\n   MsgBox.Error(\"You must first run the Load OFS Areas and Basins script\",\"Error in\"++Script.The.getName)\n   exit\nend\n'***Display list of themes when dialog opens***'\ntheListBox=the
Dialog.FindByName(\"1hrmapxListBox\")\ntheInputBasinTheme=theDialog.FindByName(\"inputbasintheme\")\ntheInputBasinTheme.Select\ntheInputBasinTheme.Click\n'theListBox.Update\n'theInputBasinTheme.setListeners({theListBox})\n'theInputBasinTheme.BroadCastUpdate\n\n'*** Check to see if Hrapp in view ***\nhaveHrapp=FALSE\nfor each t in theTHemes\n   if(t.getName=\"hrappts.shp\")then\n      haveHrapp=TRUE\n      Break\n   else\n      haveHrapp=FALSE\n   end\nend\nif(haveHrapp.not)then\n   subView=av.Getactivedoc\n   if(subView.Is(View).not
)then\n      msgBox.Error(\"A view must be the active document\",\"\")\n      exit\n   end\n   atag=subView.GetObjectTag\n   if (atag=nil) then\n      'msgbox.info(\"Problem with View.\",\"\")\n      exit\n   end\n\n   if (atag.Is(Dictionary).not) then\n      'msgbox.info(\"Problem with View.\",\"\")\n      exit\n   end\n\n   parView=atag.Get(\"Parent View\")\n   if(parView.Is(View).not)then\n      exit\n   end\n   theInputDataDir = parView.GetObjectTag.Get(\"Input Directory\")\n   theFileName=(theInputDataDir+\"/hrappts.shp\")\n   theHrappSrc=S
rcName.Make(theFileName)\n   if(theHrappSrc=Nil)then    \n      theThemeSrcList=SourceDialog.Show(\"\")\n      if(theThemeSrcList.Count=0)then\n         msgBox.Error(\"Must select an hrapp theme\",\"Need Hrapp Data\")\n         exit\n      end\n      theHrappSrc=theThemeSrcList.get(0)\n   end \n   theHrappftab=Ftab.Make(theHrappSrc)\n   theHrappTheme=Ftheme.Make(theHrappftab)\n   theView.addTheme(theHrappTheme)\nend  \n\n\n\n\n\n\n\n"
)

(Script.352
	Name:	"basin.setdeleteinfo.click"
	SourceCode:	"theDialog=av.FindDialog(\"ofs-basin-delete\")\n'******\n\n'***Set menu Option as object tag\ntheView=av.getActiveDoc\nif(theView.getClass.getClassName<>\"View\")then\n   msgBox.Error(\"a View must be the active document\",\"ERROR\")\n   exit\nend\ntheThemes=theView.GetThemes\ntheDictionary=theDialog.getObjectTag\nif(theDictionary=NIL)then\n   msgBox.Error(\"Your must first run the Load OFS Basins and Areas script\",\"Error in\"++Script.The.getName)\n   exit\nend\ntheDialog.open\ntheList=theDictionary.Get(\"BASINLIST\")\ntheListBox=theDia
log.FindByName(\"basindeletelist\")\ntheListBox.defineFromList(theList)"
)

(Script.353
	Name:	"basin.setdumpinfo.click"
	SourceCode:	"theDialog=av.FindDialog(\"ofs-basin-dump\")\n\n\n'***Set menu Option as object tag\ntheView=av.getActiveDoc\nif(theView.getClass.getClassName<>\"View\")then\n   msgBox.Error(\"a View must be the active document\",\"ERROR\")\n   exit\nend\ntheThemes=theView.GetThemes\ntheDictionary=theDialog.getObjectTag\nif(theDictionary=NIL)then\n  msgBox.Error(\"Your must first run the Load OFS Areas and Basins script\",\"Error in\"++Script.The.getName)\n  exit\nend\ntheDialog.open\ntheList=theDictionary.Get(\"BASINLIST\")\ntheListBox=theDialog.FindByN
ame(\"basindumplist\")\ntheListBox.defineFromList(theList)"
)

(Script.354
	Name:	"cap.10_50_90"
	SourceCode:	"'-----------------------------------------------\n'cap.10_50_90\n\n'Report 10th percentile\n'       50th percentile\n' and   90th percentile \n' values for cumulative distribution plots \n' Inputs: xyList is a list of Lists that\n' contain x and y values for the plotting routine\n'------------------------------------------------\nif (SELF.GetClass.GetClassName=\"Button\") then\n   theView=av.GetActiveDoc\n   viewTag=theView.GetObjectTag\n   xyList=viewTag.Get(5)\nelse\n   xyList=SELF.Get(0)\nend\n'msgbox.info(xyList.count.ass
tring,\"\")\n'--- compute y value for 10th percentile\nxold=0\nyold=0\nfor each l in xyList\n   x=l.Get(0)\n   y=l.Get(1)\n   if (y>10) then \n      x10=xold+((x-xold)/(y-yold)*(10-yold))\n      break\n   end\n   xold=x\n   yold=y\nend\n'--- compute y value for 50th percentile\nxold=0\nyold=0\nfor each l in xyList\n   x=l.Get(0)\n   y=l.Get(1)\n   if (y>50) then \n      x50=xold+((x-xold)/(y-yold)*(50-yold))\n      break\n   end\n   xold=x\n   yold=y\nend\n'--- compute y value for 90th percentile\nxold=0\nyold=0\nfor each l in xyList\n   x
=l.Get(0)\n   y=l.Get(1)\n   if (y>90) then \n      x90=xold+((x-xold)/(y-yold)*(90-yold))\n      break\n   end\n   xold=x\n   yold=y\nend\n\nif (SELF.GetClass.GetClassName=\"Button\") then\n   msgbox.report(\"10th Percentile:\"++x10.SetFormat(\"d\").asstring+nl+\n               \"50th Percentile:\"++x50.SetFormat(\"d\").AsString+nl+\n               \"90th Percentile:\"++x90.SetFormat(\"d\").AsString,\"Statistical Summary\")\nelse\n   return {x10,x50,x90}\nend\n     \n\n\n"
)

(Script.355
	Name:	"cap.about.open"
	SourceCode:	"aboutdlg = av.FindDialog(\"dlg_about\")\naboutdlg.open"
)

(Script.356
	Name:	"cap.addpctfield"
	SourceCode:	"'#---------------------------------------------------------------------\n' name: cap.addpctfield\n'\n' called by: cap.dlg_stats.lbt_ok.click\n'\n' Description: adds a percent field to a foresttypes vtab\n' either for the entire basin or a specific zone\n'\n' Last Modified: 8/29/2000  SMR \n'#----------------------------------------------------------------------\n'\n'----parameters passed from calling script\n  theview=av.finddoc(\"SelectedBasinView: ledc2\")  \n  \n  dataGrid=self.get(0)\n  bsn_idstr=self.get(1)\n  \n  fVTab 
= dataGrid.GetVTab\n  fVTab.SetEditable(true)\n  pctf = Field.Make(\"Percent\", #FIELD_FLOAT, 5, 2)\n  fp = fVTab.FindField(\"Percent\")\n  if (fp<>nil) then \n     fVTab.RemoveFields({fp})\n  end      \n  fVTab.AddFields({pctf})          \n  countf = fVTab.FindField(\"Count\") \n  cTotal = 0 \n  for each rec in fVTab\n     c = fVTab.ReturnValueNumber(countf,rec)   \n     cTotal = cTotal + c \n  end\n  if (cTotal = 0) then msgbox.info(\"Total count is zero\",\"\") return nil end\n             \n  for each rec in fVTab\n    vc = fVTab
.ReturnValueNumber(countf,rec)\n    fVTab.SetValue(pctf, rec, vc/cTotal*100)\n  end        \n       \n       \n  aTable=Table.Make(fVtab)\n  aTable.SetName(\"Detailed Forest Type:\"++bsn_idstr.Ucase)               \n  fVTab.SetEditable(false)\n \n  '--- return the name of the input table\n  return \"Detailed Forest Type:\"++bsn_idstr.Ucase\n   \n"
)

(Script.357
	Name:	"cap.canunload"
	SourceCode:	"return (system.CanUnloadLibrary(self.getdependencies.get(0)))"
)

(Script.358
	Name:	"cap.checktagdict"
	SourceCode:	"'#--------------------------------------------------------------------\n' Name:  cap.checktagdict\n' Function:  if a Tag Dictionary returns a nil value or the \n' user has removed a tagged theme from the view, then\n' allow the user to select the required Theme manually or cancel\n' Created 9/08/2000 by SMR\n'#--------------------------------------------------------------------\n\ntheview=self.get(0)\ntagstring=self.get(1)\ntagdict=self.get(2)\nisgrid=self.get(3)\n\ndemTheme=tagdict.Get(tagstring)\n\nif (demTheme=nil) the
n\n    '---\n    if (isgrid) then\n       themeList=av.run(\"util.getthms\",{theview,false,Gtheme,nil})\n       if (themeList.Count=0) then\n          msgbox.Info(\"No grids theme not available in View.\",script.the.getname)\n          return nil\n       else\n          theTheme=msgbox.Choice(themeList,\"Identify\"++tagstring++\"Cancel if not found.\",script.the.getname)\n          tagdict.Set(tagstring,theTheme)\n          return theTheme\n       end\n    else\n       themeList=av.run(\"util.getthms\",{theview,false,Ftheme,\"Poly
\"})\n       if (themeList.Count=0) then\n          msgbox.Info(tagstring++\"theme not available in View.\",script.the.getname)\n          return nil\n       else\n          theTheme=msgbox.Choice(themeList,\"Identify\"++tagstring++\"Cancel if not found.\",script.the.getname)\n          tagdict.Set(tagstring,theTheme)\n          return theTheme\n       end\n    end\nelse\n  return demTheme\nend\n\n    \n     "
)

(Script.359
	Name:	"cap.clearobjecttags"
	SourceCode:	"'#--------------------------------------------------------------------\n' Name: cap.clearobjecttags\n' Description: Clear any object tags that may have Themes attaced to them\n'#--------------------------------------------------------------------\n\ncheck=msgbox.yesno(\"Are you sure you want to clear Threshr and Cap object tags?\",script.the.getname,true)\nif ((check=nil) or (check=false)) then\n  exit\nend\n\n'Remove any RFC Main Views.\ntheproject=av.GetProject\ndocList=theproject.GetDocs\nfor each d in docList\n   doTag
=d.GetObjectTag\n   if (doTag<>nil) then\n      if (doTag.Is(Dictionary)) then\n         if ((doTag.Get(\"ThreshR\")<>nil) or (doTag.Get(\"CAPSubbasin\")<>nil)) then\n           d.SetObjectTag(nil)\n         end\n      end\n   end\nend\nav.PurgeObjects"
)

(Script.360
	Name:	"cap.createsubview"
	SourceCode:	"'-------------------------------------------------------------------\n' Name: cap.createsubview\n'   This is the script that clips info for one selected sub-basin\n'     This works when a sub-basin is selected by select features button\n'\n'   Descriptions:  Works only when a polygon theme is Active and at least\n'   one polygon is selected within this theme\n'\n'   Created By: Ziya Zhang on 7/14/2000\n'   Modified 8/3/2000 by SMR\n'   Modified 8/14/2000 by ZZ\n'   Modified 12/05/2000 by SMR\n'-------------------------
------------------------------------------\n  workdir=av.getproject.getworkdir\n  outfile=Filename.Merge(workdir.asstring,\"chksel.txt\")\n  chkfile=linefile.make(outfile,#file_perm_write)\n  gcellsize=400.0\n' ---Gets CAPMainView\n  vCAP_Main = av.GetActiveDoc \n  \n  tagdict = vCAP_Main.getobjecttag\n  if (tagdict=nil) then \n     msgbox.info(\"Please rerun setup.\",script.the.getname) \n     exit\n     '+++++++++++\n     ' future option might allow the user to select default\n     ' themes to be clipped at this point but 
not now\n     '+++++++++++\n  end\n  '-----------------------------------------------------\n  ' Create initial lists of Themes that will be clipped \n  '-----------------------------------------------------\n  vectThemeTags={\"RF1 Streams\"}\n  vNameDict=Dictionary.Make(1)\n  vNameDict.Add(\"RF1 Streams\",\"rf1.shp\")\n  subvTags={\"Subbasin RF1 Streams\"}\n  gridThemeTags={\"Elevation\",\"Mean Annual Ppt\",\"Mean Annual Tmp\",\"Annual PE\",\"Forest Percent Cover\",\"Detailed Forest Type\"}\n  gridNameDict=Dictionary.Make(6)\n  gridNameD
ict.Add(\"Elevation\",\"dem\")\n  gridNameDict.Add(\"Mean Annual Ppt\",\"pptann\")\n  gridNameDict.Add(\"Mean Annual Tmp\",\"tmpann\")\n  gridNameDict.Add(\"Annual PE\",\"peann\")\n  gridNameDict.Add(\"Forest Percent Cover\",\"for_pct\")\n  gridNameDict.Add(\"Detailed Forest Type\",\"for_type\")\n  \n  subgTags=List.Make\n  vectThemes=List.Make\n  gridThemes=List.make\n  gNames=List.Make\n  vNames=List.Make\n  \n  missingvString=\"\"\n  for each vTag in vectThemeTags\n    t=tagdict.get(vTag)\n    if (t<>nil) then\n       vectThemes.add(t)\n       vNa
mes.Add(vNameDict.Get(vTag))\n    else\n       missingvString=missingvString+vTag+nl\n       msgbox.report(\"Warning, Missing Shapefile(s):\"+nl+missingvString,script.the.getname) \n    end\n  end\n  \n  missingGridString=\"\"\n  gcellsize=400.0    'set default initial value   \n  for each gTag in gridThemeTags\n    t=tagdict.get(gTag)\n    '--- Get the Grid Cell Size from the Elevation Grid\n    if (t<>nil) then\n       if (gTag=\"Elevation\") then\n          elevGrid=t.GetGrid\n          gcellsize=elevGrid.GetCellSize\n       
end\n       if (t.GetClass.GetClassName <> \"GTheme\") then\n         msgbox.error(\"Problem with\"++gTag,script.the.getname)\n         exit\n       end \n       'chkfile.writeelt(t.getname)\n       gridThemes.add(t)\n       gNames.Add(gridNameDict.get(gTag))\n       subgTags.Add(\"Subbasin\"++gTag)\n    else\n       'compile a list of missing grids and warn \n       if (gTag=\"Elevation\") then\n          msgbox.error(\"Required Elevation Grid is Missing\",script.the.getname)\n          exit\n       end\n       missingGridString=m
issingGridString+gTag+nl\n       msgbox.report(\"Warning, Missing Grid(s):\"+nl+missingGridString,script.the.getname)\n       '--- Need to give user the option to select the appropriate Themes \n    end\n  end\n  \n'-----------------------------------------------------\n' Identify clipping subbasin polygon  \n'-----------------------------------------------------\n actTheme=vCap_Main.GetActivethemes.get(0)\n myFTab  = actTheme.GetFTab\n if (myFtab.GetSelection.Count=1) then\n   single_basin=true\n else\n   single_basin=fal
se\n end\n myShapeField=myFtab.FindField(\"shape\")\n \nsubdata_exists=false \nif (single_basin) then\n \n  '+++++++++++++++Ziya Added the following\n  myField = MsgBox.Choice(myFTab.GetFields,\"Select field with a 5 character basin identifier (e.g. ch5_id or shef_id)\",\"Field Selection\")\n  if (myField = nil) then \n     exit \n  end \n \n  for each rec in myFTab.GetSelection   \n       selbsn_idstr = myFTab.ReturnValue(myField,rec)\n       if (selbsn_idstr.count > 5) then\n         msgbox.error(\"Error, selected field must co
ntain a 5 character ID\",script.the.getname)\n         exit\n       end  \n       yesno=msgbox.yesno(\"Sub-basin \"++selbsn_idstr++\" from the theme \"++actTheme.AsString++\" is selected! Do you want to proceed?\",\"Proceed Action\",true) \n       if (yesno = false) then exit end \n   end\n   selbsn_idstr=selbsn_idstr.Lcase\n   \n   outdir=tagdict.get(\"Output Directory\")\n   if (outdir=nil) then\n      chkout=msgbox.yesno(\"Output directory not specified.  Use project working directory?\",\"Output Directory\",true)\n      if (chko
ut=false) then\n        msgbox.info(\"Rerun setup to choose output directory.\",script.the.getname)\n        exit\n      elseif (chkout=nil) then\n        exit\n      else\n        outdir=av.GetProject.GetWorkDir\n      end\n   end\n   '\n   newdir=outdir.asFilename\n   newdir.MergePath(selbsn_idstr)\n   \n   if (newdir.isdir) then  'make a subdirectory if one does not already exist\n      chk=msgbox.yesnocancel(\"Directory\"++newdir.asstring++\"exists.  Retrieve previously clipped data?\",script.the.getname,true)\n      if (ch
k=nil) then\n         exit\n      end\n      if (chk) then\n         '-- dataexists\n         subdata_exists=true\n      else\n         msgbox.report(\"Delete or rename this directory\"+nl+\"and its contents and re-run Cap --> Create SubView for Selected Basin.\",script.the.getname)\n         exit\n      end\n   else\n      theOSEnum=System.GetOS\n      if (theOSEnum.asstring=\"SYSTEM_OS_MSW\") then\n         system.execute(\"c:\\command.com /c mkdir\"++newdir.asstring)\n      else\n         System.Execute(\"mkdir\"++newdir.asstring
)\n      end\n   end\n   \nelse 'if forecast group\n\n   selbsn_idstr = MsgBox.Input(\"Enter a 5 character identifier for your forecast group.\",script.the.getname,\"aaaaa\")\n   if (selbsn_idstr = nil) then \n      exit \n   end \n   if (selbsn_idstr.count > 5) then\n         msgbox.error(\"Error, identifier must have 5 or fewer characters.\",script.the.getname)\n         exit\n   end\n   selbsn_idstr=selbsn_idstr.Lcase\n   \n  outdir=tagdict.get(\"Output Directory\")\n   if (outdir=nil) then\n      chkout=msgbox.yesno(\"Output dire
ctory not specified.  Use project working directory?\",\"Output Directory\",true)\n      if (chkout=false) then\n        msgbox.info(\"Rerun setup to choose output directory.\",script.the.getname)\n        exit\n      else\n        outdir=av.GetProject.GetWorkDir\n      end\n   end\n   '\n   newdir=outdir.asfilename\n   newdir.MergePath(selbsn_idstr)\n   if (newdir.isdir) then  'make a subdirectory if one does not already exist\n      chk=msgbox.yesnocancel(\"Directory\"++newdir.asstring++\"exists.  Retrieve previously clipped
 data?\",script.the.getname,true)\n      if (chk) then\n         '-- dataexists\n         subdata_exists=true\n      else\n         msgbox.report(\"Delete or rename this directory and its contents.\"+nl+\n         \"and re-run Cap --> Create SubView for Selected Basin.\",script.the.getname)\n      end\n   else\n      System.Execute(\"mkdir\"++newdir.asstring)\n   end\n  \n   if (subdata_exists=false) then \n      mergedbas=nil\n      '--- build an analysis polygon for the analysis area\n      for each rec in myFtab.getselection\n
         basshape=myFtab.returnvalue(myshapeField,rec)\n         if (mergedbas=nil) then\n           mergedbas=basshape\n         else\n           mergedbas=mergedbas.returnunion(basshape)\n         end\n      end\n   end\n\nend  'if forecast group\n\n\n'--------------------------------------------------\n'--- Create a new subbasin View and set object tags\n'--------------------------------------------------\n\nvSub_basin = View.Make  \n\nav.run(\"util.createsubbasinviewobjecttag\",{vSub_basin})\nsubtagdict=vSub_basin.getobject
tag\nsubtagdict.Set(\"Parent View\",vCAP_Main)\n\nchkfile.writeelt(\"gothere2\")  \n \n'--- Create a new Shapefile of the selected basin\n'--- or load previously saved file\nclipFname = Filename.Merge(newdir.asstring,(selbsn_idstr+\".shp\"))\nif (subdata_exists=false) then\n   clipFTab = myFtab.Export(clipFname, Shape, myFtab.GetSelection.Count > 0) \n   aCliptheme = Ftheme.make(clipFtab)\n   'vSub_basin.AddTheme(aCliptheme)\nelse\n   sourcefstr=clipFname.asstring\n   insourcename=srcname.make(sourcefstr)\n   if (insourcename=n
il) then\n      msgbox.info(\"Could not find \"++sourcefstr,script.the.getname)\n      exit\n   end\n   aClipTheme=theme.make(insourcename)\n   'vSub_basin.AddTheme(aClipTheme)\nend\n\nsubtagdict.set(\"Subbasin Polygon\",aCliptheme)\nsubtagdict.set(\"Subbasin ID Name\",selbsn_idstr)\n\nif (subdata_exists=false) then\n  if (single_basin) then\n    clipFtab = aCliptheme.GetFtab\n    shapeField = clipFtab.FindField(\"Shape\")\n    if (shapeField = nil) then\n       msgbox.error(\"No Shape field in this theme: \"++aCliptheme.GetName.AsS
tring,\"\")\n       exit\n    end  \n    theClipShape = clipFtab.ReturnValue(shapeField,0)\n  else\n    theClipShape=mergedbas\n  end\n\n  '------------------------------------------\n  '--- Explicitly Specify the Analysis Extent\n  '------------------------------------------\n  arect=theClipShape.ReturnExtent\n\n  'Make sure the rectangle extent is consistent with alignment of DEM Grid cells\n  ' Assumes (1) coordinate system origin is 0,0 and (2) x is increasing left to right\n  ' and y is increasing bottom to top\n  \n   a
Left=arect.GetLeft\n   numLeft=(aLeft/gcellsize).truncate\n   theLeft=(numLeft-10)*gcellsize\n  \n   aRight=arect.GetRight\n   numRight=(aRight/gcellsize).truncate\n   theRight=(numRight+10)*gcellsize\n  \n   aBottom=arect.GetBottom\n   numBottom=(aBottom/gcellsize).truncate\n   theBottom=(numBottom-10)*gcellsize\n  \n   aTop=arect.GetTop\n   numTop=(aTop/gcellsize).truncate\n   theTop=(numTop+10)*gcellsize\n   theRect=Rect.MakeXY(theLeft,theBottom,theRight,theTop)\n  \n  aEnv = vCAP_Main.GetExtension(analysisenvironment)\n 
 '--- remember the initial analysis environment settings\n  oldrect=Rect.MakeXY(0,0,1,1)\n  oldcellsize=gcellsize\n  oldae_enum=aEnv.getextent(oldrect)\n  oldae_enum=aEnv.getcellsize(oldcellsize)  \n  \n  aEnv.SetExtent(#ANALYSISENV_value,theRect)\n  \n  aEnv.SetCellSize(#analysisenv_value,gcellsize)\n  aEnv.Activate \n      \n  '----------------------------------------\n  '--- End of analysis extent specification\n  '----------------------------------------\nend     'if subdata_exists   \n          \n'--------------------
--------------------------------------\n' Clip Selected Grid and Vector Themes or Load from Previously \n' Saved Data  \n'----------------------------------------------------------\n\n'-------------------------------------------------------\n' Grid Data\n'-------------------------------------------------------\nif (subdata_exists=false) then\n  ' Add clipped data to the subbasin View\n  gridcount=0\n  for each aGridTheme in gridThemes       '---Clip all grid themes\n    gName=gNames.Get(gridcount)  \n    aGrid=aGridThem
e.GetGrid\n    if ((gName=\"dem\") or (gName=\"for_type\")) then\n       cutGrid=aGrid.ExtractByPolygon(theClipShape,prj.MakeNull,False)\n    else\n       cutGrid=aGrid.ExtractByRect(theRect,prj.MakeNull,false)\n    end\n    cutFN=FileName.Merge(newdir.asstring,gName)\n    cutGrid.SaveDataSet(cutFN)\n    outGTheme=GTheme.Make(cutGrid) \n    outGTheme.SetName(cutFN.getBaseName)\n    vSub_basin.AddTheme(outGTheme)\n    outGTheme.SetLegendVisible(false)   '---Hide legend\n    subtagdict.set(subgTags.get(gridcount),outGTheme)\n
    gridcount=gridcount+1\n  end \nelse\n  \n  for each gridTag in gridThemeTags\n      'msgbox.info(newdir.asstring,\"\")\n      gName=gridNameDict.Get(gridTag)\n      gSrcfname=filename.merge(newdir.asstring,gName)\n      gSrcfstr=gSrcfname.AsString\n      'msgbox.info(gSrcfstr,\"\")\n      gSrcname=Grid.MakeSrcName(gSrcfstr)\n      if (gSrcname=nil) then\n         continue\n         'chk=msgbox.yesno(\"Could not find\"++gSrcfstr++\"Continue?\",\"CAP load prism input data\",true)\n         'if (chk) then\n         '  continue\n   
      'else \n         '  exit\n         'end\n      else\n        'msgbox.info(gSrcname.asstring,\"\")\n        agTheme = Theme.Make(gSrcname)\n        vSub_basin.AddTheme( agTheme )  \n        agTheme.SetLegendVisible(False)\n        subtagStr=\"Subbasin\"++gridTag\n        subtagdict.Set(subtagStr,agTheme)\n      end 'if grid is found\n   end   'loop through gridNames\n    \nend   'if subbasin data already exists\n\n'-------------------------------------------------------\n' Vector Data\n'------------------------------------
-------------------\nif (subdata_exists=false) then\n    vcount=0          \n    for each vTheme in vectthemes  \n      'Specify the output shapefile \n      vName=vNames.Get(vcount)\n      outFName = FileName.Merge(newdir.asstring,vName)\n      'outputftab=av.run(\"cap.clippoly_sub\",{vTheme,theClipShape,outFName})\n      outputftab=av.run(\"cap.extracthavecenterin\",{vTheme.GetFtab,myftab,outFName})\n      clippedTheme = FTheme.Make( outputFTab )\n      clippedTheme.SetName(outputFTab.getName)\n      vSub_basin.AddTheme
(clippedTheme )\n      'subtagdict.set(subgTags.get(gridcount),outGTheme)\n      subtagdict.set(subvTags.get(vcount),clippedTheme)   'Changed by ZYZ\n      vcount=vcount + 1  \n    end\nelse\n   for each vectTag in vectThemeTags\n       vName=vNameDict.Get(vectTag)\n       sourcefname=filename.merge(newdir.asstring,vName)\n       sourcefstr=sourcefname.asstring\n       insourcename=srcname.make(sourcefstr)\n       if (insourcename=nil) then\n        \n         continue\n         'chk=msgbox.yesno(\"Could not find \"++sourc
efstr++\" Continue?\",\"Cap loadinputdata\",true)\n         'if (chk) then\n         '  continue\n         'else \n         ' exit\n         'end\n       end\n       vtheme=theme.make(insourcename)\n       vSub_basin.addtheme(vtheme)\n       subtagStr=\"Subbasin\"++vectTag\n       subtagdict.Set(subtagStr,vTheme)\n   end   'loop through gridNames\n   \nend \n\n'Add the basin boundary theme last so it will be displayed at the top   \nvSub_basin.AddTheme(aClipTheme)\n\n'-------------------------------------------------------\n' Set L
egends\n'-------------------------------------------------------\n   '---Selected Sub_basin\n      basin_theme=aCliptheme  \n      newlegend=basin_theme.GetLegend\n      theSymbols=newlegend.GetSymbols\n      theSymbols.get(0).getcolor.SetTransparent(true)\n      theSymbols.Get(0).SetOlcolor(color.getblack)\n      theSymbols.Get(0).SetOlwidth(2)\n      basin_theme.updatelegend\n      basin_theme.setvisible(true)  \n      \n   '---Streams inside\n      '--- set river line to blue\n      stream_theme=subtagdict.get(\"Subbas
in RF1 Streams\") \n      if (stream_theme<>nil) then\n        newlegend=legend.make( #symbol_pen )\n        newlegend.getsymbols.get(0).setcolor(color.getblue)\n        if (stream_theme<>nil) then\n          stream_theme.setlegend(newlegend)\n          stream_theme.updatelegend\n        end\n        stream_theme.setvisible(true)\n      end\n      \n'---Set the precipitation to a standard legend\n  legend_dir = tagdict.get(\"Legend Directory\")\n  ppt_theme = subTagDict.get(\"Subbasin Mean Annual Ppt\")\n  if (ppt_theme<>nil)
 then\n    plegend = ppt_theme.GetLegend\n    plegend.Load(filename.merge(legend_dir,\"ppt_legend.avl\"),#LEGEND_LOADTYPE_SYMBOLS)\n    ppt_theme.SetLegend(plegend)\n    ppt_theme.UpdateLegend\n    ppt_theme.SetVisible(False)\n  end      \n\n'--- Set the forest cover-type labels correctly\n   forTheme = subTagdict.Get(\"Subbasin Detailed Forest Type\")\n   if (forTheme<>nil) then\n      av.run(\"cap.for_typelegend\",{forTheme})\n   end   \n   \n'++++++++++++++++++++++++++++++++++++  \n'++++ Set the temp to a standard legend\n'++
++++++++++++++++++++++++++++++++++\n\n'--- Set color map for DEM theme\n  dem_theme = subTagDict.get(\"Subbasin Elevation\")\n  if (dem_theme<>nil) then\n    demLegend = dem_theme.GetLegend\n    demLegend.Load(filename.merge(legend_dir,\"dem_legend2.avl\"),#LEGEND_LOADTYPE_SYMBOLS)  \n    dem_theme.SetLegend(demLegend)\n    dem_theme.UpdateLegend\n    dem_theme.SetVisible(False)  \n  end\n\n'-------------------------------------------------------\n' After all themes for the selected sub-basin are ready\n' then define the vie
w properties and open the view\n'-------------------------------------------------------\n  \n'---Set the View units to Meters---\n    vUnits_Enum=vCAP_main.GetUnits\n    vSub_basin.SetUnits(vUnits_Enum)\n  \n'---Set the distance units to meters---\n    dmain_enum=vCAP_main.GetDisplay.GetDistanceUnits\n    d = vSub_basin.GetDisplay\n    d.SetDistanceUnits(dmain_enum)\n\n'---Set the new view name as selected basin ID/name---\n    'vSub_basin.SetName(\"SelectedBasinView: \"++sel_basin)\n    vSub_basin.SetName(\"SelectedBasinV
iew:\"++selbsn_idstr)\n    \n'---Open the new view ---\n    aWindow = vSub_basin.GetWin\n    aWindow.Open\n\nif (subdata_exists=false) then\n  'Reset the analysis extent before exiting\n  aEnv.setcellsize(oldae_enum,oldcellsize)\n  aEnv.setextent(oldae_enum,oldrect)\n  aEnv.Activate\nend\n     \n'Zoom all themes to full extent\nr = vSub_basin.ReturnExtent\nif (r.IsEmpty) then\n  return nil\nelseif ( r.ReturnSize = (0@0) ) then\n  vSub_basin.GetDisplay.PanTo(r.ReturnOrigin)\nelse\n  vSub_basin.GetDisplay.SetExtent(r.Scale(1.1))\n
  av.GetProject.SetModified(true)\nend\n   \n\n\n"
)

(Script.361
	Name:	"cap.createsubview.update"
	SourceCode:	"'-------------------------------------------------------------------\n' Name: cap.createsubview.update\n' Description:  All selection of subbasin view only when a polygon \n' feature is active and at least one polygon is selected. \n'-------------------------------------------------------------------\n\ntheView = av.GetActiveDoc\ntlist = theView.GetActiveThemes\nif (tlist.count<>1) then\n   SELF.SetEnabled(false)\n   exit\nelse\n   actTheme = theView.GetActiveThemes.get(0)\n   'If active theme is a not an Ftheme\n   if (
actTheme.getclass.getclassname<>\"Ftheme\") then\n      SELF.SetEnabled(false)\n      exit\n   else\n      actFtab=actTheme.GetFtab\n      if (actFtab.GetShapeClass.GetClassName<>\"Polygon\") then\n         SELF.SetEnabled(false)\n         exit\n      end\n      if (actFtab.GetSelection.Count=0) then\n        SELF.SetEnabled(false)\n        exit\n      end\n   end\nend\nSELF.SetEnabled(true)\n    \n   \n"
)

(Script.362
	Name:	"cap.createsubview_pc"
	SourceCode:	"'-------------------------------------------------------------------\n' Name: cap.createsubview\n'   This is the script that clips info for one selected sub-basin\n'     This works when a sub-basin is selected by select features button\n'\n'   Descriptions:  Works only when a polygon theme is Active and at least\n'   one polygon is selected within this theme\n'\n'   Created By: Ziya Zhang on 7/14/2000\n'   Modified 8/3/2000 by SMR\n'   Modified 8/14/2000 by ZZ\n'   Modified 12/05/2000 by SMR\n'-------------------------
------------------------------------------\n  \n  workdir=av.getproject.getworkdir\n  outfile=Filename.Merge(workdir.asstring,\"chksel.txt\")\n  chkfile=linefile.make(outfile,#file_perm_write)\n  gcellsize=400.0\n' ---Gets CAPMainView\n  vCAP_Main = av.GetActiveDoc \n  \n  tagdict = vCAP_Main.getobjecttag\n  if (tagdict=nil) then \n     msgbox.info(\"Please rerun setup.\",script.the.getname) \n     exit\n     '+++++++++++\n     ' future option might allow the user to select default\n     ' themes to be clipped at this point b
ut not now\n     '+++++++++++\n  end\n  '-----------------------------------------------------\n  ' Create initial lists of Themes that will be clipped \n  '-----------------------------------------------------\n  vectThemeTags={\"RF1 Streams\"}\n  vNameDict=Dictionary.Make(1)\n  vNameDict.Add(\"RF1 Streams\",\"rf1.shp\")\n  subvTags={\"Subbasin RF1 Streams\"}\n  gridThemeTags={\"Elevation\",\"Mean Annual Ppt\",\"Mean Annual Tmp\",\"Annual PE\",\"Forest Percent Cover\",\"Detailed Forest Type\"}\n  gridNameDict=Dictionary.Make(6)\n  gridNa
meDict.Add(\"Elevation\",\"dem\")\n  gridNameDict.Add(\"Mean Annual Ppt\",\"pptann\")\n  gridNameDict.Add(\"Mean Annual Tmp\",\"tmpann\")\n  gridNameDict.Add(\"Annual PE\",\"peann\")\n  gridNameDict.Add(\"Forest Percent Cover\",\"for_pct\")\n  gridNameDict.Add(\"Detailed Forest Type\",\"for_type\")\n  \n  subgTags=List.Make\n  vectThemes=List.Make\n  gridThemes=List.make\n  gNames=List.Make\n  vNames=List.Make\n  \n  missingvString=\"\"\n  for each vTag in vectThemeTags\n    t=tagdict.get(vTag)\n    if (t<>nil) then\n       vectThemes.add(t)\n       
vNames.Add(vNameDict.Get(vTag))\n    else\n       missingvString=missingvString+vTag+nl\n       msgbox.report(\"Warning, Missing Shapefile(s):\"+nl+missingvString,script.the.getname) \n    end\n  end\n  \n  missingGridString=\"\"\n  gcellsize=400.0    'set default initial value   \n  for each gTag in gridThemeTags\n    t=tagdict.get(gTag)\n    '--- Get the Grid Cell Size from the Elevation Grid\n    if (t<>nil) then\n       if (gTag=\"Elevation\") then\n          elevGrid=t.GetGrid\n          gcellsize=elevGrid.GetCellSize\n    
   end\n       if (t.GetClass.GetClassName <> \"GTheme\") then\n         msgbox.error(\"Problem with\"++gTag,script.the.getname)\n         exit\n       end \n       'chkfile.writeelt(t.getname)\n       gridThemes.add(t)\n       gNames.Add(gridNameDict.get(gTag))\n       subgTags.Add(\"Subbasin\"++gTag)\n    else\n       'compile a list of missing grids and warn \n       if (gTag=\"Elevation\") then\n          msgbox.error(\"Required Elevation Grid is Missing\",script.the.getname)\n          exit\n       end\n       missingGridStrin
g=missingGridString+gTag+nl\n       msgbox.report(\"Warning, Missing Grid(s):\"+nl+missingGridString,script.the.getname)\n       '--- Need to give user the option to select the appropriate Themes \n    end\n  end\n  \n'-----------------------------------------------------\n' Identify clipping subbasin polygon  \n'-----------------------------------------------------\n actTheme=vCap_Main.GetActivethemes.get(0)\n myFTab  = actTheme.GetFTab\n if (myFtab.GetSelection.Count=1) then\n   single_basin=true\n else\n   single_basin=
false\n end\n myShapeField=myFtab.FindField(\"shape\")\n \nsubdata_exists=false \nif (single_basin) then\n \n  '+++++++++++++++Ziya Added the following\n  myField = MsgBox.Choice(myFTab.GetFields,\"Select field with a 5 character basin identifier (e.g. ch5_id or shef_id)\",\"Field Selection\")\n  if (myField = nil) then \n     exit \n  end \n \n  for each rec in myFTab.GetSelection   \n       selbsn_idstr = myFTab.ReturnValue(myField,rec)\n       if (selbsn_idstr.count > 5) then\n         msgbox.error(\"Error, selected field must
 contain a 5 character ID\",script.the.getname)\n         exit\n       end  \n       yesno=msgbox.yesno(\"Sub-basin \"++selbsn_idstr++\" from the theme \"++actTheme.AsString++\" is selected! Do you want to proceed?\",\"Proceed Action\",true) \n       if (yesno = false) then exit end \n   end\n   selbsn_idstr=selbsn_idstr.Lcase\n   \n   outdir=tagdict.get(\"Output Directory\")\n   if (outdir=nil) then\n      chkout=msgbox.yesno(\"Output directory not specified.  Use project working directory?\",\"Output Directory\",true)\n      if (c
hkout=false) then\n        msgbox.info(\"Rerun setup to choose output directory.\",script.the.getname)\n        exit\n      elseif (chkout=nil) then\n        exit\n      else\n        outdir=av.GetProject.GetWorkDir\n      end\n   end\n   '\n   newdir=outdir.asFilename\n   newdir.MergePath(selbsn_idstr)\n   \n   if (newdir.isdir) then  'make a subdirectory if one does not already exist\n      chk=msgbox.yesnocancel(\"Directory\"++newdir.asstring++\"exists.  Retrieve previously clipped data?\",script.the.getname,true)\n      if 
(chk=nil) then\n         exit\n      end\n      if (chk) then\n         '-- dataexists\n         subdata_exists=true\n      else\n         'do nothing\n         'msgbox.report(\"Delete or rename this directory\"+nl+\"and its contents and re-run Cap --> Create SubView for Selected Basin.\",script.the.getname)\n         'exit\n      end\n   else\n      '\n      msgbox.info(\"Create a directory named:\"++newdir.asstring++\"and rerun\",\"Safer manual creation for Windows\") \n      exit\n      'theOSEnum=System.GetOS\n'      if (theOSEn
um.asstring=\"SYSTEM_OS_MSW\") then\n'         system.execute(\"c:\\command.com /c mkdir\"++newdir.asstring)\n'      else\n'         System.Execute(\"mkdir\"++newdir.asstring)\n'      end\n   end\n   \nelse 'if forecast group\n\n   selbsn_idstr = MsgBox.Input(\"Enter a 5 character identifier for your forecast group.\",script.the.getname,\"aaaaa\")\n   if (selbsn_idstr = nil) then \n      exit \n   end \n   if (selbsn_idstr.count > 5) then\n         msgbox.error(\"Error, identifier must have 5 or fewer characters.\",script.the.getname
)\n         exit\n   end\n   selbsn_idstr=selbsn_idstr.Lcase\n   \n  outdir=tagdict.get(\"Output Directory\")\n   if (outdir=nil) then\n      chkout=msgbox.yesno(\"Output directory not specified.  Use project working directory?\",\"Output Directory\",true)\n      if (chkout=false) then\n        msgbox.info(\"Rerun setup to choose output directory.\",script.the.getname)\n        exit\n      else\n        outdir=av.GetProject.GetWorkDir\n      end\n   end\n   '\n   newdir=outdir.asfilename\n   newdir.MergePath(selbsn_idstr)\n   if (ne
wdir.isdir) then  'make a subdirectory if one does not already exist\n      chk=msgbox.yesnocancel(\"Directory\"++newdir.asstring++\"exists.  Retrieve previously clipped data?\",script.the.getname,true)\n      if (chk) then\n         '-- dataexists\n         subdata_exists=true\n      else\n         'do nothing\n         'msgbox.report(\"Delete or rename this directory and its contents.\"+nl+\n         '\"and re-run Cap --> Create SubView for Selected Basin.\",script.the.getname)\n         'exit\n      end\n   else\n      msgb
ox.info(\"Create a directory named:\"++newdir.asstring++\"and rerun\",\"Safer manual creation for Windows\") \n      exit\n      'theOSEnum=System.GetOS\n'      if (theOSEnum.asstring=\"SYSTEM_OS_MSW\") then\n'         system.execute(\"c:\\command.com /c mkdir\"++newdir.asstring)\n'      else\n'         System.Execute(\"mkdir\"++newdir.asstring)\n'      end\n      \n   end\n  \n   if (subdata_exists=false) then \n      mergedbas=nil\n      '--- build an analysis polygon for the analysis area\n      for each rec in myFtab.getselection
\n         basshape=myFtab.returnvalue(myshapeField,rec)\n         if (mergedbas=nil) then\n           mergedbas=basshape\n         else\n           mergedbas=mergedbas.returnunion(basshape)\n         end\n      end\n   end\n\nend  'if forecast group\n\n\n'--------------------------------------------------\n'--- Create a new subbasin View and set object tags\n'--------------------------------------------------\n\nvSub_basin = View.Make  \n\nav.run(\"util.createsubbasinviewobjecttag\",{vSub_basin})\nsubtagdict=vSub_basin.getobjec
ttag\nsubtagdict.Set(\"Parent View\",vCAP_Main)\n\nchkfile.writeelt(\"gothere2\")  \n \n'--- Create a new Shapefile of the selected basin\n'--- or load previously saved file\nclipFname = Filename.Merge(newdir.asstring,(selbsn_idstr+\".shp\"))\nif (subdata_exists=false) then\n   clipFTab = myFtab.Export(clipFname, Shape, myFtab.GetSelection.Count > 0) \n   aCliptheme = Ftheme.make(clipFtab)\n   'vSub_basin.AddTheme(aCliptheme)\nelse\n   sourcefstr=clipFname.asstring\n   insourcename=srcname.make(sourcefstr)\n   if (insourcename=
nil) then\n      msgbox.info(\"Could not find \"++sourcefstr,script.the.getname)\n      exit\n   end\n   aClipTheme=theme.make(insourcename)\n   'vSub_basin.AddTheme(aClipTheme)\nend\n\nsubtagdict.set(\"Subbasin Polygon\",aCliptheme)\nsubtagdict.set(\"Subbasin ID Name\",selbsn_idstr)\n\nif (subdata_exists=false) then\n  if (single_basin) then\n    clipFtab = aCliptheme.GetFtab\n    shapeField = clipFtab.FindField(\"Shape\")\n    if (shapeField = nil) then\n       msgbox.error(\"No Shape field in this theme: \"++aCliptheme.GetName.As
String,\"\")\n       exit\n    end  \n    theClipShape = clipFtab.ReturnValue(shapeField,0)\n  else\n    theClipShape=mergedbas\n  end\n\n  '------------------------------------------\n  '--- Explicitly Specify the Analysis Extent\n  '------------------------------------------\n  arect=theClipShape.ReturnExtent\n\n  'Make sure the rectangle extent is consistent with alignment of DEM Grid cells\n  ' Assumes (1) coordinate system origin is 0,0 and (2) x is increasing left to right\n  ' and y is increasing bottom to top\n  \n   
aLeft=arect.GetLeft\n   numLeft=(aLeft/gcellsize).truncate\n   theLeft=(numLeft-10)*gcellsize\n  \n   aRight=arect.GetRight\n   numRight=(aRight/gcellsize).truncate\n   theRight=(numRight+10)*gcellsize\n  \n   aBottom=arect.GetBottom\n   numBottom=(aBottom/gcellsize).truncate\n   theBottom=(numBottom-10)*gcellsize\n  \n   aTop=arect.GetTop\n   numTop=(aTop/gcellsize).truncate\n   theTop=(numTop+10)*gcellsize\n   theRect=Rect.MakeXY(theLeft,theBottom,theRight,theTop)\n  \n  aEnv = vCAP_Main.GetExtension(analysisenvironment)\n
  '--- remember the initial analysis environment settings\n  oldrect=Rect.MakeXY(0,0,1,1)\n  oldcellsize=gcellsize\n  oldae_enum=aEnv.getextent(oldrect)\n  oldae_enum=aEnv.getcellsize(oldcellsize)  \n  \n  aEnv.SetExtent(#ANALYSISENV_value,theRect)\n  \n  aEnv.SetCellSize(#analysisenv_value,gcellsize)\n  aEnv.Activate \n      \n  '----------------------------------------\n  '--- End of analysis extent specification\n  '----------------------------------------\nend     'if subdata_exists   \n          \n'-------------------
---------------------------------------\n' Clip Selected Grid and Vector Themes or Load from Previously \n' Saved Data  \n'----------------------------------------------------------\n\n'-------------------------------------------------------\n' Grid Data\n'-------------------------------------------------------\nif (subdata_exists=false) then\n  ' Add clipped data to the subbasin View\n  gridcount=0\n  for each aGridTheme in gridThemes       '---Clip all grid themes\n    gName=gNames.Get(gridcount)  \n    aGrid=aGridThe
me.GetGrid\n    if ((gName=\"dem\") or (gName=\"for_type\")) then\n       cutGrid=aGrid.ExtractByPolygon(theClipShape,prj.MakeNull,False)\n    else\n       cutGrid=aGrid.ExtractByRect(theRect,prj.MakeNull,false)\n    end\n    cutFN=FileName.Merge(newdir.asstring,gName)\n    cutGrid.SaveDataSet(cutFN)\n    outGTheme=GTheme.Make(cutGrid) \n    outGTheme.SetName(cutFN.getBaseName)\n    vSub_basin.AddTheme(outGTheme)\n    outGTheme.SetLegendVisible(false)   '---Hide legend\n    subtagdict.set(subgTags.get(gridcount),outGTheme)
\n    gridcount=gridcount+1\n  end \nelse\n  \n  for each gridTag in gridThemeTags\n      'msgbox.info(newdir.asstring,\"\")\n      gName=gridNameDict.Get(gridTag)\n      gSrcfname=filename.merge(newdir.asstring,gName)\n      gSrcfstr=gSrcfname.AsString\n      'msgbox.info(gSrcfstr,\"\")\n      gSrcname=Grid.MakeSrcName(gSrcfstr)\n      if (gSrcname=nil) then\n         continue\n         'chk=msgbox.yesno(\"Could not find\"++gSrcfstr++\"Continue?\",\"CAP load prism input data\",true)\n         'if (chk) then\n         '  continue\n  
       'else \n         '  exit\n         'end\n      else\n        'msgbox.info(gSrcname.asstring,\"\")\n        agTheme = Theme.Make(gSrcname)\n        vSub_basin.AddTheme( agTheme )  \n        agTheme.SetLegendVisible(False)\n        subtagStr=\"Subbasin\"++gridTag\n        subtagdict.Set(subtagStr,agTheme)\n      end 'if grid is found\n   end   'loop through gridNames\n    \nend   'if subbasin data already exists\n\n'-------------------------------------------------------\n' Vector Data\n'-----------------------------------
--------------------\nif (subdata_exists=false) then\n    vcount=0          \n    for each vTheme in vectthemes  \n      'Specify the output shapefile \n      vName=vNames.Get(vcount)\n      outFName = FileName.Merge(newdir.asstring,vName)\n      'outputftab=av.run(\"cap.clippoly_sub\",{vTheme,theClipShape,outFName})\n      outputftab=av.run(\"cap.extracthavecenterin\",{vTheme.GetFtab,myftab,outFName})\n      clippedTheme = FTheme.Make( outputFTab )\n      clippedTheme.SetName(outputFTab.getName)\n      vSub_basin.AddThem
e(clippedTheme )\n      'subtagdict.set(subgTags.get(gridcount),outGTheme)\n      subtagdict.set(subvTags.get(vcount),clippedTheme)   'Changed by ZYZ\n      vcount=vcount + 1  \n    end\nelse\n   for each vectTag in vectThemeTags\n       vName=vNameDict.Get(vectTag)\n       sourcefname=filename.merge(newdir.asstring,vName)\n       sourcefstr=sourcefname.asstring\n       insourcename=srcname.make(sourcefstr)\n       if (insourcename=nil) then\n        \n         continue\n         'chk=msgbox.yesno(\"Could not find \"++sour
cefstr++\" Continue?\",\"Cap loadinputdata\",true)\n         'if (chk) then\n         '  continue\n         'else \n         ' exit\n         'end\n       end\n       vtheme=theme.make(insourcename)\n       vSub_basin.addtheme(vtheme)\n       subtagStr=\"Subbasin\"++vectTag\n       subtagdict.Set(subtagStr,vTheme)\n   end   'loop through gridNames\n   \nend \n\n'Add the basin boundary theme last so it will be displayed at the top   \nvSub_basin.AddTheme(aClipTheme)\n\n'-------------------------------------------------------\n' Set 
Legends\n'-------------------------------------------------------\n   '---Selected Sub_basin\n      basin_theme=aCliptheme  \n      newlegend=basin_theme.GetLegend\n      theSymbols=newlegend.GetSymbols\n      theSymbols.get(0).getcolor.SetTransparent(true)\n      theSymbols.Get(0).SetOlcolor(color.getblack)\n      theSymbols.Get(0).SetOlwidth(2)\n      basin_theme.updatelegend\n      basin_theme.setvisible(true)  \n      \n   '---Streams inside\n      '--- set river line to blue\n      stream_theme=subtagdict.get(\"Subba
sin RF1 Streams\") \n      if (stream_theme<>nil) then\n        newlegend=legend.make( #symbol_pen )\n        newlegend.getsymbols.get(0).setcolor(color.getblue)\n        if (stream_theme<>nil) then\n          stream_theme.setlegend(newlegend)\n          stream_theme.updatelegend\n        end\n        stream_theme.setvisible(true)\n      end\n      \n'---Set the precipitation to a standard legend\n  legend_dir = tagdict.get(\"Legend Directory\")\n  ppt_theme = subTagDict.get(\"Subbasin Mean Annual Ppt\")\n  if (ppt_theme<>nil
) then\n    plegend = ppt_theme.GetLegend\n    plegend.Load(filename.merge(legend_dir,\"ppt_legend.avl\"),#LEGEND_LOADTYPE_SYMBOLS)\n    ppt_theme.SetLegend(plegend)\n    ppt_theme.UpdateLegend\n    ppt_theme.SetVisible(False)\n  end      \n\n'--- Set the forest cover-type labels correctly\n   forTheme = subTagdict.Get(\"Subbasin Detailed Forest Type\")\n   if (forTheme<>nil) then\n      av.run(\"cap.for_typelegend\",{forTheme})\n   end   \n   \n'++++++++++++++++++++++++++++++++++++  \n'++++ Set the temp to a standard legend\n'+
+++++++++++++++++++++++++++++++++++\n\n'--- Set color map for DEM theme\n  dem_theme = subTagDict.get(\"Subbasin Elevation\")\n  if (dem_theme<>nil) then\n    demLegend = dem_theme.GetLegend\n    demLegend.Load(filename.merge(legend_dir,\"dem_legend2.avl\"),#LEGEND_LOADTYPE_SYMBOLS)  \n    dem_theme.SetLegend(demLegend)\n    dem_theme.UpdateLegend\n    dem_theme.SetVisible(False)  \n  end\n\n'-------------------------------------------------------\n' After all themes for the selected sub-basin are ready\n' then define the vi
ew properties and open the view\n'-------------------------------------------------------\n  \n'---Set the View units to Meters---\n    vUnits_Enum=vCAP_main.GetUnits\n    vSub_basin.SetUnits(vUnits_Enum)\n  \n'---Set the distance units to meters---\n    dmain_enum=vCAP_main.GetDisplay.GetDistanceUnits\n    d = vSub_basin.GetDisplay\n    d.SetDistanceUnits(dmain_enum)\n\n'---Set the new view name as selected basin ID/name---\n    'vSub_basin.SetName(\"SelectedBasinView: \"++sel_basin)\n    vSub_basin.SetName(\"SelectedBasin
View:\"++selbsn_idstr)\n    \n'---Open the new view ---\n    aWindow = vSub_basin.GetWin\n    aWindow.Open\n\nif (subdata_exists=false) then\n  'Reset the analysis extent before exiting\n  aEnv.setcellsize(oldae_enum,oldcellsize)\n  aEnv.setextent(oldae_enum,oldrect)\n  aEnv.Activate\nend\n     \n'Zoom all themes to full extent\nr = vSub_basin.ReturnExtent\nif (r.IsEmpty) then\n  return nil\nelseif ( r.ReturnSize = (0@0) ) then\n  vSub_basin.GetDisplay.PanTo(r.ReturnOrigin)\nelse\n  vSub_basin.GetDisplay.SetExtent(r.Scale(1.1))
\n  av.GetProject.SetModified(true)\nend\n   \n\n\n"
)

(Script.363
	Name:	"cap.dlg.cancel"
	SourceCode:	"Self.GetDialog.Close"
)

(Script.364
	Name:	"cap.dlg_stats.cbx_winter.select"
	SourceCode:	"'---------------------------------------------\n' Name: cap.dlg_stats.cbx_winter.select\n' Description:  Update summer combo boxes any \n' time a winter combo box is selected. \n'---------------------------------------------\n\n'cbx_summer_from=self.GetDialog.FindByName(\"cbx_summer_from\")\n'cbx_summer_to=self.GetDialog.FindByName(\"cbx_summer_to\")\nmonList = {\"January\",\"Feburary\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\"}\n\ncbx_winter_from=self.GetDialog.FindbyName(\"cbx_
winter_from\")\ncbx_winter_to=self.GetDialog.FindbyName(\"cbx_winter_to\")\ntxl_summer_from=self.GetDialog.FindbyName(\"txl_summer_from\")\ntxl_summer_to=self.GetDialog.FindByName(\"txl_summer_to\")\n\nwfrom = cbx_winter_from.GetCurrentRow\nwto = cbx_winter_to.GetCurrentRow\n\n'msgbox.info(wfrom.asstring++wto.asstring,\"\")\n\nsfrom = wto + 1\nif (sfrom > 11) then\n   sfrom = 0\nend\n\nsto = wfrom - 1\nif (sto < 0) then\n   sto = 11\nend \n\nif (sfrom = wfrom) then\n   txl_summer_from.SetText(\"\")\n   txl_summer_to.SetText(\"\")\nelse\n   txl
_summer_from.SetText(monList.Get(sfrom))\n   txl_summer_to.SetText(monList.Get(sto))\nend\n\n'cbx_summer_from.GoRow(sfrom)\n'cbx_summer_to.GoRow(sto)\n'cbx_summer_from.SelectCurrent\n'cbx_summer_to.SelectCurrent\n   \n\n\n\n"
)

(Script.365
	Name:	"cap.dlg_stats.chk_all.click"
	SourceCode:	"'-----------------------------------------------------\n'\n'Name: cap.dlg_stats.chk_all.click\n'\n'Description: Select all stats\n'\n'\n'\n'------------------------------------------------------\n\nif (self.isselected) then  'disable all custom check boxes\n  aCtlSet=self.GetControlSet.GetControls\n  for each ctl in aCtlSet\n     if ((ctl.Is(CheckBox)) and (ctl.GetName<>\"chk_zonal\") and (ctl.Getname<>\"chk_all\") and (ctl.getname<>\"chk_seasonal\")) then\n        ctl.SetEnabled(false)\n     end\n  end\nelse  'enable all custom 
check boxes\n  aCtlSet=self.GetControlSet.GetControls\n  for each ctl in aCtlSet\n     if ((ctl.Is(CheckBox)) and (ctl.GetName<>\"chk_zonal\") and (ctl.Getname<>\"chk_all\") and (ctl.getname<>\"chk_seasonal\")) then\n        ctl.SetEnabled(true)\n     end\n  end   \nend"
)

(Script.366
	Name:	"cap.dlg_stats.chk_seasonal"
	SourceCode:	"'------------------------------------------------------\n'\n'Name: cap.dlg_stats.chk.seasonal\n'\n'Description: To enable the seasonal/month selection when this \n'             button is clicked\n'\n'Modified: 8/18/2000 Ziya\n'------------------------------------------------------\n'thedlg=av.finddialog(\"dlg_stats\")\n\nchk_seasonal=self.Getdialog.findbyname(\"chk_seasonal\")\n\nif (chk_seasonal.isselected) then\n   self.GetDialog.FindByName(\"cbx_winter_from\").SetEnabled(True)\n   self.GetDialog.FindByName(\"cbx_winter_to\").S
etEnabled(True)\nelse\n   self.GetDialog.FindByName(\"cbx_winter_from\").SetEnabled(false)\n   self.GetDialog.FindByName(\"cbx_winter_to\").SetEnabled(false) \nend   \n\nself.BroadCastUpdate"
)

(Script.367
	Name:	"cap.dlg_stats.lbt_cancel.click"
	SourceCode:	"'#----------------------------------------------\n' Name: cap.dlg_stats.lbt_cancel.click\n'\n'Description: \n'     To close the dlg_stats dialog window when the\n'     Cancel button is pressed\n'\n' History: Last modified 4/28/2000 By Ziya \n\nSelf.GetDialog.Close"
)

(Script.368
	Name:	"cap.dlg_stats.lbt_ok2.click"
	SourceCode:	"'#-------------------------------------------------------\n'  Name: cap.dlg_stats.lbt_ok2.click\n'\n'  Description: Calculation statistics for selected grid\n'\n'  Modified:  8/15/2000 by Ziya\n'  08/29/2000  2/06/01 by SMR\n'#-------------------------------------------------------       \n\n'chkfile=linefile.make(\"/none/gis/cap/out/chkfile.txt\".asfilename,#file_perm_write)\n\nunitType=\"metric\"\n\nif (unitType=\"metric\") then\n   pptunit=\"(mm)\"\n   peunit=\"(mm)\"\n   elvunit=\"(m)\"\nelse\n   pptunit=\"(in)\"\n   peunit=\"(in)\"\n   e
lvunit=\"(ft)\"\nend\n\nthedlg=av.finddialog(\"dlg_stats\")\n\nif (thedlg.FindByName(\"chk_all\").IsSelected) then\n\n  chk_ppt=true\n  chk_tmp=true\n  chk_pe=true\n  chk_seasonal=true\n  chk_elv=true\n  chk_forest=true\n  chk_detforest=true\n  chk_sacsma=true\n\nelse\n\n  chk_ppt=theDlg.FindByName(\"chk_ppt\").IsSelected\n  chk_tmp=theDlg.FindByName(\"chk_tmp\").IsSelected\n  chk_pe=theDlg.FindByName(\"chk_pe\").IsSelected\n  chk_seasonal=theDlg.FindByName(\"chk_seasonal\").IsSelected\n  chk_elv=theDlg.FindByName(\"chk_elev\").IsSelected\n  chk
_forest=theDlg.FindByName(\"chk_forest\").IsSelected\n  chk_detforest=theDlg.FindByName(\"chk_detforest\").IsSelected\n  chk_sacsma=theDlg.FindByName(\"chk_sacsma\").IsSelected\n  \nend\n' -----Gets Sub-basin's View\nvSub_basin = av.GetActiveDoc\nsubtagdict = vSub_basin.GetObjectTag\nif (subtagdict = nil) then \n   msgbox.warning(\"Error:  Failed to get dictionary tags for sub-basin\", \"Sub-basin Tags\")\n   return nil\nend\n\nmainView=subtagdict.Get(\"Parent View\")\ntagdict=mainView.GetObjectTag\nif (tagdict.GetClass.GetClassName<
>\"Dictionary\") then\n   return nil\nend\n\nindirString=tagdict.Get(\"Input Directory\")\nif (indirString=nil) then\n  msgbox.info(\"No Input Directory Specified. Please re-run setup.\",script.the.getname)\n  return nil\nend\n\noutdirString=tagdict.Get(\"Output Directory\")\nif (outdirString=nil) then\n  msgbox.info(\"No Output Directory Specified. Please re-run setup.\",script.the.getname)\n  return nil\nend\n\n  \nbsn_idstr = subtagdict.Get(\"Subbasin ID Name\").AsString\nsubbsn_datadir=outdirString.AsFileName\nsubbsn_datadir.MergePat
h(bsn_idstr)\nstatname=Filename.Merge(subbsn_datadir.asstring,\"stats.dbf\") \n'statname = subbsn_datadir.MakeTmp((bsn_idstr+\"s\"),\"dbf\")\n'------Because of the name restriction, only \"s\" is added after the basin ID\n\ncomputezones=false\nif (thedlg.FindbyName(\"chk_zonal\").isselected) then\n  computezones=true\n  zTheme = subtagdict.Get(\"Subbasin Zone Grid\")\n  if (zTheme=nil) then\n     computezones=false\n     msgbox.info(\"No zones defined for zonal calculations.\",script.the.getname)\n     return nil\n  else   \n     zGri
d = zTheme.GetGrid\n     if(zGrid.Is(grid).not) then \n        msgbox.info(\"Zone Grid Error\",\"\") \n        return nil\n        thedlg.close \n     end\n     zVTab = zGrid.GetVTab\n     num_zone = zVTab.GetNumRecords   'Get number of zones\n  end      \n\nend  \n     \nif (computezones) then\n  'arect=zTheme.ReturnExtent\n  gcellsize=zGrid.GetCellSize\n  Grid.SetAnalysisCellSize(#GRID_ENVTYPE_VALUE,gcellsize)\nend\n'------------------------------------------ \n'---Create STATISTICS table\n'-------------------------------------
-----\nfieldList = List.Make\nfieldList.Add(Field.Make(\"Data Name\", #FIELD_CHAR, 18, 0))\nfieldList.Add(Field.Make(\"Basin Mean\", #FIELD_FLOAT, 10, 2))    \nfieldList.Add(Field.Make(\"Basin Min\", #FIELD_FLOAT, 10, 2))\nfieldList.Add(Field.Make(\"Basin Max\", #FIELD_FLOAT, 10, 2))\n\nif (computezones) then\n    for each zone in 1..num_zone\n       fieldList.Add(Field.Make(\" \",#FIELD_VCHAR,1,0))\n       fieldList.Add(Field.Make(\"Zone\"+zone.AsString++\"Mean\", #FIELD_FLOAT, 10, 2))\n       fieldList.Add(Field.Make(\"Zone\"+zone.
AsString++\"Min\", #FIELD_FLOAT, 10, 2))\n       fieldList.Add(Field.Make(\"Zone\"+zone.AsString++\"Max\", #FIELD_FLOAT, 10, 2))\n    end  \nend           \n'msgbox.info(statname.asstring,script.the.getname)\nstatVTab = VTab.MakeNew(statname,dbase)\nif (statVTab.HasError) then \n    msgbox.info(\"Vtab has an error\",\"Vtab error\") \n    return nil\n    thedlg.close \nend\nstatVtab.SetEditable(true)\n  \nstatVTab.AddFields(fieldList)\n     \n\n'-----Define month name list for easy read \nmonList = {\"jan\",\"feb\",\"mar\",\"apr\",\"may\",\"jun\"
,\"jul\",\"aug\",\"sep\",\"oct\",\"nov\",\"dec\"}\nmonListLong = {\"January\",\"Feburary\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\"} \n\n'---Determine seasonal start/end info\n' wlist stores a list of indices indicating winter months\n' slist stores a list of indeces indicating summer months\n'--- \ncompute_seasonal=false\nif (chk_seasonal) then\n   wlist=List.Make\n   slist=List.Make\n   compute_seasonal=true\n   wfrom = theDlg.FindByName(\"cbx_winter_from\").GetCurrentRow\n   wto = theDlg
.FindByName(\"cbx_winter_to\").GetCurrentRow\n   \n   sfromstring = theDlg.FindByName(\"txl_summer_from\").GetText\n   stostring = theDlg.FindByName(\"txl_summer_to\").GetText\n   \n   'if winter is selected as the entire season, the sfrom and sto strings will be zero length\n   if ((sfromstring.count=0) or (stostring.count=0)) then\n      compute_seasonal=false\n   else\n      sfrom = monListLong.FindByValue(sfromstring)\n      sto = monListLong.FindByValue(stostring)\n      'chkfile.writeelt(wfrom.asstring++wto.asstring++
sfrom.asstring++sto.asstring)\n   end\n   \n   if (compute_seasonal) then\n      wlist.Add(wfrom)\n      slist.Add(sfrom)\n      while (wfrom<>wto)\n          wfrom=wfrom + 1\n          if (wfrom>11) then\n             wfrom=0\n          end\n          wlist.add(wfrom)\n      end\n      while (sfrom<>sto)\n          sfrom=sfrom + 1\n          if (sfrom>11) then\n             sfrom=0\n          end\n          slist.add(sfrom)\n      end     \n   end\n   'initialize winter and summer totals\n   wppt=0\n   wpe=0\n   sppt=0\n   spe=0\ne
nd\n   \n\n'----------------------------------------------\n' Elevation and percent forest\n'----------------------------------------------\nstatDir=Filename.Merge(outdirString,\"stats\")\n'msgbox.info(statDir.asstring,\"\")\nif (statDir.isdir.not) then\n   msgbox.info(\"Precomputed stats directory not found.\",script.the.getname)\n   return nil\nend\n\n'----Elevation\nif (chk_elv) then\n   ' add a new record to the output Stats table\n   newrec=statVtab.AddRecord\n   'read values from the elv.dbf\n    inVtab=Vtab.Make(Filename.Me
rge(statdir.asstring,\"elv.dbf\"),false,false)\n    qString1=(\"[idstring] = \"+bsn_idstr.quote)\n    qString2=(\"[idstring] = \"+bsn_idstr.ucase.quote)\n    'msgbox.report(qstring1+nl+qstring2,\"\")\n    inVtab.query(qString1,invtab.getselection,#vtab_seltype_new)\n    if (invtab.getnumselrecords=0) then\n       inVtab.query(qString2,invtab.getselection,#vtab_seltype_new)\n    end\n    if (invtab.getnumselrecords=0) then\n       msgbox.error(\"Statistics not found for\"++bsn_idstr,script.the.getname)\n       return nil\n    en
d \n    selrec=inVtab.Getselection.getnextset(-1)\n    elvmean=inVtab.ReturnValue(inVtab.FindField(\"elv\"),selrec)\n    elvmin=inVtab.ReturnValue(inVtab.FindField(\"elvmin\"),selrec)\n    elvmax=inVtab.ReturnValue(inVtab.FindField(\"elvmax\"),selrec)\n    statVTab.SetValue(fieldList.Get(0),newrec,\"Elevation\"++elvunit)\n    statVTab.SetValue(fieldList.Get(1),newrec,elvMean)\n    statVTab.SetValue(fieldList.Get(2),newrec,elvMin)\n    statVTab.SetValue(fieldList.Get(3),newrec,elvMax)\n\n   if (computezones) then\n      'msgbo
x.info(computezones.asstring,\"\")\n      dataTheme = subtagdict.Get(\"Subbasin Elevation\")  \n      dataGrid = dataTheme.GetGrid    \n      av.run(\"cap.gridavg_z\",{zGrid,dataGrid,statVtab,statDir,fieldlist,newrec})\n   end \n      \nend     \n   \n\n'--- Forest Percent Cover analysis  \nif (chk_forest) then\n    ' add a new record to the output Stats table\n    newrec=statVtab.AddRecord\n   'read values from the elv.dbf\n    inVtab=Vtab.Make(Filename.Merge(statdir.asstring,\"elv.dbf\"),false,false)\n    qString1=(\"[idstring] 
= \"+bsn_idstr.quote)\n    qString2=(\"[idstring] = \"+bsn_idstr.ucase.quote)\n    'msgbox.report(qstring1+nl+qstring2,\"\")\n    inVtab.query(qString1,invtab.getselection,#vtab_seltype_new)\n    if (invtab.getnumselrecords=0) then\n       inVtab.query(qString2,invtab.getselection,#vtab_seltype_new)\n    end\n    if (invtab.getnumselrecords=0) then\n       msgbox.error(\"Statistics not found for\"++bsn_idstr,script.the.getname)\n       return nil\n    end \n    selrec=inVtab.Getselection.getnextset(-1)\n    fpctmean=inVtab.Re
turnValue(inVtab.FindField(\"fpct\"),selrec)\n    fpctmin=inVtab.ReturnValue(inVtab.FindField(\"fpctmin\"),selrec)\n    fpctmax=inVtab.ReturnValue(inVtab.FindField(\"fpctmax\"),selrec)\n    statVTab.SetValue(fieldList.Get(0),newrec,\"Forest Percent\"++elvunit)\n    statVTab.SetValue(fieldList.Get(1),newrec,fpctMean)\n    statVTab.SetValue(fieldList.Get(2),newrec,fpctMin)\n    statVTab.SetValue(fieldList.Get(3),newrec,fpctMax)\n\n   if (computezones) then\n      dataTheme = subtagdict.Get(\"Subbasin Forest Percent Cover\")  \n 
     dataGrid = dataTheme.GetGrid    \n      av.run(\"cap.gridavg_z\",{zGrid,dataGrid,statVtab,statDir,fieldlist,newrec})\n   end   \nend\n\n'----------------------------------------------\n' PRECIP\n'----------------------------------------------\n\n\n'----annual precipitation\nif (chk_ppt) then\n\n  ' add a new record to the output Stats table\n    newrec=statVtab.AddRecord\n   'read values from the elv.dbf\n    inVtab=Vtab.Make(Filename.Merge(statdir.asstring,\"ppt.dbf\"),false,false)\n    qString1=(\"[idstring] = \"+bsn_idstr
.quote)\n    qString2=(\"[idstring] = \"+bsn_idstr.ucase.quote)\n    'msgbox.report(qstring1+nl+qstring2,\"\")\n    inVtab.query(qString1,invtab.getselection,#vtab_seltype_new)\n    if (invtab.getnumselrecords=0) then\n       inVtab.query(qString2,invtab.getselection,#vtab_seltype_new)\n    end\n    if (invtab.getnumselrecords=0) then\n       msgbox.error(\"Statistics not found for\"++bsn_idstr,script.the.getname)\n       return nil\n    end \n    selrec=inVtab.Getselection.getnextset(-1)\n    \n    valmean=inVtab.ReturnValue
(inVtab.FindField(\"pptann\"),selrec)\n    valmin=inVtab.ReturnValue(inVtab.FindField(\"pptannmin\"),selrec)\n    valmax=inVtab.ReturnValue(inVtab.FindField(\"pptannmax\"),selrec)\n    statVTab.SetValue(fieldList.Get(0),newrec,\"Annual Precip\"++pptunit)\n    statVTab.SetValue(fieldList.Get(1),newrec,valMean)\n    statVTab.SetValue(fieldList.Get(2),newrec,valMin)\n    statVTab.SetValue(fieldList.Get(3),newrec,valMax)\n    if (computezones) then\n      prismdirString=tagdict.Get(\"Prism Data Directory\")\n      if (prismdirStr
ing=nil) then\n        msgbox.info(\"No PRISM Directory Specified. Please re-run setup.\",script.the.getname)\n        return nil\n      end\n      annSrcName = Grid.MakeSrcName(Filename.Merge(prismdirString,\"pptann\").AsString)\n      annSrcGrid = Grid.Make(annSrcName)\n      if (annSrcGrid.HasError.not) then    \n          av.run(\"cap.gridavg_z\",{zGrid,annSrcGrid,statVtab,statDir,fieldlist,newrec})\n      end\n    end\n    moncount=0\n    for each mon in monList\n       newrec=statVtab.AddRecord\n       valmean=inVtab.Re
turnValue(inVtab.FindField(\"ppt\"+mon),selrec)\n       valmin=inVtab.ReturnValue(inVtab.FindField(\"ppt\"+mon+\"min\"),selrec)\n       valmax=inVtab.ReturnValue(inVtab.FindField(\"ppt\"+mon+\"max\"),selrec)\n       if (chk_seasonal) then\n          if (wlist.findbyvalue(moncount) <> (-1)) then\n             wppt=wppt+valmean\n          end\n          if (slist.findbyvalue(moncount) <> (-1)) then\n             sppt=sppt+valmean\n          end\n       end\n\n       statVTab.SetValue(fieldList.Get(0),newrec,\"   Precip-->\"++mon)\n  
     statVTab.SetValue(fieldList.Get(1),newrec,valMean)\n       statVTab.SetValue(fieldList.Get(2),newrec,valMin)\n       statVTab.SetValue(fieldList.Get(3),newrec,valMax)\n       \n       if (computezones) then\n          monSrcName = Grid.MakeSrcName(Filename.Merge(prismdirString,(\"ppt\"+mon)).AsString)\n          monSrcGrid = Grid.Make(monSrcName) \n          if (monSrcGrid.HasError.not) then\n             av.run(\"cap.gridavg_z\",{zGrid,monSrcGrid,statVtab,statDir,fieldlist,newrec})\n          end\n       end\n      
 moncount=moncount+1\n    end\n    if (chk_seasonal) then  'write seasonal results to output table\n       newrec=statVtab.AddRecord\n       statVTab.SetValue(fieldList.Get(0),newrec,\"Winter PPT\")\n       statVTab.SetValue(fieldList.Get(1),newrec,wppt)\n       newrec=statVtab.AddRecord\n       statVTab.SetValue(fieldList.Get(0),newrec,\"Summer PPT\")\n       statVTab.SetValue(fieldList.Get(1),newrec,sppt)\n    end\n\n  \nend\n\n'----------------------------------------------\n' Potential Evaporation PE and PEADJ\n'----------
------------------------------------\n\n\nif (chk_pe) then\n   ' add a new record to the output Stats table\n    newrec=statVtab.AddRecord\n    inVtab=Vtab.Make(Filename.Merge(statdir.asstring,\"pe.dbf\"),false,false)\n    qString1=(\"[idstring] = \"+bsn_idstr.quote)\n    qString2=(\"[idstring] = \"+bsn_idstr.ucase.quote)\n    'msgbox.report(qstring1+nl+qstring2,\"\")\n    inVtab.query(qString1,invtab.getselection,#vtab_seltype_new)\n    if (invtab.getnumselrecords=0) then\n       inVtab.query(qString2,invtab.getselection,#vta
b_seltype_new)\n    end\n    if (invtab.getnumselrecords=0) then\n       msgbox.error(\"Statistics not found for\"++bsn_idstr,script.the.getname)\n       return nil\n    end \n    selrec=inVtab.Getselection.getnextset(-1)\n    \n    '--- PE\n    valmean=inVtab.ReturnValue(inVtab.FindField(\"peann\"),selrec)\n    valmin=inVtab.ReturnValue(inVtab.FindField(\"peannmin\"),selrec)\n    valmax=inVtab.ReturnValue(inVtab.FindField(\"peannmax\"),selrec)\n    statVTab.SetValue(fieldList.Get(0),newrec,\"Annual PE\"++pptunit)\n    statVTab.S
etValue(fieldList.Get(1),newrec,valMean)\n    statVTab.SetValue(fieldList.Get(2),newrec,valMin)\n    statVTab.SetValue(fieldList.Get(3),newrec,valMax)\n    if (computezones) then\n      pedirString=Filename.Merge(indirString,\"pe\")\n      annSrcName = Grid.MakeSrcName(Filename.Merge(pedirString.asstring,\"peann\").AsString)\n      annSrcGrid = Grid.Make(annSrcName)\n      if (annSrcGrid.HasError.not) then    \n          av.run(\"cap.gridavg_z\",{zGrid,annSrcGrid,statVtab,statDir,fieldlist,newrec})\n      end\n    end\n    
moncount=0    \n    for each mon in monList\n       newrec=statVtab.AddRecord\n       valmean=inVtab.ReturnValue(inVtab.FindField(\"pe\"+mon),selrec)\n       valmin=inVtab.ReturnValue(inVtab.FindField(\"pe\"+mon+\"min\"),selrec)\n       valmax=inVtab.ReturnValue(inVtab.FindField(\"pe\"+mon+\"max\"),selrec)\n       statVTab.SetValue(fieldList.Get(0),newrec,\"   PE-->\"++mon)\n       statVTab.SetValue(fieldList.Get(1),newrec,valMean)\n       statVTab.SetValue(fieldList.Get(2),newrec,valMin)\n       statVTab.SetValue(fieldList.Get
(3),newrec,valMax)\n       if (chk_seasonal) then\n          if (wlist.findbyvalue(moncount) <> (-1) ) then\n             wpe=wpe+valmean\n          end\n          if (slist.findbyvalue(moncount) <> (-1) ) then\n             spe=spe+valmean\n          end\n       end\n       \n       if (computezones) then\n          pedirString=Filename.Merge(indirString,\"pe\")\n          monSrcName = Grid.MakeSrcName(Filename.Merge(pedirString.Asstring,(\"pe\"+mon)).AsString)\n          monSrcGrid = Grid.Make(monSrcName) \n          if (m
onSrcGrid.HasError.not) then\n             av.run(\"cap.gridavg_z\",{zGrid,monSrcGrid,statVtab,statDir,fieldlist,newrec})\n          end\n       end\n       moncount=moncount+1\n    end\n    if (chk_seasonal) then  'write seasonal results to output table\n       newrec=statVtab.AddRecord\n       statVTab.SetValue(fieldList.Get(0),newrec,\"Winter PE\")\n       statVTab.SetValue(fieldList.Get(1),newrec,wpe)\n       newrec=statVtab.AddRecord\n       statVTab.SetValue(fieldList.Get(0),newrec,\"Summer PE\")\n       statVTab.SetVa
lue(fieldList.Get(1),newrec,spe)\n    end\n\n    '--- PEADJ\n    for each mon in monList\n      newrec=statVtab.AddRecord\n      valmean=inVtab.ReturnValue(inVtab.FindField(\"adj\"+mon),selrec)\n      valmin=inVtab.ReturnValue(inVtab.FindField(\"adj\"+mon+\"min\"),selrec)\n      valmax=inVtab.ReturnValue(inVtab.FindField(\"adj\"+mon+\"max\"),selrec)\n      statVTab.SetValue(fieldList.Get(0),newrec,\"   PE ADJ-->\"++mon)\n      statVTab.SetValue(fieldList.Get(1),newrec,valMean)\n      statVTab.SetValue(fieldList.Get(2),newrec,valM
in)\n      statVTab.SetValue(fieldList.Get(3),newrec,valMax) \n      if (computezones) then\n        pedirString=Filename.Merge(indirString,\"pe\")\n        monSrcName = Grid.MakeSrcName(Filename.Merge(pedirString.AsString,(\"adj\"+mon)).AsString)\n        monSrcGrid = Grid.Make(monSrcName) \n        if (monSrcGrid.HasError.not) then\n           av.run(\"cap.gridavg_z\",{zGrid,monSrcGrid,statVtab,statDir,fieldlist,newrec})\n        end\n      end\n    end\n\nend\n\n'*** Detailed Forest Type analysis\n'--- A separate forest type
 grid and corresponding vtab must be\n'--- created for each zone  \nif (chk_detforest) then\n   '------------------------------------------ \n   '---Create Detailed Forest table\n   '------------------------------------------\n   fortypename=Filename.Merge(subbsn_datadir.asstring,\"fortype.dbf\")\n\n   forfieldList = List.Make\n   \n   forfieldList.Add(Field.Make(\"Value\", #FIELD_BYTE, 4, 0))\n   forfieldList.Add(Field.Make(\"Name\", #FIELD_CHAR, 26, 0))\n   forfieldList.Add(Field.Make(\"Basin Pct\", #FIELD_FLOAT, 5, 1))    \n
   if (computezones) then\n     for each zone in 1..num_zone\n       forfieldList.Add(Field.Make(\" \",#FIELD_VCHAR,1,0))\n       forfieldList.Add(Field.Make(\"Zone\"+zone.AsString++\"Pct\", #FIELD_FLOAT, 5, 1))\n     end  \n   end    \n          \n    fortypeVTab = VTab.MakeNew(fortypename,dbase)\n    if (fortypeVTab.HasError) then \n        msgbox.info(\"Error creating forest type table\",\"Forest Type Error\") \n        return nil\n        thedlg.close \n    end\n    fortypeVtab.SetEditable(true)\n    detmsg=\"Percent of Foreste
d Area Covered by Each Forest Type:\"++bsn_idstr\n      \n    fortypeVTab.AddFields(forfieldList)\n\n    typeTheme = subtagdict.Get(\"Subbasin Detailed Forest Type\")\n    typeGrid = typeTheme.GetGrid\n    'Establish a dictionary of codes and names\n    typeVtab=typeGrid.GetVtab\n    nameField=typeVtab.FindField(\"Name\")\n    idField=typeVtab.FindField(\"Value\")\n    countField=typeVtab.FindField(\"Count\")\n    'create a dictionary in which the key will be a number\n    'and the value will be the name\n    nDict=Dictionary.Ma
ke(typeVtab.GetNumRecords)\n    for each rec in typeVtab\n       nDict.Add(typeVtab.ReturnValue(idField,rec),typeVtab.ReturnValue(nameField,rec))\n    end\n    \n    pctTheme = subtagdict.Get(\"Subbasin Forest Percent Cover\")  \n    pctGrid = pctTheme.GetGrid    \n    \n    '------COMPUTE PERCENTAGES FOR EACH FOREST TYPE\n    '--- typeGrid defines the Zones\n    '--- pctGrid defines the Values\n    if (idField=nil) then \n      msgbox.info(\"error in zone grid\",script.the.getname)\n      return nil\n    end\n    tempFname=F
ileName.Merge(statDir.AsString,\"atempstat.dbf\")\n    tempVtab=pctGrid.zonalstatstable(typegrid,prj.makenull,idField,false,tempFname)\n    fromField=tempVtab.FindField(\"Value\")\n    '--- join tempVtab to typeVtab\n    if (typeVtab.isbase=false) then\n      typeVtab.unjoinall\n    end\n    typeVtab.join(idField,tempVtab,fromfield)\n    \n    'calculate the total percent of each forest type\n    meanfield=typeVtab.FindField(\"Mean\")\n    \n    countTotal=0\n    for each rec in typeVtab\n       countTotal=countTotal+typeVtab.
ReturnValue(countField,rec)\n    end\n    pctTotal=0\n    for each rec in typeVtab\n        meanval=typeVtab.ReturnValue(meanField,rec)\n        acount=typeVtab.ReturnValue(countField,rec)\n        pctTotal=pctTotal+(acount/countTotal*meanval)\n    end\n    'what percent of the forest percent is represented by each forest type\n    for each rec in typeVtab\n        apct=acount/pctTotal\n        id=typeVtab.ReturnValue(idField,rec)\n        meanval=typeVtab.ReturnValue(meanField,rec)\n        acount=typeVtab.ReturnValue(
countField,rec)\n        outval=(acount/countTotal*meanval)/pctTotal*100\n        newrec=fortypeVtab.AddRecord\n        fortypeVtab.SetValue(forfieldlist.get(0),newrec,id)\n        fortypeVtab.SetValue(forfieldlist.get(1),newrec,nDict.get(id))\n        fortypeVtab.SetValue(forfieldlist.get(2),newrec,outval)\n    end\n        \n    typeVtab.unjoinall \n    \n    forTypeTable=Table.Make(fortypeVtab) \n    fortypeTable.SetName(detmsg)\n    \n    '-------------------\n    ' zonal calculations\n    \n    if (computezones) then\n
\n       maskList=List.Make\n       num_zone = zVTab.GetNumRecords   'Get number of zones\n       for each zone in 1..num_zone\n          zmask = (zGrid <> zone).SetNull(1.AsGrid)\n          maskList.Add(zmask)\n       end\n        zones=maskList.Count\n        if (zones > 1) then\n           for each zone in 1..zones  \n              z1Grid = typeGrid * maskList.Get(zone-1)\n              z1Vtab=z1Grid.GetVtab \n              idField=z1Vtab.FindField(\"Value\")\n              if (idField=nil) then \n                msgbox
.info(\"error in zone grid\",script.the.getname)\n                return nil\n              end\n              tempFname=FileName.Merge(statDir.AsString,\"atempstat.dbf\")\n              tempVtab=pctGrid.zonalstatstable(typegrid,prj.makenull,idField,false,tempFname)\n              fromField=tempVtab.FindField(\"Value\")\n              '--- join tempVtab to typeVtab\n              if (z1Vtab.isbase=false) then\n                 z1Vtab.unjoinall\n              end\n              z1Vtab.join(idField,tempVtab,fromfield)\n      
        'calculate the total percent of each forest type\n              meanfield=z1Vtab.FindField(\"Mean\")\n              countField=z1Vtab.FindField(\"Count\")\n              countTotal=0\n              for each rec in z1Vtab\n                 countTotal=countTotal+z1Vtab.ReturnValue(countField,rec)\n              end\n              pctTotal=0\n              for each rec in z1Vtab\n                  meanval=z1Vtab.ReturnValue(meanField,rec)\n                  acount=z1Vtab.ReturnValue(countField,rec)\n                 
 pctTotal=pctTotal+(acount/countTotal*meanval)\n              end\n              'what percent of the forest percent is represented by each forest type\n              z1Dict=Dictionary.Make(z1Vtab.GetNumRecords)\n              for each rec in z1Vtab\n                  apct=acount/pctTotal\n                  id=z1Vtab.ReturnValue(idField,rec)\n                  meanval=z1Vtab.ReturnValue(meanField,rec)\n                  acount=z1Vtab.ReturnValue(countField,rec)\n                  outval=(acount/countTotal*meanval)/p
ctTotal*100\n                  z1Dict.Set(id,outval)\n              end\n              for each rec in fortypeVtab\n                 idField=fortypeVtab.Findfield(\"Value\")\n                 outval=z1Dict.Get(fortypeVtab.ReturnValue(idField,rec))\n                 if (outval<>nil) then\n                    fortypeVtab.SetValue(forfieldlist.get((2*(zone+1))),rec,outval)\n                 end\n              end\n              z1Vtab.unjoinall \n               \n           end  'for each zone\n        end   'if more than on
e zone  \n        \n    end   'if computezones    \n    forTypeVtab.SetEditable(false)\n           \n    \nend  'if detailed forest type\n\n'----------------------------------------------\n' SAC-SMA Parameters\n'----------------------------------------------\n\nif (chk_sacsma) then\n\n    parList = {\"lzfpm\",\"lzfsm\",\"lzpk\",\"lzsk\",\"lztwm\",\"pfree\",\"rexp\",\"uzfwm\",\"uzk\",\"uztwm\",\"zperc\"}\n\n    inVtab=Vtab.Make(Filename.Merge(statdir.asstring,\"sacsma.dbf\"),false,false)\n    qString1=(\"[idstring] = \"+bsn_idstr.quote)\n    qString2=
(\"[idstring] = \"+bsn_idstr.ucase.quote)\n    'msgbox.report(qstring1+nl+qstring2,\"\")\n    inVtab.query(qString1,invtab.getselection,#vtab_seltype_new)\n    if (invtab.getnumselrecords=0) then\n       inVtab.query(qString2,invtab.getselection,#vtab_seltype_new)\n    end\n    if (invtab.getnumselrecords=0) then\n       msgbox.error(\"Statistics not found for\"++bsn_idstr,script.the.getname)\n       return nil\n    end \n    selrec=inVtab.Getselection.getnextset(-1)\n    \n    for each par in parList\n      newrec=statVtab.A
ddRecord\n      valmean=inVtab.ReturnValue(inVtab.FindField(par),selrec)\n      valmin=inVtab.ReturnValue(inVtab.FindField(par+\"min\"),selrec)\n      valmax=inVtab.ReturnValue(inVtab.FindField(par+\"max\"),selrec)\n      statVTab.SetValue(fieldList.Get(0),newrec,par)\n      statVTab.SetValue(fieldList.Get(1),newrec,valMean)\n      statVTab.SetValue(fieldList.Get(2),newrec,valMin)\n      statVTab.SetValue(fieldList.Get(3),newrec,valMax)\n      if (computezones) then\n        sacdirString=Filename.Merge(indirString,\"sacs
ma\")\n        parSrcName = Grid.MakeSrcName(Filename.Merge(sacdirString.Asstring,(par)).AsString)\n        parSrcGrid = Grid.Make(parSrcName) \n        if (parSrcGrid.HasError.not) then\n           av.run(\"cap.gridavg_z\",{zGrid,parSrcGrid,statVtab,statDir,fieldlist,newrec})\n        end\n      end  '---end if compute zones\n      'return nil\n    end   '--- loop throught parameters\nend\n'----Show the statistics table in the main project/table window\nstatTable = Table.Make(statVTab)\n'Rename the table name\noutname=\"St
atistics:\"++bsn_idstr.Ucase\noutTable=av.FindDoc(outname)\n'if a stats table already exists, rename to reflect current time\nif (outTable<>nil) then\n  outname=outname++Date.Now.Asstring\nend\nstatTable.SetName(outname)    \n\nmsg=\"Statistics calculations are complete.\"+nl+\"Results are in the Table:\"+outname\n'if (chk_detforest) then\n'   msg=msg+nl+\"Detailed Forest Tables:\"+nl+detmsg\n'end \n\nmsgbox.report(msg,script.the.getname)\n\nstatTable.GetWin.Activate\n\nstatVtab.SetEditable(false)\nthedlg.close"
)

(Script.369
	Name:	"cap.dlg_stats.open"
	SourceCode:	"'-----------------------------------------------------\n'\n'Name: cap.dlg_stats.open\n'\n'Sedcription: Provide list of month for user to select\n'\n'Modified by: 8/18/2000 ZYZ\n'\n'------------------------------------------------------\n  chk_ppt = self.FindByName(\"chk_ppt\")\n  chk_tmp = self.FindByName(\"chk_tmp\")\n  chk_pe = self.FindByName(\"chk_pe\")\n  chk_elev = self.FindByName(\"chk_elev\")\n  chk_forest = self.FindByName(\"chk_forest\")\n  chk_detforest = self.FindByName(\"chk_detforest\")\n  chk_seasonal = self.FindByName
(\"chk_seasonal\")\n\n'---initialize the month selection combox for seasonal \n\n  monList = {\"January\",\"Feburary\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\"}\n  cbx_wfrom = self.FindByName(\"cbx_winter_from\")\n  cbx_wto   = self.FindByName(\"cbx_winter_to\")\n  \n  'cbx_sfrom = self.FindByName(\"cbx_summer_from\")\n  'cbx_sto   = self.FindByName(\"cbx_summer_to\")\n  txl_sfrom = self.FindByName(\"txl_summer_from\")\n  txl_sto   = self.FindByName(\"txl_summer_to\")\n  txl_sfrom.settext(
\"\")\n  txl_sto.settext(\"\")\n  cbx_wfrom.DefineFromList(monList)\n  cbx_wto.DefineFromList(monList)\n  'cbx_sfrom.DefineFromList(monList)\n  'cbx_sto.DefineFromList(monList)\n     \n  chk_seasonal.SetListeners({cbx_wfrom,cbx_wto})  \n  \n  '----DeSelect all check buttons\n   'chk_seap.SetSelected(false)\n'   chk_seat.SetSelected(false)\n'   chk_seape.SetSelected(false)\n'   chk_annp.SetSelected(false)\n'   chk_annt.SetSelected(false)\n'   chk_annpe.SetSelected(false)\n'   chk_monp.SetSelected(false)\n'   chk_mont.SetSelected
(false)\n'   chk_monpe.SetSelected(false)\n'   chk_ele.SetSelected(false)\n'   chk_f.SetSelected(false)\n'   chk_detf.SetSelected(false)\n   \n    \n'---Disable the selection until the seasoanl check button is selected\n  \n  if (chk_seasonal.isselected) then\n     self.FindByName(\"cbx_winter_from\").SetEnabled(True)\n     self.FindByName(\"cbx_winter_to\").SetEnabled(True)\n  else\n     self.FindByName(\"cbx_winter_from\").SetEnabled(false)\n     self.FindByName(\"cbx_winter_to\").SetEnabled(false) \n  end   \n\n  'cbx_sfrom.SetE
nabled(false)\n  'cbx_sto.SetEnabled(false)  \n\n"
)

(Script.370
	Name:	"cap.dlg_subbsn.cbx_numbreaks.update"
	SourceCode:	"curval=self.GetCurrentRow\nself.SelectCurrent\nself.broadcastupdate"
)

(Script.371
	Name:	"cap.dlg_subbsn.lbt_clear.click"
	SourceCode:	"'#--------------------------------------------------------------------\n' Name:  cap.dlg_subbsn.lbt_clear.click\n' Function:   clear elevation break text lines   \n' History:     created by D. Wang\n'#--------------------------------------------------------------------\n\ntxln1 = self.getdialog.findbyname(\"txtln1\")\ntxln2 = self.getdialog.findbyname(\"txtln2\")\ntxln3 = self.getdialog.findbyname(\"txtln3\")\ntxln4 = self.getdialog.findbyname(\"txtln4\")\n\ntxln1.settext(\"\")\ntxln2.settext(\"\")\ntxln3.settext(\"\")\ntxln4.settext(
\"\")\n"
)

(Script.372
	Name:	"cap.dlg_subbsn.lbt_close.click"
	SourceCode:	"av.finddialog(\"dlg_subbsn\").close\n"
)

(Script.373
	Name:	"cap.dlg_subbsn.lbt_eqint.click"
	SourceCode:	"'#--------------------------------------------------------------------\n' Name:  cap.dlg_subbsn.lbt_eqint.click\n' Function:     Define equal interval elevation breaks.\n' History:      Created by D. Wang\n'               Last Modified 8/25/2000 by SMR    \n'#--------------------------------------------------------------------\n\nthedialog=self.Getdialog\ncbx_numbreaks=thedialog.findbyname(\"cbx_numbreaks\")\nnumbreaks=cbx_numbreaks.GetSelection\nif (numbreaks=nil) then\n  msgbox.error(\"At least one break must be select
ed.\",script.the.getname)\nend\nnumints=numbreaks+1\n\ntheView = av.GetActiveDoc\nsubtagdict = theView.GetObjectTag\n'theTheme = subtagdict.Get(\"Subbasin Elevation\")\ntheTheme = av.run(\"cap.checktagdict\",{theView,\"Subbasin Elevation\",subtagdict,true})\nif (theTheme=nil) then\n  return nil\nend \n\n\ntheGrid = theTheme.GetGrid\ntheMin = thegrid.getstatistics.get(0)\ntheMax = thegrid.getstatistics.get(1)\n\nintval = ((theMax - theMin)/numints)\n\nln1 = self.getdialog.findbyname(\"txtln1\")\nln2 = self.getdialog.findbyname(\"txtln2\")
\nln3 = self.getdialog.findbyname(\"txtln3\")\nln4 = self.getdialog.findbyname(\"txtln4\")\n\nlnlist={ln1,ln2,ln3,ln4}\n\n'--- Specify equal interval break points ---------\ntopval=theMin\nfor each b in 0..(numbreaks-1)\n  topval=topval+intval\n  lnlist.get(b).SetText(topval.setformat(\"d.d\").AsString)\nend\n\n'-------------------------------------------------\n\n"
)

(Script.374
	Name:	"cap.dlg_subbsn.lbt_ok.click"
	SourceCode:	"'#--------------------------------------------------------------------\n'\n' Name:  cap.dlg_subbsn.lbt_ok.click\n' Function:     1.  Accept range for reclassification\n'               2.  Commit reclassification\n' History:      Created by D. Wang under guidance of Seann.\n'               Last modified 9/26/02 by Seann\n'\n'#--------------------------------------------------------------------\n\ntheView = av.GetActiveDoc\n'theTheme = theView.GetActiveThemes.Get(0)\nsubtagdict = theView.GetObjectTag\n\ntheTheme = av.run(\"
cap.checktagdict\",{theview,\"Subbasin Elevation\",subtagdict,true})\nif (theTheme=nil) then\n  return nil\nend \n\nbasin_name = subtagdict.Get(\"Subbasin ID Name\")\n\nworkdir=av.GetProject.GetWorkDir\noutdir=Filename.Merge(workdir.AsString,basin_name) \n\nthedialog=self.getdialog\ncbx_numbreaks=thedialog.findbyname(\"cbx_numbreaks\")\nnumbreaks=cbx_numbreaks.getselection\nnumints=numbreaks+1\n\nlnmin = thedialog.findbyname(\"txl_min\")\nln1 = thedialog.findbyname(\"txtln1\")\nln2 = thedialog.findbyname(\"txtln2\")\nln3 = thedialog.find
byname(\"txtln3\")\nln4 = thedialog.findbyname(\"txtln4\")\nlnmax = thedialog.findbyname(\"txl_max\")\n\nminval=lnmin.gettext.asnumber\nmaxval=lnmax.gettext.asnumber\n\nintvalues=List.Make\nif (numbreaks=1) then\n   val1=ln1.gettext\n   if (val1.IsNumber) then\n      if ((val1.asnumber<maxval) and (val1.asnumber>minval)) then\n         intvalues={minval,val1.asnumber,maxval}\n      else\n         msgbox.info(\"Invalid entry for first break.\",script.the.getname)\n      end\n   else\n     msgbox.info(\"Invalid entry for first break.\"
,script.the.getname)\n   end\nelseif (numbreaks=2) then\n   val1=ln1.gettext\n   val2=ln2.gettext\n   if ((val1.IsNumber) and (val2.isnumber)) then\n      val1=val1.asnumber\n      val2=val2.asnumber\n      if ((val2<maxval) and (val2>val1) and (val1>minval)) then\n         intvalues={minval,val1,val2,maxval}\n      else\n         msgbox.info(\"Invalid entry in one of the break fields.\",script.the.getname)\n      end\n   else\n     msgbox.info(\"Invalid entry in one of the break fields.\",script.the.getname)\n   end\nelseif (
numbreaks=3) then\n   val1=ln1.gettext\n   val2=ln2.gettext\n   val3=ln3.gettext\n   if ((val1.IsNumber) and (val2.isnumber) and (val3.isnumber)) then\n      val1=val1.asnumber\n      val2=val2.asnumber\n      val3=val3.asnumber\n      if ((val3<maxval) and (val3>val2) and (val2>val1) and (val1>minval)) then\n         intvalues={minval,val1,val2,val3,maxval}\n      else\n         msgbox.info(\"Invalid entry in one of the break fields.\",script.the.getname)\n      end\n   else\n     msgbox.info(\"Invalid entry in one of the 
break fields.\",script.the.getname)\n   end\nelseif (numbreaks=4) then\n   val1=ln1.gettext\n   val2=ln2.gettext\n   val3=ln3.gettext\n   val4=ln4.gettext\n   if ((val1.IsNumber) and (val2.isnumber) and (val3.isnumber) and (val4.isnumber)) then\n      val1=val1.asnumber\n      val2=val2.asnumber\n      val3=val3.asnumber\n      val4=val4.asnumber\n      if ((val4<maxval) and (val4>val3) and (val3>val2) and (val2>val1) and (val1>minval)) then\n         intvalues={minval,val1,val2,val3,val4,maxval}\n      else\n         msgb
ox.info(\"Invalid entry in one of the break fields.\",script.the.getname)\n      end\n   else\n     msgbox.info(\"Invalid entry in one of the break fields.\",script.the.getname)\n   end\nelse\n\nend\n\naClassifList=List.Make\nnewLabelList=List.Make\nfor each int in 0..(numints-1)\n   aClassif=Classification.Make(intvalues.Get(int),intvalues.Get(int+1))\n   aClassif.SetLabel((int+1).AsString)\n   newLabelList.Add(\"Z\"++(int+1).AsString+\":\"++intvalues.Get(int).Asstring++\"-\"++intvalues.Get(int+1).Asstring)\n   aClassifList.Add(aC
lassif)\nend \n\ntheGrid = theTheme.GetGrid\nif (theGrid.haserror) then\n  msgbox.info(\"Grid has error.\",\"\")\n  return nil\n  exit\nend \n\ntheVtab = thegrid.getvtab\n\n'add theme to the view\ntheResultGrid = theGrid.ReclassByClassList(\"Value\",aClassifList,true)\n\n'---- GRID RESULT\n'***** Rename the resulting grid\nresFN=outdir.MakeTmp(\"zones\",\"\")\n'msgbox.info(resFN.AsString,\"\")\ntheResultGrid.SaveDataSet(resFN)\ntheResultTheme = GTheme.Make(theResultGrid)\ntheView.AddTheme(theResultTheme)\n\n'**** Set the zone theme object ta
g\nsubtagDict.Set(\"Subbasin Zone Grid\",theResultTheme)\n\n'set a new legend\nmaxlabelLength = 0\ntheLegend = theResultTheme.GetLegend \ntheClassList = theLegend.GetClassifications\n cnt = 0 \n for each c in theClassList\n     if (cnt<numints) then   \n       c.Setlabel(newLabelList.Get(cnt))\n       labelLength = newLabelList.Get(cnt).Count\n       if (labelLength > maxlabelLength) then\n          maxLabelLength = labelLength\n       end\n     end  \n     cnt = cnt + 1 \n end \ntheResultTheme.UpdateLegend\n\n'--- POLYGON RESUL
T ------------------------\n' create a polygon coverage of the zones\nz0fname=outdir.Maketmp(\"tmpzones\",\"shp\")\nzftab0 = theResultGrid.aspolygonftab(z0fname,false,prj.makenull)\n\n' DISSOLVE dangling polygons\nmergefield=zftab0.findfield(\"gridcode\")\nshpfield=zftab0.findfield(\"shape\")\nzfname=outdir.maketmp(\"zonesp\",\"shp\")\nzftab=zftab0.summarize(zfname,Shape,mergefield,{shpfield},{#vtab_summary_sum})\nzFtheme=ftheme.make(zftab)    \ntheview.addtheme(zFtheme)\nav.run(\"util.calculatefeaturegeometrysub\",{theview,zftab})\n
'remove the shapefiles zftab0 that are no longer needed\nz0fnamestr=z0fname.asstring\ndbffname=(z0fnamestr.left(z0fnamestr.count-3)+\"dbf\").asfilename\nshxfname=(z0fnamestr.left(z0fnamestr.count-3)+\"shx\").asfilename\nFile.Delete(z0fname)\nFile.Delete(dbffname)\nFile.Delete(shxfname)\n\n'--- Add a field with the zone labels\nnewField=Field.Make(\"Zoneinfo\",#field_char,(maxLabelLength + 1),0)\nif (zftab.CanEdit) then\n  zftab.SetEditable(true)\n  zftab.Addfields({newField})\nend\nif (zftab.GetNumRecords = newLabelList.Count)
 then\n   for each rec in zftab\n      zftab.setvalue(zftab.findfield(\"Zoneinfo\"),rec,newLabelList.Get(rec))\n   end\nend\nzftab.SetEditable(false)\nsubtagDict.Set(\"Subbasin Zone Polygons\",zFtheme)\n\n'--- Specify the legend for the polygon result\nnewlegend1=Legend.Make( #symbol_fill )\nnewlegend1.getsymbols.get(0).getcolor.settransparent(true)\nnewlegend1.getsymbols.get(0).setOlWidth(2)\nzFtheme.setlegend(newlegend1)\nzFtheme.updatelegend\n\n'--- end of polygon result ------------------\n\n\nself.getdialog.close\n"
)

(Script.375
	Name:	"cap.dlg_subbsn.lbt_range.click"
	SourceCode:	"'#--------------------------------------------------------------------\n' Name:  cap.dlg_bassub.lbt_range.click\n' Function:     Assign range for the fields\n' History:      D. Wang \n'#--------------------------------------------------------------------\n\n\ntheView = av.GetActiveDoc\nsubtagdict = theView.GetObjectTag\n'demTheme = subtagdict.Get(\"Subbasin Elevation\")\ndemTheme = av.run(\"cap.checktagdict\",{theView,\"Subbasin Elevation\",subtagdict,true})\nif (demTheme=nil) then\n  return nil\nend \n\n'++++++++++++++++++++++
+\n' if demGrid = nil, then make a list of Grids to choose from\n'+++++++++++++++++++++++\n\ndemGrid = demTheme.GetGrid\n\ntheMin = demgrid.getstatistics.get(0)\ntheMax = demgrid.getstatistics.get(1)\n\ntxtMin = self.getdialog.findbyname(\"txl_min\")\ntxtMax = self.getdialog.findbyname(\"txl_max\")\n\ntxtMin.setText(theMin.asString)\ntxtMax.setText(theMax.AsString)\n"
)

(Script.376
	Name:	"cap.dlg_subbsn.txtln2.update"
	SourceCode:	"thedialog=self.getdialog\ncbx_numbreaks=thedialog.findbyname(\"cbx_numbreaks\")\nnumbreaks=cbx_numbreaks.getselection\nif (numbreaks<2) then\n  self.setvisible(false)\nelse\n  self.setvisible(true)\nend"
)

(Script.377
	Name:	"cap.dlg_subbsn.txtln3.update"
	SourceCode:	"thedialog=self.getdialog\ncbx_numbreaks=thedialog.findbyname(\"cbx_numbreaks\")\nnumbreaks=cbx_numbreaks.getselection\nif (numbreaks<3) then\n  self.setvisible(false)\nelse\n  self.setvisible(true)\nend"
)

(Script.378
	Name:	"cap.dlg_subbsn.txtln4.update"
	SourceCode:	"thedialog=self.getdialog\ncbx_numbreaks=thedialog.findbyname(\"cbx_numbreaks\")\nnumbreaks=cbx_numbreaks.getselection\nif (numbreaks<4) then\n  self.setvisible(false)\nelse\n  self.setvisible(true)\nend"
)

(Script.379
	Name:	"cap.dlg_xygraph.open"
	SourceCode:	"'#-----------------------------------------\n' Name:  cap.dlg_xygraph.open\n' \n' Description: Initializes the dlg_xygraph dialog\n' \n' Dependencies: \n' History: Last modified 3/14/2000 by SMR\n'#-----------------------------------------\n\ntheview=av.GetActiveDoc\nsubtagdict=theview.GetObjectTag\nzoneGTheme=subtagdict.Get(\"Subbasin Zone Grid\")\n\nif (zoneGTheme<>nil) then\n   zoneVtab=zoneGtheme.GetVtab\n   valField=zoneVtab.FindField(\"Value\")\nend\nzoneChoices=List.Make\nzoneChoices.Add(\"Entire Basin\")\nif (zoneGTheme<>ni
l) then\n  for each rec in zoneVtab\n     val=zoneVtab.ReturnValue(valField,rec)\n     zoneChoices.Add(\"Zone\"++val.AsString)\n  end\nend\n\n'--- Set the title for the dialog\nsubName=subtagdict.get(\"Subbasin ID Name\")\nself.SetTitle(\"Create XYGraph for\"++subName)\n\ncbx_subdiv=self.FindByName(\"cbx_subdiv\")\ncbx_subdiv.definefromlist(zoneChoices)\ncbx_subdiv.update\n\nrad_ae=self.findbyname(\"rad_ae\")\nrad_pcp=self.findbyname(\"rad_pcp\")\n\nlbt_plot=self.findbyname(\"lbt_plot\")\n\nlbt_plot.setenabled(false)\n\nrad_ae.setlisteners({l
bt_plot})\nrad_pcp.setlisteners({lbt_plot})\n\nrad_ae.broadcastupdate\nrad_pcp.broadcastupdate\n\n\n"
)

(Script.380
	Name:	"cap.dlg_xygraph.plot"
	SourceCode:	"'#--------------------------------------------------------------------\n' Name:  cap.dlg_xygraph.plot\n'\n' Description:    \n' (1) Plot the Area-Elevation curve, Area-Temperature curve, or\n' the Area-Precipitation curve\n'#---------------------------------------------------------------------\n\n'chkfile=linefile.make(\"/none/cap/out/chkfile.txt\".asfilename,#file_perm_write)\n'chkfile2=linefile.make(\"/none/cap/out/chkfile2.txt\".asfilename,#file_perm_write)\n\n'----------------------------------------------------------
----\n'--- Get control information \n'--------------------------------------------------------------\ntheView=av.GetActiveDoc\nsubtagDict=theView.GetObjectTag\nbasin_name=subtagDict.Get(\"Subbasin ID Name\")\n\nworkDir=av.getproject.getworkdir\noutdir=Filename.Merge(workdir.AsString,basin_name) \n\nif (self.GetDialog.FindByName(\"rad_ae\").isselected) then\n   graphtype=\"ae\"\n   graphname=\"Area vs. Elevation\"\n   xAxisLabel=\"Elevation (m)\"\n   yAxisLabel=\"% Area Less Than\"\nelseif (self.GetDialog.findbyname(\"rad_pcp\").isselec
ted) then\n   graphtype=\"ppt\"\n   graphname=\"PRISM PPT vs. Elevation\"\n   yAxisLabel=\"Precipitation (mm)\"\n   xAxisLabel=\"Elevation (m)\"\nelse\n   'graphtype=\"tmp\"\n   'do nothing\n   graphname=\"PRISM TMP vs. Elevation\"\n   yAxisLabel=\"Temperature(Deg. C)\"\n   xAxisLabel=\"Elevation (m)\"\nend\n\ncbx_subdiv=self.GetDialog.FindByName(\"cbx_subdiv\")\nseltype=cbx_subdiv.getselection\n'demGTheme=subtagDict.Get(\"Subbasin Elevation\")\ndemGTheme = av.run(\"cap.checktagdict\",{theView,\"Subbasin Elevation\",subtagdict,true})\nif (demGThem
e=nil) then\n  return nil\nend \n\n'if (demGtheme=nil) then\n'  msgbox.error(\"Subbasin DEM not found.\",script.the.getname)\n'  self.getdialog.close\n'  return nil\n'end\nif (seltype<>\"Entire Basin\") then\n    zonenum=seltype.AsTokens(\" \").Get(1).Asnumber\n    seltype=\"Zones\"\nend\n\n\n'---------------------------------------------\n'--- If plot is to be made for a selected Zone\n'---------------------------------------------\nif (seltype=\"Zones\") then  \n  'zTheme = subtagdict.Get(\"Subbasin Zone Grid\") \n  zTheme = av.run(\"cap
.checktagdict\",{theView,\"Subbasin Zone Grid\",subtagdict,true})\n   if (zTheme=nil) then\n      return nil\n   end   \n  zGrid = zTheme.GetGrid\n  if(zGrid.Is(grid).not) then \n     msgbox.info(\"Zone Grid Error\",script.the.getname) \n     return nil \n  end\n  'create a temporary mask for cells in the selected zone \n  zmask = (zGrid <> zonenum).SetNull(1.AsGrid)\nend\n\ndemGrid0=demGtheme.GetGrid\nif (demGrid0.HasError) then\n   msgbox.error(\"DEM grid has error.\",script.the.getname)\nend\n\n'--- Added 5/16/2001 ------------\n
gcellsize=demGrid0.GetCellSize\nGrid.SetAnalysisCellSize(#GRID_ENVTYPE_VALUE,gcellsize)\n'--------------------------------\n\nif (seltype=\"Zones\") then\n   demGrid = demGrid0 * zmask\nelse\n   demGrid = demGrid0\nend \n\ndemVtab=demGrid.GetVtab\nif (demVtab=nil) then\n  chkbuild=demGrid.buildVat\n  if (chkbuild=false) then\n     msgbox.error(\"Could not build VAT for DEM\",script.the.getname)\n     self.getdialog.close\n     return nil\n  end\nend\n\nvalGrid=nil\nif (graphtype=\"ppt\") then\n   valGTheme=subtagDict.Get(\"Subbasin Mea
n Annual Ppt\")\n   valGTheme = av.run(\"cap.checktagdict\",{theView,\"Subbasin Mean Annual Ppt\",subtagdict,true})\n   if (valGTheme=nil) then\n      return nil\n   end \n   valGrid=valGTheme.GetGrid\nend\n\n'--------------------------------------------------------------\n'--- Determine point values to plot\n'--------------------------------------------------------------\n\ntxl_numpts=self.GetDialog.FindByName(\"txl_numpts\")\nnumpts_str=txl_numpts.GetText\nif (numpts_str.count=0) then\n  msgbox.error(\"Must enter number of poin
ts.\",script.the.getname)\n  return nil\nend\nif (numpts_str.isnumber.not) then\n  msgbox.error(\"# of Points Not A Number.\",script.the.getname)\n  return nil\nend\nnumpts=numpts_str.AsNumber\n'if (graphtype=\"ae\") then\n'   'plot fewer points when calculations are only for single zone\n'   if (seltype=\"Zones\") then\n'      numpts=12\n'   else\n'      numpts=12\n'   end\n'else\n'   if (seltype=\"Zones\") then\n'      'was 4\n'      numpts=12\n'   else\n'      'was 6\n'      numpts=12\n'   end\n'end\n\nxyList=av.run(\"cap.xygraph.pointsto
plot\",{outdir.AsString,graphtype,demGrid,valGrid,numpts})\nif (xyList=nil) then\n  self.getdialog.close\n  return nil\nend\n\n\n'xyList is a list of lists with x and y coordinate values; this list includes all but the \n'first and last points\n\nxmax=demGrid.GetStatistics.Get(1)\nxmin=demGrid.GetStatistics.Get(0) \nif (graphtype=\"ae\") then\n   ymax=100\n   ymin=0  \nelse\n   ymax=valGrid.GetStatistics.Get(1)\n   ymin=valGrid.GetStatistics.Get(0)\n'determine max and min y values in the list\n'ymax=0\n'   ymin=99999\n'   xmax=0\n'
   xmin=99999\n'   for each l in xyList\n'      yval=l.Get(1)\n'      if (yval>ymax) then\n'         ymax=yval\n'      end\n'      if (yval<ymin) then\n'         ymin=yval\n'      end\n'      xval=l.get(0)\n'      if (xval>xmax) then\n'         xmax=xval\n'      end\n'      if (xval<xmin) then\n'         xmin=xval\n'      end\n'   end\n\n   if ((ymax-ymin)<50.8) then\n      msgbox.info(\"Ann precip max - ann precip min < 2 inches.  No precip elv plot can be made.\",script.the.getname)\n      return nil\n   end\n   \n\nend\n'msgbox.in
fo(ymin.asstring++ymax.asstring,\"\")\n'return nil\n'--------------------------------------------------------------\n'--- Set up Graph View Axes, Tics, Labels, Scale Factors\n'--------------------------------------------------------------\nif (seltype=\"Entire Basin\") then\n   viewName=graphname++\"for\"++basin_name\nelse\n   viewName=graphname++\"for Zone\"++zonenum.AsString++\"of\"++basin_name\nend\n\n'--- Remove old document with the same name if one already exists\noldView=av.GetProject.FindDoc(viewName)\nif (oldView<>nil) t
hen\n   av.GetProject.RemoveDoc(oldView)\nend\n'\n'Create a new instance of CAPGraph DocGUI\n'\nnewView=av.run(\"cap.xygraph.docGUI\",nil)\n\nnewView.SetName(viewName)\nnewView.getwin.activate\n\n'------------------------------\n'Initialize graphics parameters\n'------------------------------\nlabelFontSize=10\nticFontSize=6\ndataFontSize=10\naxisFontSize=12\ntitleFontSize=14\n\ntheGraphicList = newView.GetGraphics\ntheGraphicList.SelectAll\ntheGraphicList.CutSelected\n\naTextSymbol = Symbol.Make(#symbol_text)\naTextSymbol.SetFont(Fo
nt.Make(\"Times\",\"Normal\"))\naTextSymbol.SetColor(Color.GetBlack)\naTextsymbol.setsize(labelFontSize)\n\nticSymbol=Symbol.Make(#symbol_marker)\nticFont=Font.Make(\"ESRI Cartography\",\"Normal\")\n\nticSymbol.SetFont(ticFont)\nticSymbol.SetCharacter(1)\nticSymbol.SetColor(Color.Getblack)\nticSymbol.SetSize(ticFontSize)\n\ntxtset=List.Make\n'--------------------------------------------------------\n'--- Creat xtics \n'--------------------------------------------------------\n\n'msgbox.info(xmax.asstring++xmin.asstring++ymax.asstri
ng++ymin.asstring,\"\")\n'return nil\n\n' xmax = maximum x value in the data\n' Divide the range into 10 equal intervals\nxtic_inc=(xmax-xmin)/10\n \n' Determine a round number for the tic increments\nif (xtic_inc<0) then\n   msgbox.error(\"xmax < xmin\",script.the.getname)\n   self.getdialog.close\n   return nil \nend\nif (xtic_inc<1) then\n  xtencount=1\n  while (xtic_inc<1)\n     xtic_inc=xtic_inc*10\n     xtencount=xtencount*10\n  end\n  xtic_inc=(xtic_inc.truncate)/xtencount\n  \n  if (xtic_inc>xmin) then\n     ticxStart=0\n  el
se  'start at the tic just below the minimum\n     ticxStart=((xmin*xtencount).truncate)/xtencount\n  end   \nelse  'if xtic_inc > 1  \n  'strip off all but one sig digit from xtic_inc\n  xtencount=1\n  if (xtic_inc>10) then\n    while (xtic_inc>10)\n       xtic_inc=xtic_inc/10\n       xtencount=xtencount*10\n    end\n    xtic_inc=(xtic_inc.truncate)*xtencount\n  else \n     xtic_inc=xtic_inc.round\n  end\n  if (xtic_inc>xmin) then\n     ticxStart=0\n  else  'start at the tic just below the minimum\n     ticxStart=((xmin/xte
ncount).truncate)*xtencount\n  end\nend\n\n'msgbox.info(ticxStart.asstring++xtic_inc.asstring,\"\")\n\n\n'--- label every second tic   \ncurlabel=ticxStart\ncurx=0\nyoffset=10\nnumxtics=0\nwhile (true)\n   tic=Point.Make(curx,0)\n   ticGraphic=GraphicShape.Make(tic)\n   ticGraphic.SetSymbol(ticSymbol)\n   xoffset=curlabel.asstring.count*0.7\n   labPoint=Point.Make((curx-xoffset),(-1*yoffset))\n   agLabel = GraphicLabel.MakeWithSym(curlabel.asstring,labPoint,aTextSymbol,txtSet)     \n   theGraphicList.Add(agLabel)   \n   theGraph
icList.Add(ticGraphic)\n   if ((curlabel>xmax) or (curx>200)) then\n     break\n   end\n   numxtics=numxtics+1\n   curlabel=curlabel+(xtic_inc*2)\n   curx = curx + 20\nend\nnumxtics2=numxtics*2\n\n\n'--------------------------------------------------------\n'--- Create and label ytics \n'--------------------------------------------------------\n' ymax = maximum y value in the data\n'----------------------\nytic_inc=(ymax-ymin)/10\n \n' Determine a round number for the tic increments\nif (ytic_inc<0) then\n   msgbox.error(\"ymax
 < ymin\",script.the.getname)\n   self.getdialog.close\n   return nil\nend\n\nif (ytic_inc<1) then\n  ytencount=1\n  while (ytic_inc<1)\n     ytic_inc=ytic_inc*10\n     ytencount=ytencount*10\n  end\n  ytic_inc=(ytic_inc.truncate)/ytencount\n  \n  if (ytic_inc>xmin) then\n     ticyStart=0\n  else  'start at the tic just below the minimum\n     ticyStart=((ymin*ytencount).truncate)/ytencount\n  end\n   \nelse  'if ytic_inc > 1\n  \n  'strip off all but one sig digit from ytic_inc\n  ytencount=1\n  if (xtic_inc>10) then\n    while (y
tic_inc>10)\n       ytic_inc=ytic_inc/10\n       ytencount=ytencount*10\n    end\n    ytic_inc=(ytic_inc.truncate)*ytencount\n  else\n    ytic_inc=ytic_inc.Round\n  end\n  \n  if (ytic_inc>ymin) then\n     ticyStart=0\n  else  'start at the tic just below the minimum\n     ticyStart=((ymin/ytencount).truncate)*ytencount\n  end\nend\n'msgbox.info(ticyStart.asstring++ytic_inc.asstring,\"\")\n'self.getdialog.close\n'return nil\n\n'chklist=List.Make\n\ncury=0\ncurlabel=ticyStart\nxoffset=10\nnumytics=0\nwhile (true)\n   tic=Point.Make(0,c
ury)\n   ticGraphic=GraphicShape.Make(tic)\n   ticGraphic.SetSymbol(ticSymbol)\n   yoffset=curlabel.asstring.count*0.7\n   labPoint=Point.Make((-1*xoffset),(cury-yoffset))\n   'chklist.Add(curlabel.asstring)\n   'chklist.Add(yoffset.asstring)    \n   agLabel = GraphicLabel.MakeWithSym(curlabel.asstring,labPoint,aTextSymbol,txtSet)\n   agLabel.SetAngle(90)\n   theGraphicList.Add(agLabel)\n   theGraphicList.Add(ticGraphic)\n   if ((curlabel>ymax) or (cury>1000)) then\n     break\n   end\n   curlabel=curlabel+(ytic_inc*2)\n 
  'chkfile\n   numytics=numytics+1\n   cury = cury + 20\nend\nnumytics2=numytics*2\n\n'msgbox.listasstring(chklist,\"\",\"\")\n'return nil\n'msgbox.info(numytics.asstring,\"\")\n'-----------------------------------------------------------\n'--- Plot x-y coordinate pairs from xyList \n'-----------------------------------------------------------\n\ndataSymbol=Symbol.Make(#symbol_marker)\ndataFont=Font.Make(\"ESRI Geometric Symbols\",\"Normal\")\n\ndataSymbol.SetFont(dataFont)\ndataSymbol.SetCharacter(36)\ndataSymbol.SetColor(Color.Getbl
ack)\ndataSymbol.SetSize(dataFontSize)\n\ndataSymbol1=Symbol.Make(#symbol_marker)\ndataFont=Font.Make(\"ESRI Geometric Symbols\",\"Normal\")\n\ndataSymbol1.SetFont(dataFont)\ndataSymbol1.SetCharacter(36)\ndataSymbol1.SetColor(Color.GetGreen)\ndataSymbol1.SetSize(dataFontSize)\n\ndataSymbol2=Symbol.Make(#symbol_marker)\ndataFont=Font.Make(\"ESRI Geometric Symbols\",\"Normal\")\n\ndataSymbol2.SetFont(dataFont)\ndataSymbol2.SetCharacter(36)\ndataSymbol2.SetColor(Color.GetRed)\ndataSymbol2.SetSize(dataFontSize)\n\naPointList=List.Make\n\n'
----- MIN POINT ----\n'max and min values are not included in plot for Area-Precip curves\n'plot the min point\nxminloc=(xmin-ticxStart)*(10/xtic_inc)\nyminloc=(ymin-ticyStart)*(10/ytic_inc)\nmindataPoint=Point.Make(xminloc,yminloc)\ndataGraphic=GraphicShape.Make(mindataPoint)\ndataGraphic.SetSymbol(dataSymbol2.Clone)\ntheGraphicList.Add(dataGraphic)\n\n'----- MAX POINT ----- \nxmaxloc=(xmax-ticxStart)*(10/xtic_inc)\nymaxloc=(ymax-ticyStart)*(10/ytic_inc)\nmaxdataPoint=Point.Make(xmaxloc,ymaxloc)\ndataGraphic=GraphicShap
e.Make(maxdataPoint)\ndataGraphic.SetSymbol(dataSymbol2.Clone)\n'outfile.writeelt(xmax.asstring+\",\"+ymax.asstring)\n'dataGraphic.SetObjectTag({true,xmax,ymax})\ntheGraphicList.Add(dataGraphic)\n\n'---- ALL OTHER POINTS -----\nfor each l in xyList\n   xval=l.Get(0)\n   yval=l.Get(1)\n   xplot=(xval-ticxStart)*(10/xtic_inc)\n   yplot=(yval-ticyStart)*(10/ytic_inc)\n   dataPoint=Point.Make(xplot,yplot)   \n   aPointList.Add(dataPoint)\n   dataGraphic=GraphicShape.Make(dataPoint)\n   dataGraphic.SetSymbol(dataSymbol.clone)\n  
 'if (i<>0) then\n   '   dataGraphic.SetObjectTag({true,xValList.Get(i),curyval})\n   'end\n   theGraphicList.Add(dataGraphic)\nend\n\nif (graphtype=\"ae\") then\n   aPointList.Insert(mindataPoint)\n   xyList.Insert({xmin,ymin})\nend\n\n'MAX Point\nif (graphtype=\"ae\") then \n   aPointList.Add(maxdataPoint)\n   xyList.Add({xmax,ymax})\nend\n\naPolyLine=PolyLine.Make({aPointList})\nlineGraphic=GraphicShape.Make(aPolyLine)\nlineGraphic.GetSymbol.SetSize(1)\nlineGraphic.GetSymbol.SetColor(Color.GetRed)\ntheGraphicList.Add(lineGraphic
)\n\n'------------------------------------------------------------\n'--- add graphics indicating 10th, 50th, and 90th percentiles\n'--- if the area-elevation curve option is selected \n'------------------------------------------------------------\nif (graphtype=\"ae\") then\n  statxList=av.run(\"cap.10_50_90\",{xyList})\n  x10=statxList.Get(0)\n  x50=statxList.Get(1)\n  x90=statxList.Get(2)\n  xplot10=(x10-ticxStart)*(10/xtic_inc)\n  yplot10=(10-ticyStart)*(10/ytic_inc)\n  p10=Point.Make(xplot10,yplot10)\n  dataGraphic=Graph
icShape.Make(p10)\n  dataGraphic.SetSymbol(dataSymbol1.Clone)\n  theGraphicList.Add(dataGraphic)\n  xplot50=(x50-ticxStart)*(10/xtic_inc)\n  yplot50=(50-ticyStart)*(10/ytic_inc)\n  p50=Point.Make(xplot50,yplot50)\n  dataGraphic=GraphicShape.Make(p50)\n  dataGraphic.SetSymbol(dataSymbol1.Clone)\n  theGraphicList.Add(dataGraphic)\n  xplot90=(x90-ticxStart)*(10/xtic_inc)\n  yplot90=(90-ticyStart)*(10/ytic_inc)\n  p90=Point.Make(xplot90,yplot90)\n  dataGraphic=GraphicShape.Make(p90)\n  dataGraphic.SetSymbol(dataSymbol1.Clon
e)\n  theGraphicList.Add(dataGraphic)  \nend\n\n\n'------------------------\n'--- Create X and Y axes\n'------------------------\n\naxisorigin=Point.Make(0,0)\nxend=Point.Make((numxtics2*10),0)\nyend=Point.Make(0,(numytics2*10))\nxline=Line.Make(axisorigin,xend)\nyline=Line.Make(axisorigin,yend)\n\n'create an axis title graphic\n\nlabPoint=Point.Make(((numxtics2*10)/2-10),-20)\naTextsymbol.setsize(axisFontSize)\nxaxisGText=GraphicText.Make(xAxisLabel,labPoint)\nxaxisGText.SetSymbol(aTextSymbol)\n\nlabPoint=Point.Make(-20,((numyt
ics2*10/2)-15))\naTextsymbol.setsize(axisFontSize)\nyaxisGText=GraphicText.Make(yAxisLabel,labPoint)\nyaxisGText.SetSymbol(aTextSymbol)\nyaxisGText.SetAngle(90)\n\nxlineGraphic=GraphicShape.Make(xline)\nylineGraphic=GraphicShape.Make(yline)\nxlineGraphic.GetSymbol.SetSize(2)\nylineGraphic.GetSymbol.SetSize(2)\n\ntheGraphicList.Add(xlineGraphic)\ntheGraphicList.Add(ylineGraphic)\ntheGraphicList.Add(xaxisGText)\ntheGraphicList.Add(yaxisGText)\n\n'Zoom to the extent of all graphics\n\nr = theGraphicList.ReturnExtent\nif (r.IsEmp
ty) then\n  self.getdialog.close\n  return nil\nelseif ( r.ReturnSize = (0@0) ) then\n  newView.GetDisplay.PanTo(r.ReturnOrigin)\nelse\n  newView.GetDisplay.SetExtent(r.Scale(1.3))\n  av.GetProject.SetModified(true)\nend\n\nnewView.setobjecttag({graphtype,ticyStart,ytic_inc,ticxStart,xtic_inc,xyList,basin_name})\nself.getdialog.close"
)

(Script.381
	Name:	"cap.dlg_xygraph.radio"
	SourceCode:	"self.broadcastupdate"
)

(Script.382
	Name:	"cap.dlg_xygraph.update"
	SourceCode:	"\nrad_aesel=self.getdialog.findbyname(\"rad_ae\").isselected\nrad_pcpsel=self.getdialog.findbyname(\"rad_pcp\").isselected\nlbt_plot=self.getdialog.findbyname(\"lbt_plot\")\n\nif ((rad_aesel) or (rad_pcpsel)) then\n   lbt_plot.setenabled(true)\nelse\n   lbt_plot.setenabled(false)\nend\n\n\n\n   \n"
)

(Script.383
	Name:	"cap.extracthavecenterin"
	SourceCode:	"'#---------------------------------------------------------------------\n' Name:  cap.extracthavecenterin\n'\n' Description:  Extract arcs that have their center in the selected basin.\n' \n' History: \n'#----------------------------------------------------------------------\n\nvectFtab=self.get(0)\nclipFtab=self.get(1)\noutFname=self.get(2)\n\nvectFtab.SelectByFtab(clipFtab,#ftab_reltype_hascenterwithin,1,#vtab_seltype_new)\n\noutputFTab = vectFtab.Export(outFname, Shape, vectFtab.GetSelection.Count > 0) \n\nreturn output
Ftab"
)

(Script.384
	Name:	"cap.for_typelegend"
	SourceCode:	"'#--------------------------------------------------------------------\n' Name:  cap.for_typelegend\n'\n' History: Created 9/8/2000 by SMR \n'#---------------------------------------------------------------------\n\ntheTheme=self.get(0)\nthegrid=thetheme.getgrid\nthevtab=thegrid.getvtab\n\nvalfield=thevtab.findfield(\"value\")\ndesfield=thevtab.findfield(\"Name\")\n\ndesDict=Dictionary.Make(26)\nfor each rec in thevtab\n   val=thevtab.returnvalue(valfield,rec)\n   des=thevtab.returnvalue(desfield,rec)\n   desDict.Add(val.asstri
ng,des)\nend\n   \nfor each c in thetheme.getLegend.GetClassifications\n   aLabel=c.GetLabel\n   newLabel=desDict.Get(aLabel)\n   if (newLabel<>nil) then\n      c.SetLabel(newLabel)\n   end   \nend\n   \ntheTheme.UpdateLegend"
)

(Script.385
	Name:	"cap.graphnew"
	SourceCode:	"msgbox.info(\"CAPGraphs can only be created using the\" + \nnl+ \"'CAP --> Plot Graph' Menu item.\",script.the.getname)"
)

(Script.386
	Name:	"cap.gridavg"
	SourceCode:	"'#---------------------------------------------------\n'----------------------------------------------------\n' Name: cap.gridavg\n'\n' Description:  Given a grid of zones, a grid of values,\n' and a base table, compute the average, min, and max values for each zone \n' and populate the base table with these average values given \n' a common id. \n\n' Script intended to be general enough to average climatic\n' data as well as SAC-SMA aPriori parameters.  \n'\n' History: Created by Seann Reed 2/8/98;\n'          modified
 12/14/1999\n'          modified 12/14/2000\n'----------------------------------------------------\n'#---------------------------------------------------\n'determine inputs\nzoneGrid=self.get(0)\nvalGrid=self.get(1)\nbasvtab=self.Get(2)\nbasidField=self.get(3)\nidstring=self.Get(4)\nnewdir=self.get(5)\n\n'msgbox.info(valgrid.getname++zonegrid.getname++newdir,\"\")\n'---Adding Fields to Polygon Attribute Table---\nzoneField=zonegrid.GetVtab.FindField(\"value\")\nif (zoneField=nil) then\n   return nil\nend\n\ntempFname=FileName.Mer
ge(newdir,\"tempstat.dbf\")\n\noutVtab=valGrid.zonalstatstable(zonegrid,prj.makenull,zoneField,false,tempFname)\n\nfromfield=outVtab.findfield(zonefield.getname)\ninmeanfield=outVtab.findfield(\"Mean\")\ninminField=outVtab.FindField(\"min\")\ninmaxField=outVtab.FindField(\"max\")\n\nif (basvtab.isbase=false) then\n  basvtab.unjoinall\nend\nbasvtab.join(basvtab.FindField(\"id\"),outVtab,fromfield)\n'atable=Table.Make(basvtab)\n\naddfieldList=List.Make\nif(basvtab.findfield(idstring)=nil) then\n    addfieldlist.add(field.make(idstring,
inmeanfield.gettype,inmeanfield.getwidth,inmeanfield.getprecision))\nend\nif(basvtab.findfield((idstring+\"min\"))=nil) then\n    addfieldlist.add(field.make((idstring+\"min\"),inminfield.gettype,inminfield.getwidth,inminfield.getprecision))\nend\nif(basvtab.findfield((idstring+\"max\"))=nil) then\n    addfieldlist.add(field.make((idstring+\"max\"),inmaxfield.gettype,inmaxfield.getwidth,inmaxfield.getprecision))\nend\nif (addFieldList.Count>0) then\n   basvtab.AddFields(addFieldList)\nend\nmeanField=basVtab.findfield(idstring
)\nminField=basVtab.FindField((idstring+\"min\"))\nmaxField=basVtab.FindField((idstring+\"max\"))\n'msgbox.info(\"gothere1\",\"\")\ninmeanfield=basVtab.findfield(\"Mean\")\ninminField=basVtab.FindField(\"min\")\ninmaxField=basVtab.FindField(\"max\")\nfor each rec in basVtab\n  meanval=basVtab.returnvalue(inmeanfield,rec)\n  minval=basVtab.returnvalue(inminfield,rec)\n  maxval=basVtab.returnvalue(inmaxfield,rec)\n  if (meanval.isnull) then\n     meanval=-1\n  end\n  if (minval.isnull) then\n     minval=-1\n  end\n  if (maxval.isnull) then
\n     maxval=-1\n  end\n  basVtab.setvalue(meanField,rec,meanval)\n  basVtab.setvalue(minField,rec,minval)\n  basVtab.setvalue(maxField,rec,maxval)\nend\n  \n'---remove join---\nbasVtab.unjoinall\n"
)

(Script.387
	Name:	"cap.gridavg_z"
	SourceCode:	"'#---------------------------------------------------\n'----------------------------------------------------\n' Name: cap.gridavg_z\n'\n' Description:  Add one new record to the statistical output \n'  table.    \n'\n' History: Created 12/15/2000\n'----------------------------------------------------\n'#---------------------------------------------------\n'determine inputs\nzoneGrid=self.get(0)\nvalGrid=self.get(1)\noutVtab=self.Get(2)\nstatDir=self.get(3)\nfieldlist=self.get(4)\nnewrec=self.Get(5)\n\nzoneVtab=zoneGrid.GetVt
ab\nzoneField=zoneVtab.Findfield(\"value\")\nif (zoneField=nil) then \n  msgbox.info(\"error in zone grid\",script.the.getname)\n  return nil\nend\ntempFname=FileName.Merge(statDir.AsString,\"atempstat.dbf\")\ntempVtab=valGrid.zonalstatstable(zonegrid,prj.makenull,zoneField,false,tempFname)\nfromfield=outVtab.findfield(zonefield.getname)\nmeanfield=tempVtab.findfield(\"Mean\")\nminField=tempVtab.FindField(\"min\")\nmaxField=tempVtab.FindField(\"max\")\nidField=tempVtab.FindField(\"value\")\n'*** tempVtab should have the same number o
f records as zoneVtab\n'*** if not, then use dictionary approach (as before to keep track of which zone output \n'*** create a list of output fields\nvalDict=Dictionary.Make(tempVtab.GetNumRecords)\nfor each rec in tempVtab\n    valid=tempVtab.ReturnValue(idField,rec)\n    meanval=tempVtab.ReturnValue(meanField,rec)\n    minval=tempVtab.ReturnValue(minField,rec)\n    maxval=tempVtab.ReturnValue(maxField,rec)\n    valDict.Add(valid,{meanval,minval,maxval})\nend\n\nzonecount=1\nfor each rec in zoneVtab\n  zoneid=zoneVtab.R
eturnValue(zoneField,rec)\n  valList=valDict.Get(zoneid)\n  if (valList=nil) then\n     continue\n  end\n  field_count = zonecount * 4  '**This needs to be changes if new field is added\n  outVTab.SetValue(fieldList.Get(field_count),newrec,nil)\n  outVTab.SetValue(fieldList.Get(field_count+1),newrec,valList.Get(0))\n  outVTab.SetValue(fieldList.Get(field_count+2),newrec,valList.Get(1))\n  outVTab.SetValue(fieldList.Get(field_count+3),newrec,valList.Get(2))\n  zonecount=zonecount+1 \nend"
)

(Script.388
	Name:	"cap.install"
	SourceCode:	"'-------------------------------------------------------\n'#-------------------------------------------------------\n' Name: cap.install\n'\n' Description:  Install the CAP Extension.    \n'\n' History: Created by Seann Reed 09/07/2000\n'#-------------------------------------------------------\n'-------------------------------------------------------\n\nif (av.GetProject = nil) then  \n  return nil\nend\n\nmsgbox.report(\"CAP\"+nl+\"Developed by the Hydrology Lab\"+nl+\"of the National Weather Service\",\"CAP\")\n\ntheproject=av.g
etproject\n\n' Install menus buttons and tools in the View GUI.\n' The SELF object is the ArcView Extension\nviewGUI = av.GetProject.FindGUI( \"View\" )\n\nif (viewGUI <> nil) then  \n \n  ' Add menus \n  viewGUI.GetMenuBar.Add( self.get(0), viewGUI.GetMenuBar.GetControls.count )  \n  viewGUI.GetButtonBar.Add( self.get(1), viewGUI.GetButtonBar.GetControls.count )\n  'viewGUI.GetMenuBar.Add( self.get(1), viewGUI.GetMenuBar.GetControls.count )\n  'viewGUI.gettoolbar.add( self.get(2), viewGUI.GetToolBar.GetControls.count )\n
  'viewGUI.gettoolbar.add( self.get(3), viewGUI.GetToolBar.GetControls.count )\n  'viewGUI.gettoolbar.add( self.get(4), viewGUI.GetToolBar.GetControls.count )\n  'viewGUI.gettoolbar.add( self.get(5), viewGUI.GetToolBar.GetControls.count )\n  'viewGUI.gettoolbar.add( self.get(6), viewGUI.GetToolBar.GetControls.count )\n  \n  \nend\nviewGUI.setmodified(true)\n'--- add dialogs\ntheproject=av.getproject\nfor each i in 2..12\n  'msgbox.info(i.asstring,\"\")\n  theproject.adddialog(self.get(i))\nend\n  \n'' 79.  /none/threshr/ave
files/threshr.install of 26 lines,"
)

(Script.389
	Name:	"cap.installdata"
	SourceCode:	"'#--------------------------------------------------------------------\n' Name:  cap.installdata\n'\n' Description:  Create RFC Level Data Sets Ready for Distribution by\n' clipping out existing data sets.  Two options are provided: \n' Option 1: clip\n'   all forest \n'   all ppt\n'   all pe\n'   all adj\n'   all snow\n'   all sac\n'\n' Option 2: clip\n'   forest\n'   mean annual \n'\n' snow copy script should be run separately         \n'\n'#---------------------------------------------------------------------\n\n'-----------
-----------------------\ncopyforest=true\ncopyprecip=true\ncopype=true\ncopyadj=true\ncopysac=true\nbasicsoil=true\ncopylegend=true\ncopywindows=true\n\noutroot=\"/bulk/1/gisdata/\"\n\n\n'**** Identify the RFC you are in \n'--- two letter code will be used to identify projected basin boundary file name\n\n'rfc=msgbox.choiceasstring({\"ab\",\"ak\",\"cb\",\"cn\",\"lm\",\"ma\",\"mb\",\"nc\",\"ne\",\"nw\",\"oh\",\"se\",\"wg\"},\"Select your RFC\",\"RFC Choice\")\n'if (rfc=nil) then\n'  exit\n'end\n\nrfc=\"ab\"\ntheView=av.GetActiveDoc\nif (theView.GetActiveThemes.cou
nt=1) then\n  maskGtheme=theView.GetActiveThemes.Get(0)\nelse\n  msgbox.info(\"One grid theme must be active.\",\"\")\n  exit\nend\nmaskGrid=maskGtheme.GetGrid\n\n'------------------------------------------\n'--- Explicitly Specify the Analysis Extent\n'------------------------------------------\ntherect=maskGtheme.ReturnExtent\ngcellsize=maskGrid.GetCellSize\n    \naEnv = theView.GetExtension(analysisenvironment)\n\n'oldrect=Rect.MakeXY(0,0,1,1)\n'oldcellsize=gcellsize\n'oldae_enum=aEnv.getextent(oldrect)\n'oldae_enum=aEnv.getce
llsize(oldcellsize)  \n\naEnv.SetExtent(#ANALYSISENV_value,theRect)\naEnv.SetCellSize(#analysisenv_maxof,nil)\naEnv.SetMask(maskGtheme)\naEnv.Activate \n'msgbox.info(\"gothere\",\"\")\n'Grid.SetAnalysisCellsize(#grid_envtype_maxof,nil)\n'Grid.SetAnalysisExtent(#grid_envtype_value,therect)\n'Grid.SetAnalysisMask(maskGrid)\n\n'msgbox.info(\"gothere\",\"\")\n\n'------------------------------------------\n'--- copy the legends directory and windows.shp\n'------------------------------------------\nif (copylegend) then\n   system.Execut
e(\"cp -r /fs/gis/usa/legends\"++outroot+rfc+\"rfc/legends\")\nend\nif (copywindows) then\n   system.Execute(\"cp /fs/gis/usa/snow/windows.*\"++outroot+rfc+\"rfc/snow\")\nend\n'------------------------------------------\n'--- Forest Data\n'------------------------------------------\n'get forest grid from disk\nin_for_dir=\"/fs/gis/usa/forest\"\n\n'newgtheme=gtheme.make(sourcegrid)\n'theview.addtheme(newgtheme)\n'newgtheme.setlegendvisible(false)\n'if (g=\"for_type\") then\n'+++++++++++\n'av.run(\"cap.for_typelegend\",{newgtheme})\n'+++++
+++++++++++++++++++\n'end\n\nif (copyforest) then\n  'define a new directory\n  outdirstr=outroot+rfc+\"rfc/forest\"\n  outdir=outdirstr.AsFilename\n  \n  if (outdir.IsDir.not) then\n     system.Execute(\"mkdir\"++outdirstr)\n     'create a new version of the grid just in the masked area\n     sourcefname=filename.merge(in_for_dir,\"for_pct\")\n     sourcefstr=sourcefname.asstring\n     insourcename=Grid.makesrcname(sourcefstr)\n     if (insourcename=nil) then\n       chk=msgbox.yesno(\"Could not find\"++sourcefstr++\"Continue?\",\"
CAP loadinputdata\",true)\n       if (chk=false) then \n         exit\n       end\n     end\n     sourcegrid=Grid.make(insourcename)\n     newgrid=sourcegrid*maskgrid\n     newfname=Filename.Merge(outdirstr,\"for_pct\")\n     newgrid.SaveDataSet(newfname)\n\n     sourcefname=filename.merge(in_for_dir,\"for_type\")\n     sourcefstr=sourcefname.asstring\n     insourcename=Grid.makesrcname(sourcefstr)\n     if (insourcename=nil) then\n       chk=msgbox.yesno(\"Could not find\"++sourcefstr++\"Continue?\",\"CAP loadinputdata\",true)\n   
    if (chk=false) then \n         exit\n       end\n     end\n     sourcegrid=Grid.make(insourcename)\n     newgrid=sourcegrid*maskgrid\n     newfname=Filename.Merge(outdirstr,\"for_type\")\n     newgrid.SaveDataSet(newfname)\n\n  end\nend\n\n'------------------------------------------\n'--- Precip Data\n'------------------------------------------\nmonList={\"jan\",\"feb\",\"mar\",\"apr\",\"may\",\"jun\",\"jul\",\"aug\",\"sep\",\"oct\",\"nov\",\"dec\",\"ann\"}\n\nif (copyprecip) then\n  'get forest grid from disk\n  in_pr_dir=\"/fs/gis/usa/prism\"\n  \n  '
define a new directory\n  outdirstr=outroot+rfc+\"rfc/prism\"\n  outdir=outdirstr.AsFilename\n  if (outdir.IsDir.not) then\n       system.Execute(\"mkdir\"++outdirstr)\n       for each mon in monList\n         sourcefname=filename.merge(in_pr_dir,(\"ppt\"+mon))\n         sourcefstr=sourcefname.asstring\n         insourcename=Grid.makesrcname(sourcefstr)\n         if (insourcename=nil) then\n         chk=msgbox.yesno(\"Could not find\"++sourcefstr++\"Continue?\",\"CAP loadinputdata\",true)\n         if (chk=false) then \n          
 exit\n         end\n       end\n       sourcegrid=Grid.make(insourcename)\n       'create a new version of the grid just in the masked area\n       newgrid=sourcegrid*maskgrid\n       newfname=Filename.Merge(outdirstr,(\"ppt\"+mon))\n       newgrid.SaveDataSet(newfname)\n    end\n  end\nend\n'------------------------------------------\n'--- PE \n'------------------------------------------\n\n\nif (copype) then\n   in_pe_dir=\"/fs/gis/usa/pe\"\n  \n  'define a new directory\n  outdirstr=outroot+rfc+\"rfc/pe\"\n  outdir=outdirstr.AsFi
lename\n  if (outdir.IsDir.not) then\n       system.Execute(\"mkdir\"++outdirstr)\n       for each mon in monList\n         sourcefname=filename.merge(in_pe_dir,(\"pe\"+mon))\n         sourcefstr=sourcefname.asstring\n         insourcename=Grid.makesrcname(sourcefstr)\n         if (insourcename=nil) then\n         chk=msgbox.yesno(\"Could not find\"++sourcefstr++\"Continue?\",\"CAP loadinputdata\",true)\n         if (chk=false) then \n           exit\n         end\n       end\n       sourcegrid=Grid.make(insourcename)\n       'cre
ate a new version of the grid just in the masked area\n       newgrid=sourcegrid*maskgrid\n       newfname=Filename.Merge(outdirstr,(\"pe\"+mon))\n       newgrid.SaveDataSet(newfname)\n    end\n  end\nend   'if copype\n\n'------------------------------------------\n'--- PE Adjust \n'------------------------------------------\n'Redefine month list without ann.\nmonList={\"jan\",\"feb\",\"mar\",\"apr\",\"may\",\"jun\",\"jul\",\"aug\",\"sep\",\"oct\",\"nov\",\"dec\"}\n\nif (copyadj) then\n  in_pe_dir=\"/fs/gis/usa/pe\"\n  \n  'define a new directory\n  ou
tdirstr=outroot+rfc+\"rfc/pe\"\n  outdir=outdirstr.AsFilename\n  for each mon in monList\n       sourcefname=filename.merge(in_pe_dir,(\"adj\"+mon))\n       sourcefstr=sourcefname.asstring\n       insourcename=Grid.makesrcname(sourcefstr)\n       if (insourcename=nil) then\n       chk=msgbox.yesno(\"Could not find\"++sourcefstr++\"Continue?\",\"CAP loadinputdata\",true)\n       if (chk=false) then \n         exit\n       end\n     end\n     sourcegrid=Grid.make(insourcename)\n     'create a new version of the grid just in the mas
ked area\n     newgrid=sourcegrid*maskgrid\n     newfname=Filename.Merge(outdirstr,(\"adj\"+mon))\n     newgrid.SaveDataSet(newfname)\n  end\nend\n\n'msgbox.info(\"Done\",\"\")\n\n'------------------------------------------\n'--- SAC-SMA Parameters\n'------------------------------------------\n\nif (copysac) then\n  parList = {\"lzfpm\",\"lzfsm\",\"lzpk\",\"lzsk\",\"lztwm\",\"pfree\",\"rexp\",\"uzfwm\",\"uzk\",\"uztwm\",\"zperc\"}\n  \n  'get forest grid from disk\n  in_sac_dir=\"/fs/gis/usa/sacsma\"\n  \n  'define a new directory\n  outdirstr=outroot+rfc+
\"rfc/sacsma\"\n  outdir=outdirstr.AsFilename\n  if (outdir.IsDir.not) then\n       system.Execute(\"mkdir\"++outdirstr)\n       for each par in parList\n         sourcefname=filename.merge(in_sac_dir,par)\n         sourcefstr=sourcefname.asstring\n         insourcename=Grid.makesrcname(sourcefstr)\n         if (insourcename=nil) then\n         chk=msgbox.yesno(\"Could not find\"++sourcefstr++\"Continue?\",\"CAP loadinputdata\",true)\n         if (chk=false) then \n           exit\n         end\n       end\n       sourcegrid=Grid.
make(insourcename)\n       'create a new version of the grid just in the masked area\n       newgrid=sourcegrid*maskgrid\n       newfname=Filename.Merge(outdirstr,par)\n       newgrid.SaveDataSet(newfname)\n    end\n  end\nend\n\n'------------------------------------------\n'--- Basic Soil Grids\n'------------------------------------------\n\nif (basicsoil) then\n  parList = {\"soil_depth\",\"soil_dom\",\"soil_hsgpct\"}\n  \n  in_soil_dir=\"/fs/gis/usa/soil/soil_alb\"\n  \n  'define a new directory\n  outdirstr=outroot+rfc+\"rfc/soil\"
\n  outdir=outdirstr.AsFilename\n  if (outdir.IsDir.not) then\n       system.Execute(\"mkdir\"++outdirstr)\n       for each par in parList\n         sourcefname=filename.merge(in_soil_dir,par)\n         sourcefstr=sourcefname.asstring\n         insourcename=Grid.makesrcname(sourcefstr)\n         if (insourcename=nil) then\n         chk=msgbox.yesno(\"Could not find\"++sourcefstr++\"Continue?\",\"CAP loadinputdata\",true)\n         if (chk=false) then \n           exit\n         end\n       end\n       sourcegrid=Grid.make(insour
cename)\n       'create a new version of the grid just in the masked area\n       newgrid=sourcegrid*maskgrid\n       newfname=Filename.Merge(outdirstr,par)\n       newgrid.SaveDataSet(newfname)\n    end\n  end\nend\n\n\n\n"
)

(Script.390
	Name:	"cap.make"
	SourceCode:	"'-------------------------------------------------------\n'#-------------------------------------------------------\n' Name: cap.make\n'\n' Description:  Make the CAP extension.    \n'\n' History: Created by Seann Reed on 09/07/2000\n'#-------------------------------------------------------\n'-------------------------------------------------------\n' Create the extension object\n'  NOTE - add dependencies to last empty list - if applicable\ntheproject=av.getproject\noutdir=theproject.getworkdir\nextfilename=Filename.mer
ge(outdir.asstring,\"cap_test.avx\")\ntheavx = Extension.Make( extfilename,\"CAP_TEST\",theproject.FindScript(\"cap.install\"), theproject.FindScript(\"cap.uninstall\"), {\"$AVBIN/avdlog.dll\".asfilename,\"$AVEXT/spatial.avx\".asfilename})\n' Set other properties \n'theavx.SetProjectSaveScript( av.FindScript( \"ProjectSave\" ))\ntheavx.setcanunloadscript(av.findscript(\"cap.canunload\"))\ntheavx.setunloadscript(av.findscript(\"cap.unload\"))\ntheavx.SetAbout(\"CAP Proto 1.1.7 - HL Option\")\ntheavx.SetExtVersion(1)\nviewGUI=theproject
.findGUI(\"View\")\n\n'--------------------------------\n'--- Add View Menus\n'-------------------------------- \nthemenu=viewGUI.getmenubar.findbylabel(\"CAP\")\ntheList=viewGUI.getmenubar.getControls\nthemenu.setobjecttag(nil)\ntheavx.add(themenu)\n\n'--------------------------------\n'--- Add View Buttons\n'-------------------------------- \nvbuttonbar=viewGUI.GetButtonBar\nvbuttonbarctls=vbuttonbar.getcontrols\nfor each bctrl in vbuttonbarctls\n  bctrl.setobjecttag(nil)\n  strkey=\"\"\n  if (bctrl.is(Space)) then\n    continue\n
  else\n    strkey=bctrl.GetClick\n  end\n  if(strKey.Contains(\"util.legendconversion\"))then\n    theavx.Add(bctrl.Clone)  \n  end\nend \n      \n'--------------------------------\n'--- Add Dialogs\n'--------------------------------\n\nthedialognames={\"dlg_coords\",\"dlg_stats\",\"dlg_subbsn\",\"dlg_xygraph\",\"ofs-mapx-define\",\"ofs-mapx-delete\",\"ofs-mapx-dump\",\n\"ofs-basin-define\",\"ofs-basin-delete\",\"ofs-basin-dump\",\"ofs-ppinit\"}\nfor each d in thedialognames\n   thedialog=theproject.finddialog(d)\n   thedialog.setobjecttag(nil)\n
   thedialog.setserver(nil)\n   theavx.add(thedialog)\nend\n\n'--------------------------------\n'--- Add Scripts\n'--------------------------------\n\n'  Note: this assumes that each script you want to include is in a SEd \n'  Include all scripts with the first 4 letters \n'  \"util\" and the first 3 letters \"cap\".\nfor each d in av.GetProject.GetDocs  \n  if (d.Is(SEd)) then    \n    if ((d.getname.left(4)=\"util\") or (d.getname.left(3)=\"cap\") or (d.getname.left(4)=\"mapx\")or \n       (d.getname.left(4)=\"mapx\") or (d.getna
me.left(4)=\"map\") or (d.getname.left(4)=\"mape\")or\n       (d.getname.left(3)=\"mat\") or (d.getname.left(4)=\"fmap\") or (d.getname.left(5)=\"basin\")or\n       (d.getname.left(3)=\"ofs\"))  then\n      if (d.iscompiled.not) then\n        d.compile\n      end\n      theavx.Add(d.GetScript) \n    end \n  end\nend\n\ntheavx.commit\n"
)

(Script.391
	Name:	"cap.pecards"
	SourceCode:	"\n\noutfile=LineFile.Make(\"/fs/hydro/users/sreed/calb/tifm7.pe\".asfilename,#file_perm_write)\n\nthetab=av.Getactivedoc\ntheVtab=theTab.GetVtab\n\ntheBitmap=theVtab.GetSelection\nselrec=theBitmap.GetNextSet(-1)\n\ntheFields=theVtab.GetFields\ncard5string=\"               \"\nmonlist={\"jan\",\"feb\",\"mar\",\"apr\",\"may\",\"jun\",\"jul\",\"aug\",\"sep\",\"oct\",\"nov\",\"dec\"}\nnumdayList={31,28.25,31,30,31,30,31,31,30,31,30,31}\nfor each mon in monlist\n   pefield=theVtab.FindField((\"pe\"+mon))\n   adjfield=theVtab.FindField((\"adj\"+mon))\n   pe=the
Vtab.ReturnValue(pefield,selrec)\n   adj=theVtab.ReturnValue(adjfield,selrec)\n   numdays=numdayList.Get(monlist.findbyvalue(mon))\n   outval=pe*adj/numdays\n   card5string=card5string+outval.setformat(\"d.dd\").asstring\nend\n\noutfile.WriteElt(card5string)"
)

(Script.392
	Name:	"cap.prestatistics"
	SourceCode:	"'#---------------------------------------------------------------------\n' name: cap.prestatistics\n'\n' Description: Precompute statistics for all defined basins\n'\n' Modified: 8/16/2000 by ZYZ\n'           12/14/2000 by SMR\n'#----------------------------------------------------------------------\n\n'----- include for future\nprecip=true\npe=true\nsacsma=true\npeadj=true\n'----- include for future\n\ntheView=av.GetActiveDoc\n'Get the basin Theme\nthemeList=av.run(\"util.getthms\",{theview,false,Ftheme,\"Poly\"})\nbasTheme=msgb
ox.Choice(themeList,\"Identify the subbasin Theme.\",script.the.getname)\nif (basTheme=nil) then\n  return nil\n  exit\nend\nbasFtab=basTheme.GetFtab\n\n'--- Get the DEM grid\ntagdict = theView.GetObjectTag\ndemTheme=av.run(\"cap.checktagdict\",{theview,\"Elevation\",tagdict,true})\nif (demTheme=nil) then\n   exit\nend\ndemGrid=demTheme.GetGrid\ngcellsize=demGrid.GetCellSize\n\nnameField = MsgBox.Choice(basFTab.GetFields,\"Select field with a 5 character basin identifier (e.g. ch5_id or shef_id)\",\"Field Selection\")\nif (nameField 
= nil) then\n   exit\nend\n\nidField = MsgBox.Choice(basFTab.GetFields,\"Select field with unique integer identifier\",\"Field Selection\")\nif (idField = nil) then\n   exit\nend\n \noutdir=tagdict.get(\"Output Directory\")\nif (outdir.count=0) then\n  chkout=msgbox.yesno(\"Output directory not specified.  Use project working directory?\",\"Output Directory\",true)\n  if (chkout=false) then\n    msgbox.info(\"Rerun setup to choose output directory.\",script.the.getname)\n    exit\n  elseif (chkout=nil) then\n    exit\n  else\n    outdir
=av.GetProject.GetWorkDir\n  end\nelse\n  outdir=outdir.AsFileName\nend\n\nnewdir=outdir.Clone\nnewdir.MergePath(\"stats\")\n\nif (newdir.isdir.not) then\n  '---create a subdirectory called \"stats\"\n  theOSEnum=System.GetOS\n  if (theOSEnum.asstring=\"SYSTEM_OS_MSW\") then\n     system.execute(\"c:\\command.com /c mkdir\"++newdir.asstring)\n  else\n     System.Execute(\"mkdir\"++newdir.asstring)\n  end\nend\n\n'--- convert basFtab into a grid with the same cell resolution as the DEM\n'------------------------------------------\n'--- Exp
licitly Specify the Analysis Extent\n'------------------------------------------\narect=basTheme.ReturnExtent\n'Make sure the rectangle extent is consistent with alignment of DEM Grid cells\n' Assumes (1) coordinate system origin is 0,0 and (2) x is increasing left to right\n' and y is increasing bottom to top\n'\naLeft=arect.GetLeft\nnumLeft=(aLeft/gcellsize).truncate\ntheLeft=(numLeft-1)*gcellsize\n'\naRight=arect.GetRight\nnumRight=(aRight/gcellsize).truncate\ntheRight=(numRight+1)*gcellsize\n'\naBottom=arect.GetBottom
\nnumBottom=(aBottom/gcellsize).truncate\ntheBottom=(numBottom-1)*gcellsize\n'\naTop=arect.GetTop\nnumTop=(aTop/gcellsize).truncate\ntheTop=(numTop+1)*gcellsize\ntheRect=Rect.MakeXY(theLeft,theBottom,theRight,theTop)\n\nGrid.SetAnalysisCellSize(#GRID_ENVTYPE_VALUE,gcellsize)\n\n'--- specify the extent and analysis cellsize of the grid to be created\nzoneGrid=Grid.MakeFromFtab(basFtab,prj.Makenull,idField,{gcellsize,theRect})\nif (zoneGrid.HasError) then \n   msgbox.info(\"Error creating zone grid.\",script.the.getname)\n   
exit\nend\n'zoneTheme=Gtheme.Make(zoneGrid)\n'theView.AddTheme(zoneTheme)\n\n'----------------------------------------------\n' Create empty stats table for each type of parameter\n' populate the stats table for each parameter\n'----------------------------------------------\n\n'---Add 5 char ID and numerical ID to the output fields. \nfieldList = List.Make\nfieldlist.add(field.make(\"id\",idField.gettype,idField.getwidth,idField.getprecision))\nfieldlist.add(field.make(\"idstring\",nameField.gettype,nameField.getwidth,name
Field.getprecision))\n\n'----------------------------------------------\n' Elevation and percent forest\n'----------------------------------------------\n\n'--- create elevation statistics table\nelvFname=FileName.Merge(newdir.asstring,\"elv.dbf\")\n\nelvVTab = VTab.MakeNew(elvFname,dbase)   'will erase any existing file with this name\nif (elvVTab.HasError) then \n    msgbox.info(\"Vtab has an error\",\"Vtab error\") \n    return nil\n    exit\nend\nelvVtab.SetEditable(true)\n\nelvVTab.AddFields(fieldList.deepclone)\nbasidField=e
lvVtab.FindField(\"id\")\nbasnamefield=elvVtab.findfield(\"idstring\")\nfor each rec in basFtab\n   newrec=elvVtab.AddRecord\n   elvVtab.SetValue(basidfield,newrec,basFtab.ReturnValue(idField,rec))\n   elvVtab.SetValue(basnameField,newrec,basFtab.ReturnValue(nameField,rec))\nend\n\n'--- COMPUTE AVERAGES FOR ELV AND PCTFOREST\n\ntagdict = theView.GetObjectTag\nfpctTheme=av.run(\"cap.checktagdict\",{theview,\"Percent Forest Cover\",tagdict,true})\n\n'--- elevation \nav.run(\"cap.gridavg\",{zoneGrid,demGrid,elvVtab,basidField,(\"elv\")
,newdir.asstring})\n\nif (fpctTheme<>nil) then\n  fpctgrid=fpctTheme.GetGrid\n  av.run(\"cap.gridavg\",{zoneGrid,fpctGrid,elvVtab,basidField,(\"fpct\"),newdir.asstring})\nend\n\n\nelvVtab.SetEditable(false)\n'table.make(elvVTab)\n\n'----------------------------------------------\n' PRECIP\n'----------------------------------------------\n\npptFname=FileName.Merge(newdir.asstring,\"ppt.dbf\")\n\npptVTab = VTab.MakeNew(pptFname,dbase)\nif (pptVTab.HasError) then \n    msgbox.info(\"Vtab has an error\",\"Vtab error\") \n    exit\nend\npptVta
b.SetEditable(true)\n\npptVTab.AddFields(fieldList.deepclone)\nbasidField=pptVtab.FindField(\"id\")\nbasnamefield=pptVtab.findfield(\"idstring\")\nfor each rec in basFtab\n   newrec=pptVtab.AddRecord\n   pptVtab.SetValue(basidfield,newrec,basFtab.ReturnValue(idField,rec))\n   pptVtab.SetValue(basnameField,newrec,basFtab.ReturnValue(nameField,rec))\nend\n\nindirString=tagdict.Get(\"Prism Data Directory\")\nif (indirString.count=0) then\n  msgbox.info(\"No PRISM Directory Specified. Please re-run setup.\",script.the.getname)\n  ex
it\nend\n\n'--- annual precip \nannSrcName = Grid.MakeSrcName(Filename.Merge(indirString,\"pptann\").AsString)\nannSrcGrid = Grid.Make(annSrcName)\n'msgbox.info(annSrcGrid.GetClass.GetClassName,script.the.getname)\nif (annSrcGrid.HasError.not) then\n  'msgbox.info(\"gothere1\"++annsrcname.asstring,\"\")\n\n  av.run(\"cap.gridavg\",{zoneGrid,annSrcGrid,pptVtab,basidField,\"pptann\",newdir.asstring})\n  'msgbox.info(\"gothere2\",\"\")\n  '--- monthly precip\n  monList = {\"jan\",\"feb\",\"mar\",\"apr\",\"may\",\"jun\",\"jul\",\"aug\",\"sep\",\"oct\",\"nov\"
,\"dec\"}\n  for each mon in monList\n     monSrcName = Grid.MakeSrcName(Filename.Merge(indirString,(\"ppt\"+mon)).AsString)\n     monSrcGrid = Grid.Make(monSrcName) \n     av.run(\"cap.gridavg\",{zoneGrid,monSrcGrid,pptVtab,basidField,(\"ppt\"+mon),newdir.asstring})\n  end\n\nend\npptVtab.SetEditable(false)\n\n\n'----------------------------------------------\n' PE\n'----------------------------------------------\n\npeFname=FileName.Merge(newdir.asstring,\"pe.dbf\")\n\npeVTab = VTab.MakeNew(peFname,dbase)\nif (peVTab.HasError) then \n
    msgbox.info(\"Vtab has an error\",\"Vtab error\") \n    exit\nend\npeVtab.SetEditable(true)\n\npeVTab.AddFields(fieldList.deepclone)\nbasidField=peVtab.FindField(\"id\")\nbasnamefield=peVtab.findfield(\"idstring\")\nfor each rec in basFtab\n   newrec=peVtab.AddRecord\n   peVtab.SetValue(basidfield,newrec,basFtab.ReturnValue(idField,rec))\n   peVtab.SetValue(basnameField,newrec,basFtab.ReturnValue(nameField,rec))\nend\n\npe_dirString=tagdict.Get(\"PE Data Directory\")\nif (pe_dirString.count=0) then\n  msgbox.info(\"PE directory n
ot found\",script.the.getname)\n  exit\nend\n\n'--- annual \nannSrcName = Grid.MakeSrcName(Filename.Merge(pe_dirString,\"peann\").AsString)\nif (annSrcName<>nil) then\n  annSrcGrid = Grid.Make(annSrcName)\n  if (annSrcGrid.HasError.Not) then\n  \n    av.run(\"cap.gridavg\",{zoneGrid,annSrcGrid,peVtab,basidField,\"peann\",newdir.asstring})\n    \n    '--- monthly \n    monList = {\"jan\",\"feb\",\"mar\",\"apr\",\"may\",\"jun\",\"jul\",\"aug\",\"sep\",\"oct\",\"nov\",\"dec\"}\n    for each mon in monList\n       monSrcName = Grid.MakeSrcName(Filename.Mer
ge(pe_dirString,(\"pe\"+mon)).AsString)\n       if (monSrcName=nil) then\n          msgbox.info(\"Can't create pe\"+mon,script.the.getname)\n          exit\n       end\n       monSrcGrid = Grid.Make(monSrcName) \n       av.run(\"cap.gridavg\",{zoneGrid,monSrcGrid,peVtab,basidField,(\"pe\"+mon),newdir.asstring})\n    end\n    for each mon in monList\n       monSrcName = Grid.MakeSrcName(Filename.Merge(pe_dirString,(\"adj\"+mon)).AsString)\n       if (monSrcName=nil) then\n          msgbox.info(\"Can't create adj\"+mon,script.the.g
etname)\n          exit\n       end\n       monSrcGrid = Grid.Make(monSrcName) \n       av.run(\"cap.gridavg\",{zoneGrid,monSrcGrid,peVtab,basidField,(\"adj\"+mon),newdir.asstring})\n    end\n  \n  end\nend\n\npeVtab.SetEditable(false)\n\n'----------------------------------------------\n' SAC\n'----------------------------------------------\n\nsacdirFname=tagdict.Get(\"SAC-SMA Directory\")\nif (sacdirFname.count=0) then\n   msgbox.error(\"Directory with SAC Data Not Found\",script.the.getname)\n   exit   'ok to exit here because the 
SAC parameters are the last parameters \n          'being calculated\nend\nchk=sacdirFname.AsFilename.isdir\nif (chk=false) then\n   msgbox.error(\"Directory with SAC Data Not Found\",script.the.getname)\n   exit\nend\n\nparList = {\"lzfpm\",\"lzfsm\",\"lzpk\",\"lzsk\",\"lztwm\",\"pfree\",\"rexp\",\"uzfwm\",\"uzk\",\"uztwm\",\"zperc\"}\n\nsacFname=FileName.Merge(newdir.asstring,\"sacsma.dbf\")\n\nsacVTab = VTab.MakeNew(sacFname,dbase)\nif (sacVTab.HasError) then \n    msgbox.info(\"Vtab has an error\",\"Vtab error\") \n    exit\nend\nsacVtab.SetEditable(
true)\n\nsacVTab.AddFields(fieldList.deepclone)\nbasidField=sacVtab.FindField(\"id\")\nbasnamefield=sacVtab.findfield(\"idstring\")\nfor each rec in basFtab\n   newrec=sacVtab.AddRecord\n   sacVtab.SetValue(basidfield,newrec,basFtab.ReturnValue(idField,rec))\n   sacVtab.SetValue(basnameField,newrec,basFtab.ReturnValue(nameField,rec))\nend\n  \nfor each par in parList\n   monSrcName = Grid.MakeSrcName(Filename.Merge(sacdirFname,par).asstring)\n   if (monSrcName<>nil) then\n     monSrcGrid = Grid.Make(monSrcName)\n     if (monS
rcGrid.HasError) then\n        continue\n     end \n     av.run(\"cap.gridavg\",{zoneGrid,monSrcGrid,sacVtab,basidField,par,newdir.asstring})\n   end\nend\n\nsacVtab.SetEditable(false)\n\n  \n\n"
)

(Script.393
	Name:	"cap.rmsadjinput"
	SourceCode:	"'Write pre-computed SAC parameters to an ASCII file in the format needed by RMS\n\noutfile=LineFile.Make(\"/fs/hydro/users/sreed/rms/dmip.adj\".asfilename,#file_perm_write)\n\nthetab=av.Getactivedoc\ntheVtab=theTab.GetVtab\n\nidField=theVtab.FindField(\"idstring\")\nparlist={\"adjjan\",\"adjfeb\",\"adjmar\",\"adjapr\",\"adjmay\",\"adjjun\",\"adjjul\",\"adjaug\",\"adjsep\",\"adjoct\",\"adjnov\",\"adjdec\"}\nparDict=Dictionary.Make(12)\n\nfor each rec in theVtab.GetSelection\n  'initialize dictionary\n  anindex=0\n  for each par in parlist\n     theFi
eld=theVtab.findField(par)\n     if (theField<>nil) then\n        aval=theVtab.ReturnValue(theField,rec)\n        parDict.Set(par,aval)\n     end\n     anindex=anindex+1\n  end\n  id=thevtab.ReturnValue(idField,rec)\n  outfile.writeelt(id)\n  linestring=\"\"\n  for each par in parList\n       linestring=linestring+\"  \"+parDict.Get(par).setformat(\"d.dd\").asstring\n  end\n  outfile.writeelt(linestring)\nend"
)

(Script.394
	Name:	"cap.rmspeinput"
	SourceCode:	"'Write pre-computed SAC parameters to an ASCII file in the format needed by RMS\n\noutfile=LineFile.Make(\"/fs/hydro/users/sreed/rms/dmip.pe\".asfilename,#file_perm_write)\n\nthetab=av.Getactivedoc\ntheVtab=theTab.GetVtab\n\nidField=theVtab.FindField(\"idstring\")\nparlist={\"pejan\",\"pefeb\",\"pemar\",\"peapr\",\"pemay\",\"pejun\",\"pejul\",\"peaug\",\"pesep\",\"peoct\",\"penov\",\"pedec\"}\nnumdayList={31,28.25,31,30,31,30,31,31,30,31,30,31}\nparDict=Dictionary.Make(12)\n\nfor each rec in theVtab.GetSelection\n  'initialize dictionary\n  anindex
=0\n  for each par in parlist\n     theField=theVtab.findField(par)\n     if (theField<>nil) then\n        aval=theVtab.ReturnValue(theField,rec)/numdaylist.get(anindex)\n        parDict.Set(par,aval)\n     end\n     anindex=anindex+1\n  end\n  id=thevtab.ReturnValue(idField,rec)\n  outfile.writeelt(id)\n  linestring=\"\"\n  for each par in parList\n       linestring=linestring+\"  \"+parDict.Get(par).setformat(\"d.dd\").asstring\n  end\n  outfile.writeelt(linestring)\nend"
)

(Script.395
	Name:	"cap.rmssacinput"
	SourceCode:	"'Write pre-computed SAC parameters to an ASCII file in the format needed by RMS\n\noutfile=LineFile.Make(\"/fs/hydro/users/sreed/rms/dmip.sac\".asfilename,#file_perm_write)\n\nthetab=av.Getactivedoc\ntheVtab=theTab.GetVtab\n\nidField=theVtab.FindField(\"idstring\")\nparlist={\"uztwm\",\"uzfwm\",\"uzk\",\"pctim\",\"adimp\",\"riva\",\"zperc\",\"rexp\",\"lztwm\",\"lzfsm\",\"lzfpm\",\"lzsk\",\"lzpk\",\"pfree\",\"side\",\"rserv\"}\nddlist={\"d\",\"d\",\"d.ddd\",\"d.ddd\",\"d.dd\",\"d.ddd\",\"d\",\"d.dd\",\"d\",\"d\",\"d\",\"d.ddd\",\"d.dddd\",\"d.dd\",\"d.dd\",\"d.dd\"}\nparDict=Dictionar
y.Make(16)\n\n\nfor each rec in theVtab.GetSelection\n  'initialize dictionary\n  for each par in parlist\n     theField=theVtab.findField(par)\n     if (theField<>nil) then\n        aval=theVtab.ReturnValue(theField,rec)\n        parDict.Set(par,aval)\n     end\n  end\n  parDict.Set(\"pctim\",0.0)\n  parDict.Set(\"adimp\",0.0)\n  parDict.Set(\"riva\",0.0)\n  parDict.Set(\"side\",0.0)\n  parDict.Set(\"rserv\",0.3)\n  id=thevtab.ReturnValue(idField,rec)\n  outfile.writeelt(id)\n  linestring=\"\"\n  for each par in parList\n     anindex=parl
ist.find(par)\n     linestring=linestring+\"  \"+parDict.Get(par).setformat(ddlist.get(anindex)).asstring\n  end\n  outfile.writeelt(linestring)\nend"
)

(Script.396
	Name:	"cap.rundlg_stats"
	SourceCode:	"thedialog=av.finddialog(\"dlg_stats\")\nthedialog.open"
)

(Script.397
	Name:	"cap.rundlg_sub"
	SourceCode:	"'#--------------------------------------------------------------------\n' Name:  cap.dlg_bassub.lbt_range.click\n' Function:     Assign range for the fields\n' History:      D. Wang \n' Last modified 8/25/2000 by SMR\n'#--------------------------------------------------------------------\n\nthedialog = av.finddialog(\"dlg_subbsn\")\n\ntheView = av.GetActiveDoc\nsubtagdict = theView.GetObjectTag\n'demTheme = subtagdict.Get(\"Subbasin Elevation\")\n'if demTheme=nil then\ndemTheme=av.run(\"cap.checktagdict\",{theview,\"Subbasin E
levation\",subtagdict,true})\nif (demTheme=nil) then\n   exit\nend\n\n'+++++++++++++++++++++++\n' if demGrid = nil, then make a list of Grids to choose from\n'+++++++++++++++++++++++\n\ndemGrid = demTheme.GetGrid\n\ntheMin = demgrid.getstatistics.get(0)\ntheMax = demgrid.getstatistics.get(1)\n\ntxtMin = thedialog.findbyname(\"txl_min\")\ntxtMax = thedialog.findbyname(\"txl_max\")\n\ntxtMin.setText(theMin.asString)\ntxtMax.setText(theMax.AsString)\n\n'--- initialize combobox\naComboBox=thedialog.FindByName(\"cbx_numbreaks\")   \nbreakli
st={1,2,3,4}\naCombobox.DefineFromList(breaklist)\n\n'-------------------------------------------\n' set up broadcaster and listener components\n'-------------------------------------------\ntxtln1=thedialog.findbyname(\"txtln1\")\ntxtln2=thedialog.findbyname(\"txtln2\")\ntxtln3=thedialog.findbyname(\"txtln3\")\ntxtln4=thedialog.findbyname(\"txtln4\")\n\ntxtln1.SetText(\"\")\ntxtln2.SetText(\"\")\ntxtln3.SetText(\"\")\ntxtln4.SetText(\"\")\n\naCombobox.setlisteners({txtln2,txtln3,txtln4})\nacombobox.broadcastupdate\n\nthedialog.open\n\n\n\n\n\n\n\n"
)

(Script.398
	Name:	"cap.rundlg_xygraph"
	SourceCode:	"thedialog=av.finddialog(\"dlg_xygraph\")\nthedialog.open"
)

(Script.399
	Name:	"cap.saccards"
	SourceCode:	"\n\noutfile=LineFile.Make(\"/fs/hydro/users/sreed/calb/tifm7.sac\".asfilename,#file_perm_write)\n\nthetab=av.Getactivedoc\ntheVtab=theTab.GetVtab\n\ntheBitmap=theVtab.GetSelection\nselrec=theBitmap.GetNextSet(-1)\n\ntheFields=theVtab.GetFields\nparlist={\"uztwm\",\"uzfwm\",\"uzk\",\"zperc\",\"rexp\",\"lztwm\",\"lzfsm\",\"lzfpm\",\"lzsk\",\"lzpk\",\"pfree\"}\nuztwm=theVtab.ReturnValue(thevtab.FindField(\"uztwm\"),selrec)\nuzfwm=theVtab.ReturnValue(thevtab.FindField(\"uzfwm\"),selrec)\nuzk=theVtab.ReturnValue(thevtab.FindField(\"uzk\"),selrec)\nzperc=th
eVtab.ReturnValue(thevtab.FindField(\"zperc\"),selrec)\nrexp=theVtab.ReturnValue(thevtab.FindField(\"rexp\"),selrec)\nlztwm=theVtab.ReturnValue(thevtab.FindField(\"lztwm\"),selrec)\nlzfsm=theVtab.ReturnValue(thevtab.FindField(\"lzfsm\"),selrec)\nlzfpm=theVtab.ReturnValue(thevtab.FindField(\"lzfpm\"),selrec)\nlzsk=theVtab.ReturnValue(thevtab.FindField(\"lzsk\"),selrec)\nlzpk=theVtab.ReturnValue(thevtab.FindField(\"lzpk\"),selrec)\npfree=theVtab.ReturnValue(thevtab.FindField(\"pfree\"),selrec)\n\n'--- create card3string\n'20 spaces pl
us assume pxadj and peadj equal 1.0\ncard3string=\"                      1.0  1.0\"\n\nspacecount=5-uztwm.setformat(\"d.d\").asstring.count\nif (spacecount>0) then\n   mbuff=String.MakeBuffer(spacecount)\n   card3string=card3string+mbuff+uztwm.setformat(\"d.d\").asstring\nelse\n   card3string=card3string+uztwm.setformat(\"d.d\").asstring\nend\n\nspacecount=5-uzfwm.setformat(\"d.d\").asstring.count\nif (spacecount>0) then\n   mbuff=String.MakeBuffer(spacecount)\n   card3string=card3string+mbuff+uzfwm.setformat(\"d.d\").asstring\nelse\n
   card3string=card3string+uzfwm.setformat(\"d.d\").asstring\nend\n\nspacecount=5-uzk.setformat(\"d.ddd\").asstring.count\nif (spacecount>0) then\n   mbuff=String.MakeBuffer(spacecount)\n   card3string=card3string+mbuff+uzk.setformat(\"d.ddd\").asstring\nelse\n   card3string=card3string+uzk.setformat(\"d.ddd\").asstring\nend\n\ncard3string=card3string+uzk.setformat(\"d.ddd\").asstring\n\n\ncard3string=card3string+\"  0.0  0.0  0.0  0.0\"\n\n'--- create card4string\n'20 spaces plus assume pxadj and peadj equal 1.0\ncard4string=\"         
           \"\n\nspacecount=5-zperc.setformat(\"d.d\").asstring.count\nif (spacecount>0) then\n   mbuff=String.MakeBuffer(spacecount)\n   card4string=card4string+mbuff+zperc.setformat(\"d.d\").asstring\nelse\n   card4string=card4string+zperc.setformat(\"d.d\").asstring\nend\n\nspacecount=5-rexp.setformat(\"d.dd\").asstring.count\nif (spacecount>0) then\n   mbuff=String.MakeBuffer(spacecount)\n   card4string=card4string+mbuff+rexp.setformat(\"d.dd\").asstring\nelse\n   card4string=card4string+rexp.setformat(\"d.dd\").asstring\nend\n\nspac
ecount=5-lztwm.setformat(\"d.d\").asstring.count\nif (spacecount>0) then\n   mbuff=String.MakeBuffer(spacecount)\n   card4string=card4string+mbuff+lztwm.setformat(\"d.d\").asstring\nelse\n   card4string=card4string+lztwm.setformat(\"d.d\").asstring\nend\n\nspacecount=5-lzfsm.setformat(\"d.d\").asstring.count\nif (spacecount>0) then\n   mbuff=String.MakeBuffer(spacecount)\n   card4string=card4string+mbuff+lzfsm.setformat(\"d.d\").asstring\nelse\n   card4string=card4string+lzfsm.setformat(\"d.d\").asstring\nend\n\nspacecount=5-lzfpm.set
format(\"d.d\").asstring.count\nif (spacecount>0) then\n   mbuff=String.MakeBuffer(spacecount)\n   card4string=card4string+mbuff+lzfpm.setformat(\"d.d\").asstring\nelse\n   card4string=card4string+lzfpm.setformat(\"d.d\").asstring\nend\n\ncard4string=card4string+lzsk.setformat(\"d.ddd\").asstring\ncard4string=card4string+lzpk.setformat(\"d.ddd\").asstring\ncard4string=card4string+\" \"pfree.setformat(\"d.dd\").asstring\ncard4string=card4string+\"  0.3  0.0\"\n\n\noutfile.WriteElt(card3string)\noutfile.WriteElt(card4string)"
)

(Script.400
	Name:	"cap.setup"
	SourceCode:	"'#--------------------------------------------------------------------\n' Name:  cap.setup\n'\n' Description:    \n' (1) Prompt the user for the input and output data directories\n' (2) Load Themes and Tables required for CAP analysis\n\n' set the View object tag \"Input Dictionary\" equal to the input data directory \n' string and \"Output Dictionary\" equal to the output data directory so that \n' other programs will know these locations. \n' \n' Edit gridNameList to load additional grids\n' Edit vectNameList to load add
itional vector Themes\n' Edit prismList to add more prism data layers\n'\n'\n' History: Created 4/5/2000 by Ziya, David under Seann's guidance at HRL\n'          Modified 7/7/2000 by Ziya\n'#---------------------------------------------------------------------\n\n\nusertype=msgbox.choiceasstring({\"RFC User\",\"HL User\"},\"Are you an RFC or HL user?\",\"Where are you?\")\nif (usertype=nil) then\n   exit\nend\nif (usertype=\"RFC User\") then\n  hl=false\nelseif (usertype=\"HL User\") then\n  hl=true\nelse\n  msgbox.info(\"should never se
e this\",\"\") \n  exit\nend\n\n'---------------------\n'hl allows the national cap data to be used in lieu of the \n'RFC specific CAP input data directory\n'\n'hl=true   ' should be false for RFC implementation \nhldir=\"/fs/gis/threshr\" \n'----- \n   \ntheview=av.getactivedoc\n  \n'--- check to see if the object tag for the current view is a list\n' of dictionaries\ntagdict = theview.getobjecttag\n\nif (tagdict=nil) then\n  av.run(\"util.createviewobjecttag\",nil)\nend\ntagdict=theview.GetObjectTag\n\n'**** Identify the RFC you wish 
to work with \n'--- two letter code will be used to identify projected basin boundary file name\n\n  rfc=msgbox.choiceasstring({\"ab\",\"ak\",\"cb\",\"cn\",\"lm\",\"ma\",\"mb\",\"nc\",\"ne\",\"nw\",\"oh\",\"se\",\"wg\"},\"Select your RFC\",\"RFC Choice\")\n  if (rfc=nil) then\n    exit\n  end\n   \n'--------------------------------------------------------\n' (1) Set input and output directories\n'--------------------------------------------------------\n\n'***** Input Directory Info including precip/temperature data input dir\n  indir=tagDict.get(\"I
nput Directory\")\n  \n  if (hl) then \n     indir=hldir+\"/\"+rfc+\"rfc\"\n  end\n  \n  indatadir=msgbox.input(\"Identify the data input directory.\",\"Cap Input Directory\",indir)\n  if (indatadir=nil) then\n     exit\n  end\n    \n  chk=indatadir.asfilename.isdir\n  if (chk=false) then\n    msgbox.error(\"Invalid data directory. Please rerun.\",\"Cap Input Directory\")\n    exit\n  end \n  \n'**** Assuming precip data under Prism directory which is under indatadir\n  'if (hl) then\n  '   prism_dirFname=Filename.merge(hldir,\"prism\")\n  '
else\n  \n   prism_dirFname=Filename.merge(indatadir,\"prism\")\n  \n  'end\n  'prism_dir = indatadir+\"/prism\"\n  prism_dir=prism_dirFname.asstring\n  \n  chk2=prism_dir.asfilename.isdir\n    if (chk2=false) then\n    msgbox.error(\"Could not find prism directory. Exiting.\",\"Cap Prism Data Directory\")\n    exit\n  end\n \n'**** Assuming PE data under pe directory which is under indatadir\n  'if (hl) then\n  '   pe_dirFname=Filename.merge(hldir,\"pe\")\n  'else\n  \n  pe_dirFname = FileName.Merge(indatadir,\"pe\")\n  \n  'end\n  pe_dir 
= pe_dirFname.AsString\n  \n  chk = pe_dir.AsFilename.Isdir\n  if (chk=false) then\n       msgbox.error(\"Could not find pe directory.  Exiting.\",\"Cap PE Data Directory\")\n       exit\n  end\n\n'**** Assuming snow data under indatadir\n  'if (hl) then\n  '   snow_dirFname=Filename.merge(hldir,\"snow\")\n  'else\n   \n  snow_dirFname = FileName.Merge(indatadir,\"snow\")\n  \n  'end\n  snow_dir = snow_dirFname.AsString\n  \n  chk =snow_dir.AsFilename.Isdir\n  if (chk=false) then\n       msgbox.error(\"Could not find snow directory.  E
xiting.\",\"Cap Snow Data Directory\")\n       exit\n  end\n  \n'**** Assuming Forest data under forest directory which is under indatadir\n  'if (hl) then\n  '   for_dirFname=Filename.merge(hldir,\"forest\")\n  'else\n  \n  for_dirFname = FileName.Merge(indatadir,\"forest\")\n  \n  'end\n  for_dir = for_dirFname.AsString\n  \n  chk = for_dir.AsFilename.Isdir\n  if (chk=false) then\n       msgbox.error(\"Could not find forest directory.  Exiting.\",\"Cap Forest Data Directory\")\n       exit\n  end \n  \n'**** Assume saved legends are un
der Legends directory\n    'if (hl) then\n    '   legend_dirFname=Filename.merge(hldir,\"legends\")\n    'else\n     \n    legend_dirFname=Filename.Merge(indatadir,\"legends\")\n    \n    'end\n   'legend_dir = indatadir + \"/legends\"\n   legend_dir=legend_dirFname.asstring\n   \n   chk3=legend_dir.asfilename.isdir\n   if (chk3=false) then\n    msgbox.error(\"Could not find legend directory.\",\"Cap Legend Directory\")\n    exit\n   end\n   \n'**** Assume SAC-SMA parameter data are under sacsma directory which is under Input directo
ry\n   'if (hl) then\n   '   sac_dirFname=Filename.merge(hldir,\"sacsma\")\n   'else\n   \n   sac_dirFname=Filename.Merge(indatadir,\"sacsma\")\n   \n   'end\n   \n   sac_dir=sac_dirFname.asstring\n   \n   chk3=sac_dir.asfilename.isdir\n   if (chk3=false) then\n     msgbox.error(\"Could not find sac directory.\",script.the.getname)\n     exit\n   end\n\n  \n'Determine/Set up output/working directory\n  out_string = tagdict.get(\"Output Directory\")\n  if (out_string.count=0) then\n     out_string=av.GetProject.GetWorkDir.Asstring\n  end
    \n  \n  outputdir=msgbox.input(\"Give output data directory.\",\"Cap Ouput Directory\",out_string)\n  \n  if (outputdir=nil) then\n     exit\n  end\n    \n  chk=outputdir.asfilename.isdir\n  if (chk=false) then\n    msgbox.error(\"Invalid output directory. Please rerun.\",\"Cap Output Directory\")\n    exit\n  end \n\n  av.GetProject.SetWorkDir(outputdir.asfilename)\n  'If output directory is not given, then check to see if input dir can be used\n  'if (outputdir=nil) then\n  '  chk=msgbox.yesno(\"Use the Input Directory as your
 Output Directory?\",script.the.getname,true)\n  '    if (chk = false) then\n  '      msgbox.info(\"Please rerun setup to define output directory\",\"\")\n  '      exit\n  '    else\n  '      outputdir = commondict.get(\"Input Directory\")\n  '    end\n  'end\n  \n  fname=outputdir.asfilename\n\n'while loop?\n  if (File.Exists(fname)) then\n     if (File.IsWritable(fname)) then \n      aProj = av.getProject\n      aProj.SetWorkDir(fname)      \n      end  \n  else\n     msgbox.error(\"Directory does not exist or permission denied. P
lease rerun setup.\",\"Cap_Output\")\n     exit\n  end\n\n'******** set Dictionary keys \n  tagdict.set(\"Input Directory\",indatadir)\n  tagdict.set(\"Output Directory\", outputdir)\n  tagdict.set(\"Prism Data Directory\", prism_dir)\n  tagdict.Set(\"Legend Directory\", legend_dir)\n  tagdict.Set(\"PE Data Directory\", pe_dir)\n  tagdict.Set(\"Forest Directory\",for_dir)\n  tagdict.Set(\"Snow Directory\",snow_dir)\n  tagdict.Set(\"SAC-SMA Directory\",sac_dir)\n\n   \n'--------------------------------------------------------\n' (2) Load requ
ired data into View\n'--------------------------------------------------------\n\n'Prepare to load data into the view\n ' chk=msgbox.yesno(\"Load Input Data?\",script.the.getname,true)\n  'if (chk=false) then\n'    chk1=msgbox.yesno(\"Reset object tags to default Theme names?\",script.the.getname,true)\n'    if (chk1) then\n'      '---- set tags\n'      tagdict.set(\"Analysis Polygon Theme\",theview.findtheme(\"rfcbound.shp\"))\n'      \n'      tagdict.set(\"Flow Direction\",theview.findtheme(\"fd\"))\n'      tagdict.set(\"Flow Acc
umulation\",theview.findtheme(\"fa\"))\n'      tagdict.set(\"Downstream Flowlength\",theview.findtheme(\"fld\"))\n'      tagdict.set(\"Elevation\",theview.findtheme(\"dem\"))\n'      tagdict.set(\"Slope Grid\",theview.findtheme(\"slopepct\"))\n'      tagdict.set(\"RF1 Streams\",theview.findtheme(\"rf1.shp\"))\n'      tagdict.set(\"NOHRSC Basins\",theview.findtheme(\"nohrscbsns.shp\"))\n'      \n'      tagdict.set(\"Mean Annual Ppt\", theview.findtheme(\"pptann\"))\n'      tagdict.set(\"Mean Annual Tmp\", theview.findtheme(\"tmpann\"))\n'      tag
dict.set(\"Annual PE\", theview.findtheme(\"peann\"))\n'      tagdict.set(\"Forest Percent Cover\", theview.findtheme(\"for_pct\"))\n'      tagdict.set(\"Detailed Forest Type\", theview.findtheme(\"for_type\"))\n'      \n'      'Soil Depth Grid\n'      tagdict.set(\"Soil Depth\", theview.findtheme(\"s_dpth\"))\n'    end\n'    exit\n'  end\n  \n  \n'--- LOAD INPUT DATA\n'--- Cap loadinputdata\n'--- Grids to load\n  gridnamelist={\"dem\",\"for_pct\",\"for_type\",\"peann\"}\n  'gridnamelist={\"dem\",\"fd\",\"fa\",\"mask\",\"fld\",\"slopepct\",\"for_pct\",\"for_ty
pe\",\"s_depth\"}\n  \n  '---check if annual precip and temp data exists\n  prismList={\"pptann\"}  'only annual data will be loaded into View\n                        'monthly data is accessed locally from disk as needed\n\n'---vector themes to load\n  vectnamelist={(\"bsns_\"+rfc+\"p.shp\"),\"statekey.shp\",\"rfcbound.shp\",\"rf1.shp\",\"windows.shp\"}\n  \n'---tables to load  DON'T NEED THESE FOR CAP\n  tabnamelist={\"parcode.dbf\",\"regequat.dbf\"}\n  \n'---load grids\n  for each g in gridnamelist\n     '---load a grid theme if it has no
t been loaded in the 'theview' yet\n     if (theview.findtheme(g)=nil) then\n        if ((g=\"for_pct\") or (g=\"for_type\")) then\n          sourcefname=filename.merge(for_dir,g)\n        elseif (g=\"peann\") then\n          sourcefname=filename.merge(pe_dir,g)\n        else\n          sourcefname=filename.merge(indatadir,g)\n        end\n          sourcefstr=sourcefname.asstring\n          insourcename=Grid.makesrcname(sourcefstr)\n          if (insourcename=nil) then\n             chk=msgbox.yesno(\"Could not find\"++source
fstr++\"Continue?\",\"CAP loadinputdata\",true)\n             if (chk) then\n               continue\n             else \n               exit\n           end\n        end\n       sourcegrid=Grid.make(insourcename)\n       newgtheme=gtheme.make(sourcegrid)\n       theview.addtheme(newgtheme)\n       newgtheme.setlegendvisible(false)\n       if (g=\"for_type\") then\n          '+++++++++++\n          av.run(\"cap.for_typelegend\",{newgtheme})\n          '++++++++++++++++++++++++\n       end\n       'msgbox.info(g,\"\")\n     end\n  end\n
  \n'---load annual precipitation theme and annual mean annual temperature if not yet\n  for each g in prismList  \n    if (theview.FindTheme(g)=nil) then\n      prismSrcfname=filename.merge(prism_dir,g)\n      prismSrcfstr=prismSrcfname.AsString\n      prisminSrcname=Grid.MakeSrcName(prismSrcfstr)\n      if (prisminSrcname=nil) then\n           chk=msgbox.yesno(\"Could not find\"++prismSrcfstr++\"Continue?\",\"CAP load prism input data\",true)\n           if (chk) then\n             continue\n           else \n             
exit\n           end\n       end\n\n       if (prisminSrcName <> nil) then     \n          ' Make a Theme from this data source\n           prismTheme = Theme.Make(prisminSrcname)\n           theview.AddTheme( prismTheme )  \n           prismTheme.SetLegendVisible(False)\n       end  \n    end\n  end \n 'msgbox.info(\"gothere\",\"\")\n'---load shapefiles\n  for each v in vectnamelist\n     if (theview.findtheme(v)=nil) then\n       if (v=\"windows.shp\") then\n          sourcefname=filename.merge(snow_dir,v)\n       else\n         
 sourcefname=filename.merge(indatadir,v)\n       end\n       sourcefstr=sourcefname.asstring\n       insourcename=srcname.make(sourcefstr)\n       if (insourcename=nil) then\n         chk=msgbox.yesno(\"Could not find \"++sourcefstr++\" Continue?\",\"Cap loadinputdata\",true)\n         if (chk) then\n           continue\n         else \n           exit\n         end\n       end\n       newtheme=theme.make(insourcename)\n       theview.addtheme(newtheme)\n       'newgtheme.setlegendvisible(false)\n       'msgbox.info(g,\"\")\n     
end\n  end\n  \ncolor.getblue.settransparent(false)\n'--- set river line to blue\n  refstr_theme=theview.findtheme(\"rf1.shp\")\n  if (refstr_theme<>nil) then\n    newlegend0=legend.make( #symbol_pen )\n    newlegend0.getsymbols.get(0).setcolor(color.getblue)\n    refstr_theme.setlegend(newlegend0)\n    refstr_theme.updatelegend\n  end\n\n'--- set watershed fill to gray\n  refshd_theme=theview.findtheme(\"rfcbound.shp\")\n  if (refshd_theme<>nil) then\n     newlegend=legend.make( #symbol_fill )\n     outcolor=color.make\n     ou
tcolor.setrgblist({210,210,210})\n     newlegend.getsymbols.get(0).setcolor(outcolor)\n     refshd_theme.setlegend(newlegend)\n     refshd_theme.updatelegend\n  end\n  \n'--- set the regions fill to transparent and display boundary\n  'reg_theme=theview.findtheme(\"regions.shp\")\n'  if (reg_theme <> nil) then\n'    newlegend1=legend.make( #symbol_fill )\n'    newlegend1.getsymbols.get(0).getcolor.settransparent(true)\n'    reg_theme.setlegend(newlegend1)\n'    reg_theme.updatelegend\n'    reg_theme.setvisible(true)    'T
his theme is selected initially\n'  end\n  \n'--- set sub-basins fill and outline to a color\n  refsub_theme=theview.findtheme(\"bsns_\"+rfc+\"p.shp\")\n  if (refsub_theme<>nil) then\n    outcolor=color.make\n    outcolor.setrgblist({230,230,230})\n    newlegend2=refsub_theme.GetLegend\n    theSymbols=newlegend2.GetSymbols\n    theSymbols.get(0).setcolor(outcolor)\n    theSymbols.Get(0).SetOlcolor(color.getgreen)\n    refsub_theme.updatelegend\n    refsub_theme.SetActive(True)    'Make it selected\n    refsub_theme.setvisibl
e(true)  \n  end\n  \n'---Set the precipitation and temperature to standard legends\n  ppt_theme = theview.FindTheme(\"pptann\")\n  if (ppt_theme<>nil) then\n    plegend = ppt_theme.GetLegend\n    plegend.Load(filename.merge(legend_dir,\"ppt_legend.avl\"),#LEGEND_LOADTYPE_SYMBOLS)\n    ppt_theme.SetLegend(plegend)\n    ppt_theme.UpdateLegend\n    ppt_theme.SetVisible(False)\n  end  \n  \n'--- Set color map for DEM theme\n  dem_theme = theview.FindTheme(\"Dem\")\n  if (dem_theme<>nil) then\n    demLegend = dem_theme.GetLegend\n   
 demLegend.Load(filename.merge(legend_dir,\"dem_legend.avl\"),#LEGEND_LOADTYPE_ALL)  \n    dem_theme.SetLegend(demLegend)\n    dem_theme.UpdateLegend\n    dem_theme.SetVisible(False)\n  end  \n\n  \n'Set the View units to Meters\n    theview.SetUnits(#UNITS_LINEAR_METERS)\n  \n'Set the distance units to meters\n    d = theview.GetDisplay\n    d.SetDistanceUnits(#UNITS_LINEAR_METERS)\n\n'Rename the active view as RFCView\n    theview.SetName(\"RFCView\")\n    \n'Zoom all themes to full extent\n    'r = theview.ReturnExtent\n    if
 (theview.getactivethemes.count=0) then\n       r=dem_theme.ReturnExtent\n    else\n       r=theview.GetactiveThemes.Get(0).ReturnExtent\n    end\n    if (r.IsEmpty) then\n      return nil\n    elseif ( r.ReturnSize = (0@0) ) then\n      theView.GetDisplay.PanTo(r.ReturnOrigin)\n    else\n      theView.GetDisplay.SetExtent(r.Scale(1.1))\n      av.GetProject.SetModified(true)\n    end\n\n  \n'---- set tags\n  'tagdict.set(\"Analysis Polygon Theme\",theview.findtheme(\"rfcbound.shp\"))\n  \n  'tagdict.set(\"Flow Direction\",theview.
findtheme(\"fd\"))\n  'tagdict.set(\"Flow Accumulation\",theview.findtheme(\"fa\"))\n  'tagdict.set(\"Downstream Flowlength\",theview.findtheme(\"fld\"))\n  tagdict.set(\"Elevation\",theview.findtheme(\"dem\"))\n  'tagdict.set(\"Slope Grid\",theview.findtheme(\"slopepct\"))\n  tagdict.set(\"RF1 Streams\",theview.findtheme(\"rf1.shp\"))\n  tagdict.set(\"NOHRSC Basins\",theview.findtheme(\"nohrscbsns.shp\"))\n  \n  tagdict.set(\"Mean Annual Ppt\", theview.findtheme(\"pptann\"))\n  tagdict.set(\"Mean Annual Tmp\", theview.findtheme(\"tmpann\")) \n  tagd
ict.set(\"Annual PE\", theview.FindTheme(\"peann\")) \n  tagdict.set(\"Forest Percent Cover\", theview.FindTheme(\"for_pct\"))\n  tagdict.set(\"Detailed Forest Type\", theview.FindTheme(\"for_type\"))\n  tagdict.set(\"Snow Windows\",theview.findtheme(\"windows.shp\"))\n  \n'Soil Depth Grid\n  tagdict.set(\"Soil Depth\", theview.findtheme(\"s_dpth\"))\n\n"
)

(Script.401
	Name:	"cap.snowcopy"
	SourceCode:	"'#--------------------------------------------------------------------\n' Name:  cap.snowcopy\n'\n' Function:  Display a list of snow images that are available for \n' the selected basin.\n'\n'#---------------------------------------------------------------------\n\ntheview=av.getactivedoc\nchkfile=LineFile.Make(\"/fs/gis/cap/filelist.txt\".asfilename,#file_perm_write)\n'rfclist={\"ne\",\"ma\",\"se\",\"lm\",\"oh\",\"nc\",\"mb\",\"ab\",\"wg\",\"cb\",\"cn\",\"nw\"}\n'rfclist={\"ne\",\"ma\",\"se\",\"lm\",\"oh\",\"nc\",\"mb\",\"ab\",\"wg\",\"cn\"}\nrfclist={\"ab\"}\n\nfor
 each rfc in rfclist\n   \n   '--- get the snow window theme\n   rfcdir=\"/bulk/1/gisdata/\"+rfc+\"rfc\"+\"/snow\"\n   if (rfcdir.AsFilename.isdir.not) then\n      system.execute(\"mkdir\"++rfcdir)\n   end\n   winsourcestr=\"/fs/gis/usa/snow/windows.shp\"\n   insourcename=srcname.make(winsourcestr)\n   if (insourcename=nil) then\n     chk=msgbox.yesno(\"Could not find \"++winsourcestr++\" Continue?\",\"\",true)\n     if (chk) then\n       continue\n     else \n       exit\n     end\n   end\n   wintheme=theme.make(insourcename)\n   winftab=w
intheme.getftab\n   'theview.addtheme(wintheme)\n   '\n   '--- get the rfc boundary theme\n   bndsourcestr=\"/bulk/1/gisdata/\"+rfc+\"rfc\"+\"/rfcbound.shp\"\n   insourcename=srcname.make(bndsourcestr)\n   if (insourcename=nil) then\n     chk=msgbox.yesno(\"Could not find \"++bndsourcestr++\" Continue?\",\"\",true)\n     if (chk) then\n       continue\n     else \n       exit\n     end\n   end\n   bndtheme=theme.make(insourcename)\n   bndftab=bndtheme.getftab\n   \n   '\n   ''------- determine possible windows\n   '\n   winFtab.SelectByFt
ab(bndFtab,#ftab_reltype_intersects,1,#vtab_seltype_new)\n   idField=winFtab.FindField(\"Id\")\n   \n   yearlist={\"1990\",\"1991\",\"1992\",\"1993\",\"1994\",\"1995\"}\n   \n   for each wrec in winFtab.GetSelection\n      id=winFtab.ReturnValue(idField,wrec)\n      if (id<10) then\n        idstring=\"0\"+id.asstring\n      else\n        idstring=id.asstring\n      end\n      chkfile.writeelt(idstring)\n      \n      for each y in yearlist\n        filelist=(\"/fs/gis/usa/snow/\"+y+\"/us\").AsFileName.Read(\"*\")\n      \n        for each f in f
ilelist\n            fname=f.GetBaseName\n            if (fname.count=9) then\n               if (fname.Middle(1,2)=idstring) then\n                    chkfile.writeelt(fname)\n                    '--- copy the grid file to the correct location  \n                    infilename=(\"/fs/gis/usa/snow/\"+y+\"/us\"+\"/\"+fname).asfilename\n                    outfilename=(rfcdir+\"/\"+fname).asfilename\n                    success=Grid.CopyDataSet(infilename,outfilename)\n                    if (success=false) then\n             
          exit\n                    end \n                             \n                    'daystring=fname.Right(5)\n                    'availdate=Date.Make(daystring,\"yyj\")\n         \n                    'availdates.Add(availdate.setformat(\"mdy\".Asstring))\n                    'filenames.Add(fname)\n                    'copy the appropriate files to the current directory\n               end\n            end\n        end  'file list\n      end  'year list\n   \n   end  'window list\nend\n\n\n\n\n \n'^^^^^^^^^^^^^^^^^^^^^^^
^\n'msgbox.choiceasstring(filenames,\"\",\"\")\n'msgbox.choiceasstring(availdates,\"\",\"\")\n\n'newdate=Date.Make(\"95032\",\"yyjj\")\n'msgbox.info(newdate.setformat(\"MMM\"++\"dd\"++\"yyyy\").asstring,\"\")\n\n'look in the snow directory to determine the available data\n'filter=\n'-------- display a list of possible snow Themes \n"
)

(Script.402
	Name:	"cap.snowview"
	SourceCode:	"'#--------------------------------------------------------------------\n' Name:  cap.snowview\n'\n' Function:  Display a list of snow images that are available for \n' the selected basin.\n'\n' Notes: Corrected for a bug on Dec. 5, 2006 by Seann Reed.  See user\n' manual on web site for a description.\n'\n'#---------------------------------------------------------------------\n\n'chkfile=LineFile.Make(\"/none/cap/out1/filelist.txt\".asfilename,#file_perm_write)\n\ntheview=av.GetActiveDoc\nsubtagDict=theview.GetObjectTag\npa
rentView=subtagDict.Get(\"Parent View\")\ntagDict=parentView.GetObjectTag\n\n'---\nlegend_dir=tagDict.Get(\"Legend Directory\")\n''Get Theme of Snow Windows\nwinTheme=tagDict.Get(\"Snow Windows\")\nwinFtab=winTheme.GetFtab\n\n'--- get the input directory\nsnowdir=tagDict.Get(\"Snow Directory\")\n'msgbox.info(snowdir,\"\")\n\n''determine extent\nsubbsnTheme=subtagDict.Get(\"Subbasin Polygon\")\nsubbsnTheme = av.run(\"cap.checktagdict\",{theView,\"Subbasin Polygon\",subtagdict,false})\n if (subbsnTheme=nil) then\n    return nil\n end \n\n'-----
-- determine possible windows\n'\n'identify the windows theme\n\nsubbsnFtab=subbsnTheme.GetFtab\nsubbsnFtab.GetSelection.ClearAll\nwinFtab.SelectByFtab(subbsnFtab,#ftab_reltype_intersects,1,#vtab_seltype_new)\nidField=winFtab.FindField(\"Id\")\n\navailgstrings=List.Make\nsnowcount=0\nfor each rec in winFtab.GetSelection\n  \n  id=winFtab.ReturnValue(idField,rec)\n  \n  '--- get a list of grids that cover the selected basin\n  filelist=snowdir.AsFileName.Read(\"*\")\n  if (id<10) then\n    idstring=\"0\"+id.asstring\n  else\n    idst
ring=id.asstring\n  end\n  nfiles=filelist.count\n  gdict=Dictionary.Make(nfiles)    \n  for each f in filelist\n     fname=f.GetBaseName\n     if (fname.count=9) then\n        if (fname.Middle(1,2)=idstring) then\n              daystring=fname.Right(5)\n              availdate=Date.Make(daystring,\"yyj\")\n              availgstrings.Add(availdate.setformat(\"yyy\"+\"-\"+\"M\"+\"-\"+\"d\").AsString++\"Window\"++idstring)\n              gdict.add((availdate.setformat(\"yyy\"+\"-\"+\"M\"+\"-\"+\"d\").AsString++\"Window\"++idstring),f) \n        
end\n     end\n  end\nend\navailgstrings.Sort(true)\n  \nsellist=msgbox.MultiListAsString(availgstrings,\"Choose Snow Images to Load\",script.the.getname)\nif (sellist=nil) then\n   exit\nend\nif (sellist.count=0) then\n  exit\nelse\n  for each s in sellist\n     \n     ingridfname=gdict.get(s)\n     \n     ingridSrcname=Grid.MakeSrcName(ingridfname.AsString)\n     'if (ingridSrcname=nil) then\n     '   chk=msgbox.yesno(\"Could not find\"++ingridSrcfstr++\"Continue?\",\"\",true)\n     '   if (chk) then\n     '      continue\n     '   el
se \n     '      exit\n     '   end\n     'end\n     if (ingridSrcname <> nil) then     \n        ' Make a Theme from this data source\n         inTheme = Theme.Make(ingridSrcname)\n         theview.AddTheme( inTheme )  \n         'inTheme.SetLegendVisible(False)  \n         inlegend = inTheme.GetLegend\n         inlegend.Load(filename.merge(legend_dir,\"snow.avl\"),#LEGEND_LOADTYPE_CLASSESANDSYMBOLS)\n         intheme.SetLegend(inlegend)\n         intheme.UpdateLegend\n         intheme.SetVisible(false)\n         intheme.
SetName(s)\n         snowcount=snowcount+1\n     end\n  end\nend  \n\ntheThemes = theView.GetThemes\n\nfor each i in 1..snowcount\n  ' the first becomes the last \n  theThemes.Shuffle(theThemes.Get(0), (theThemes.Count))\nend\ntheview.InvalidateTOC(nil)\n\n"
)

(Script.403
	Name:	"cap.subviewactive.update"
	SourceCode:	"theView = av.GetActiveDoc\nsubtagdict=theView.GetObjectTag\nif (subtagdict=nil) then\n  self.setenabled(false)\n  exit\nend\nif (subtagdict.get(\"CAPSubbasin\")=true) then\n  self.setenabled(true)\nelse\n  self.setenabled(false)\nend\n\n'tlist = theView.GetActiveThemes\n'if (tlist.count<>1) then\n'   SELF.SetEnabled(false)\n'   exit\n'else\n'   actTheme = theView.GetActiveThemes.get(0)\n'   'If active theme is a not an Ftheme\n'   if (actTheme.getclass.getclassname<>\"Ftheme\") then\n'      SELF.SetEnabled(false)\n'      exit\n'   e
lse\n'      actFtab=actTheme.GetFtab\n'      if (actFtab.GetShapeClass.GetClassName<>\"Polygon\") then\n'         SELF.SetEnabled(false)\n'         exit\n'      end\n'      if (actFtab.GetSelection.Count<>1) then\n'        SELF.SetEnabled(false)\n'        exit\n'      end\n'   end\n'end\n\n'SELF.SetEnabled(true)\n    \n   \n"
)

(Script.404
	Name:	"cap.uninstall"
	SourceCode:	"'-------------------------------------------------------\n'#-------------------------------------------------------\n' Name: cap.uninstall\n'\n' Description:  Uninstall the CAP extension.    \n'\n' History: Created by Seann Reed 09/07/2000\n'#-------------------------------------------------------\n'-------------------------------------------------------\n' Don't uninstall if there is no project\nif (av.GetProject = nil) then  \n  return nil\nend\ntheproject=av.getproject\n' Clean up even if the project is closing\n' don'
t uninstall extension objects if project is closing\nif (av.GetProject.IsClosing) then  \n  return nil\nend\n' Remove objects owned by the extension from the project\nviewGUI=theproject.FindGUI(\"View\")\nviewMenuBar=viewGUI.getmenubar\nif(viewGUI<>nil) then\n  viewmenubar.remove(viewmenubar.findbylabel(\"CAP\"))\nend\n\nViewBBar=TheProject.FindGui(\"View\").GetButtonBar\nViewBBarCtrl=ViewBBar.GetControls\nRmvList=List.Make\nfor each Bctrl in ViewBBarCtrl\n  strKey=\"\"\n  if(Bctrl.is(Space))then\n    continue\n  else\n    strKey=Bct
rl.GetClick\n  end\n  if(strKey.Contains(\"util.legendconversion\"))then\n    rmvlist.add(bctrl)\n  end\nend\n\nfor each rmvObj in RmvList\n   ViewBBar.Remove(rmvObj)\nend\n\n'--- Remove dialogs\n'--- The \"SELF\" object is the ArcView Extension\ntheproject=av.getproject\nfor each i in 2..12\n  theproject.removedialog(self.get(i).getname)\nend\n\n'--- Remove \"CAPGraph\" GUI if it exists\ntheGui= av.FindGui(\"CAPGraph\")\nif (theGui<>nil) then\n  theproject=av.getproject\n  docList=theproject.GetDocsWithGUI(theGUI)\n  for each d in docLi
st\n    theproject.RemoveDoc(d)\n  end\n\n  theproject.removegui(\"CAPGraph\")\nend\n"
)

(Script.405
	Name:	"cap.uninstalldata"
	SourceCode:	"'#--------------------------------------------------------------------\n' Name:  cap.uninstalldata\n'\n' Function:  Remove data from directories specified in a file called\n' .capdata which is located by default in the user's home directory.\n' The .capdata file is written by the \"View Object Tags\" script under\n' the CAP menu.     \n'\n'#---------------------------------------------------------------------\n\nnewFile=nil\ntheOSEnum=System.GetOS\nif (theOSEnum.asstring=\"SYSTEM_OS_UNIX\") then\n  '-- assume that home dire
ctory exists and is writable\n  userhome=system.getenvvar(\"HOME\")\n  fileString=userhome+\"/.capdata\"\n  newFile=LineFile.Make(fileString.AsFilename,#file_perm_read)\n  \n  while (newFile.IsAtEnd=false)\n     dirName=newFile.ReadElt\n     system.execute(\"rm -r\"++dirName)\n  end\n  \nend\n"
)

(Script.406
	Name:	"cap.unload"
	SourceCode:	"dialog.DetachFromExtension(self)"
)

(Script.407
	Name:	"cap.xygraph.aeupdate"
	SourceCode:	"theView=av.GetActiveDoc\ntagList=theView.GetObjectTag\nif (tagList<>nil) then\n  graphtype=tagList.Get(0)\n  if (graphtype=\"ae\") then\n    self.setenabled(true)\n  else\n    self.setenabled(false)\n  end\nend"
)

(Script.408
	Name:	"cap.xygraph.dlg_coords.lbt_copy.click"
	SourceCode:	"'Copy text to the system clipboard.\ntbx_coords=Self.GetDialog.FindbyName(\"tbx_coords\")\nseltext=tbx_coords.GetText\nClipBoard.The.Empty\nClipBoard.The.Add(seltext)\nClipBoard.The.Update"
)

(Script.409
	Name:	"cap.xygraph.dlg_coords.lbt_ok.click"
	SourceCode:	"self.getDialog.Close"
)

(Script.410
	Name:	"cap.xygraph.docGUI"
	SourceCode:	"\n'Create a new GUI on the fly\n'Do not add GUI to the Project\n\ngraphTitle=\"CAPGraph\"\n\nif (av.GetProject.FindGUI(\"CAPGraph\")=nil) then\n  newGUI = av.FindGUI(\"View\").Clone\n  newGUI.SetName(\"CAPGraph\")\n  \n  menuControlSet=newGUI.GetMenuBar\n  menu1=menuControlSet.FindByLabel(\"File\")\n  menu2=menuControlSet.FindByLabel(\"Edit\")\n  menu3=menuControlSet.FindByLabel(\"Graphics\")\n  menu4=menuControlSet.FindByLabel(\"Window\")\n  menuControlSet.Empty\n  menuControlSet.Add(menu1,0)\n  menuControlSet.Add(menu2,1)\n  menuControlSe
t.Add(menu3,2)\n  menuControlSet.Add(menu4,3)\n  'modify Tools\n  aControlSet=newGUI.GetToolBar\n  textTool=aControlSet.FindByScript(\"View.TextTool\")\n  drawTool=aControlSet.FindByScript(\"View.PointTool\")\n  selectTool=aControlSet.FindByScript(\"View.Select\")\n  panTool=aControlSet.FindByScript(\"View.Pan\")\n  zoominTool=aControlSet.FindByScript(\"View.ZoomInTool\")\n  zoomoutTool=aControlSet.FindByScript(\"View.ZoomOutTool\")\n  xyTool=Tool.Make\n  xyTool.SetIcon(Icon.MakeFromResName(\"Icons.ID\"))\n  xyTool.SetApply( \"cap.xy
graph.getpointvalue\" )\n  xyTool.SetHelp(\"Get graph coordinates of a point clicked by the mouse\")  \n  aSpace=Space.Make\n  aControlSet.Empty\n  aControlSet.Add(textTool,0)\n  aControlSet.Add(drawTool,1)\n  aControlSet.Add(selectTool,2)\n  aControlSet.Add(panTool,3)\n  aControlSet.Add(zoominTool,4)\n  aControlSet.Add(zoomoutTool,5)\n  aControlSet.Add(aSpace,6)\n  aControlSet.Add( xyTool,7)  \n  \n  buttonControlSet=newGUI.GetButtonBar\n  buttonControlSet.Empty\n  newButton = Button.Make \n  newButton.SetIcon(Icon.MakeFromR
esName(\"Icons.XY2\"))\n  newButton.SetClick( \"cap.xygraph.rundlg_coords\" )\n  newButton.SetHelp(\"Display XY coordinate list.\")  \n  buttonControlSet.Add( newButton, 0 )\n  \n  'newButton = Button.Make \n  'newButton.SetIcon(Icon.MakeFromResName(\"Icons.PennantGreen\"))\n  'buttonControlSet.Add( newButton, 1 )\n  'newButton.SetClick( \"cap.xygraph.flagpoints\" )\n  'newButton.SetHelp(\"Flag points not to be included in MCP card 3A\")\n  'newButton.SetUpdate(\"cap.xygraph.aeupdate\")\n  \n  newButton = Button.Make \n  newButton.Se
tIcon(Icon.MakeFromResName(\"Icons.Write\"))\n  buttonControlSet.Add( newButton, 2 )\n  newButton.SetClick( \"cap.xygraph.writesnow17\" )\n  newButton.SetHelp(\"Write Cards 3A and 3B for Snow 17\")\n  newButton.SetUpdate(\"cap.xygraph.aeupdate\")\n\n  newButton = Button.Make \n  newButton.SetIcon(Icon.MakeFromResName(\"Icons.S\"))\n  buttonControlSet.Add( newButton, 3 )\n  newButton.SetClick( \"cap.10_50_90\" )\n  newButton.SetHelp(\"Report 10th, 50th, and 90th percentiles\")\n  newButton.SetUpdate(\"cap.xygraph.aeupdate\")\n\n  \n  'mo
dify Menus\n  av.GetProject.AddGUI(newGUI)\n  newGUI.SetTitle(\"CAPGraph\")\n  newGUI.SetDocBaseName(\"CAPGraph\")\n  newGUI.SetIcon(Icon.MakeFromResName(\"Icons.Icon12\"))\n  newGUI.SetNewScript(\"cap.graphnew\")\nend\n\nnewView = View.MakeWithGUI(\"CAPGraph\")\nnewView.SetTOCUnresizable(true)\nnewView.SetTOCWidth(0)\n\nnewView.GetWin.Resize(700,600)\nnewView.GetWin.Open\n\nreturn newView"
)

(Script.411
	Name:	"cap.xygraph.getpointvalue"
	SourceCode:	"'#--------------------------------------------------------------------\n' Name:  cap.xygraph.getpointvalue\n'\n' Function:  Get the value of a series point in a View\n'#---------------------------------------------------------------------\n\ntheView = av.GetActiveDoc\nplotScales=theView.GetObjectTag\nyvalOrigin=plotScales.Get(1)\nytic_inc=plotScales.Get(2)\nxvalOrigin=plotScales.Get(3)\nxtic_inc=plotScales.Get(4)\n\n'theGraphicsList=theView.GetGraphics\n''theGraphic=nil\n'count=0\n'gsel=nil\n'for each g in theGraphicsList\n'
  if (g.IsSelected) then\n'    count=count+1\n'    if (count>1) then \n'      msgbox.info(\"One and only one point must be selected.\",script.the.getname)\n'      exit\n'    end\n'    gsel=g.clone\n'  end\n'end\n'if (count=0) then\n'  msgbox.info(\"One and only one point must be selected.\",script.the.getname)\n'  exit\n'end\np = theView.GetDisplay.ReturnUserPoint\n\nxplot = p.GetX\nyplot = p.GetY\nxval = xplot*xtic_inc/10 + xvalOrigin\nyval = yplot*ytic_inc/10 + yvalOrigin\nmsgbox.info(\"X =\"++xval.asstring+nl+\"Y =\"++yval.Asstrin
g,script.the.getname)\n  \n"
)

(Script.412
	Name:	"cap.xygraph.pointlabeler.old"
	SourceCode:	"'theview=av.finddoc(\"xyplot\")\n'thetheme=theview.findtheme(\"xtics\")\n'thelegend = thetheme.getlegend\n'symblist=thelegend.getsymbols\n'for each s in symblist\n'  msgbox.info(s.getstyle.asstring++s.getsize.asstring++s.getfont.getfamily.asstring++\"?\"++s.getfont.getstyle.asstring,\"\")\n'end\n\n\naView = av.GetActiveDoc\n\naTheme = aView.GetActiveThemes.Get(0)\nbtheme = aView.getactivethemes.get(1)\n'tp=aTheme.gettextpositioner\n'tp.SetHAlign(#TEXTPOSITIONER_HALIGN_CENTER)\n'tp.SetVAlign(#TEXTPOSITIONER_VALIGN_BELOW) \naExt = a
View.GetDisplay.ReturnVisExtent\n\naLabeler = Labeler.Make(aExt)\n\n 'These weights are the defaults for a line theme.\n\naLabeler.SetFeatureWeight(#LABEL_WEIGHT_NO)\n\naLabeler.SetLabelWeight(#LABEL_WEIGHT_HIGH)\n\naLabeler.Removeduplicates(true)\n' Set the textsymbol for the theme you are labeling\n\naTextSym = TextSymbol.Make\n\naTextSym.SetFont(Font.Make(\"Times\",\"Bold\"))\n\naTextSym.SetSize(8)\n\naTheme.SetLabelTextSym(aTextSym)\naTheme.setlabelfield(aTheme.getftab.findfield(\"id\"))\nbTheme.SetLabelTextSym(aTextSym)\nbTheme.s
etlabelfield(bTheme.getftab.findfield(\"id\"))\n\n'aFtab=aTheme.getftab\n'shapefield=aFtab.findfield(\"shape\")\n'idfield=aFtab.findfield(\"id\")\n'for each rec in aFtab\n'   pt=aFtab.returnvalue(shapefield,rec)\n'   id=aFtab.returnvalue(idfield,rec)\n'\n'  'Create some graphic text whose position is to be determined by the \n'  'TextPositioner tp \n'  aView.label(pt)\n'  'tp.Calculate(pt, gt.GetExtent, aTheme.ReturnSymbolSize(rec), nil)\n'  'gt.SetOrigin(tp.GetOrigin) \n'  'gt.SetAngle(tp.GetAngle) \n'  'aView.GetGraphics.Add(
gt)\n'end\n\n\n' This starts the labeling process and corresponds to the first\n\n' status bar you see on the application window.\naLabeler.SetLinePlacement(2)\naLabeler.Load(aTheme)\naLabeler.SetLinePlacement(1)\naLabeler.Load(btheme)\n' Get the Labels from the labeler (corresponds to the second\n\n' status bar you see on the application window) and draw them \n\n' on the view.\n\n' The GetAutoLabels request automatically adds the new labels\n\n' to the aView's GraphicList and aTheme's GraphicSet.\n\naView.GetAutoLabels(aLabel
er, false)"
)

(Script.413
	Name:	"cap.xygraph.pointstoplot"
	SourceCode:	"'#---------------------------------------------------\n' Name: cap.xygraph.pointstoplot\n'\n' Description: Get a list of points to plot -- either for\n' a precip-elevation curve or a temp-elevation curve.\n' \n' Subrouting called from cap.dlg_xygraph.plot\n'\n' History:  Created Aug. 24, 2000 by Seann M. Reed\n'#-------------------------------------------------\n\n\noutdir=Self.Get(0)\ngraphtype=Self.Get(1)\ndemgrid=Self.Get(2)  'if this plot is for a specific zone, then\n                     'the DEM grid is to be pre-cl
ipped \nvalgrid=Self.Get(3) 'value grid might be mean ann ppt or mean ann temp\nnumpts=Self.Get(4)\n\n'create a temporary Zone Grid\nsliceGrid=demGrid.Slice(#grid_slicetype_eqinterval,numpts,nil)\n'sliceGrid=demGrid.Slice(#grid_slicetype_eqarea,numpts,nil)\n'sliceTheme=Gtheme.Make(slicegrid)\n'av.GetActiveDoc.AddTheme(sliceTheme)\n\n'determine the mean elevation and mean of value grid in the sliced zones\nzoneField=slicegrid.GetVtab.FindField(\"Value\")\ndemstatfname=outdir.asfilename.maketmp(\"demstat\",\"\")\ndemStats = dem
Grid.ZonalStatsTable(slicegrid,prj.MakeNull,zoneField,false,demstatfname)\n\ndemTable=Table.Make(demStats)\n\n'create a list of points to plot\nxyList=List.Make\nif ((graphtype=\"ppt\") or (graphtype=\"tmp\")) then\n  valstatfname=outdir.asfilename.maketmp(\"valstat\",\"\")\n  valStats = valGrid.ZonalStatsTable(slicegrid,prj.MakeNull,zoneField,false,valstatfname)\n  \n  numvals=valStats.GetNumRecords\n  if (numvals<numpts) then\n     numblank=numpts-numvals\n     msgbox.warning(\"Warning: Values not available for\"++numblank.asst
ring++\"zones.\",script.the.getname)\n  end\n  \n  valTable=Table.Make(valStats)\n  \n  demMeanField=demStats.FindField(\"Mean\")\n  demidField=demStats.FindField(\"Value\")\n  valMeanField=valStats.FindField(\"Mean\")\n  validField=valStats.FindField(\"Value\")\n  valDict=Dictionary.Make(valStats.GetNumRecords)\n  for each rec in valStats\n     yid=valStats.ReturnValue(validField,rec)\n     yVal=valStats.ReturnValue(valMeanField,rec)\n     if (yVal=nil) then\n        continue\n     end\n     valDict.Add(yid,yVal)\n  end\n  for each r
ec in demStats\n     xid=demStats.ReturnValue(demidField,rec)\n     xVal=demStats.ReturnValue(demMeanField,rec)\n     if (xVal=nil) then\n        continue\n     end\n     yVal=valDict.Get(xid)\n     if (yVal=nil) then\n       continue\n     end\n     xyList.Add({xVal,yVal})\n     'outstring=outstring+xVal.Asstring++yVal.Asstring+nl\n  end\nelseif (graphtype=\"ae\") then\n  total=0\n  demMaxField=demStats.FindField(\"Max\")\n  demCountField=demStats.FindField(\"Count\")\n  for each rec in demStats\n    total=total+demStats.ReturnVa
lue(demCountfield,rec)\n  end\n  numrecs=demStats.GetNumRecords\n  cumcells=0\n  for each rec in 0..(numrecs-2)\n     xVal=demStats.ReturnValue(demMaxField,rec)\n     cumcells=cumcells+demStats.ReturnValue(demCountfield,rec)\n     yVal=(cumcells/total)*100\n     xyList.Add({xVal,yVal})\n  end    \nelse\n  msgbox.info(\"Should not see this.\",script.the.getname)\nend\n\nreturn xyList"
)

(Script.414
	Name:	"cap.xygraph.rundlg_coords"
	SourceCode:	"'#--------------------------------------------------------------\n' Name:  cap.xygraph.rundlg_coords\n' \n' Description: Run dialog that will display all coordinate points\n' \n' Dependencies: \n' History: Last modified 3/14/2000 by SMR\n'#--------------------------------------------------------------\n\ntheView=av.GetActiveDoc\nthedialog=av.GetProject.FindDialog(\"dlg_coords\")\n\ntbx_coords=thedialog.FindByName(\"tbx_coords\")\n'Display the point coordinates for selected points values for  \ntheView = av.GetActiveDoc\n\ntagL
ist=theView.GetObjectTag\nif (tagList=nil) then\n   msgbox.error(\"Error.  Try rerunning CAP --> Plot Graph\",script.the.getname)\nend\nxyList=tagList.Get(5)\n'minelv=tagList.Get(5)\n'maxelv=tagList.Get(6)\n\n'theGraphicsList=theView.GetGraphics\noutstring=\"x,y\"+nl\n'outstring=outstring+minelv.AsString+\",0\"+nl\n'stringlist=List.Make\n'count=0\n'gsel=nil\n'for each g in theGraphicsList\n\nfor each l in xyList\n  'if (g.GetObjectTag<>nil) then\n    'gTag=g.GetObjectTag\n    'if (gTag.get(0)) then\n    outstring=outstring+l.Get(0).
setformat(\"d.d\").AsString+\",\"+l.Get(1).setformat(\"d.d\").AsString+nl\n    'outstring=outstring+gTag.Get(1).AsString+\",\"+GTag.Get(2).AsString+nl\n    'stringList.Add(gTag.Get(1).AsString+\",\"+gTag.Get(2).AsString)\n    'end\n  'end\nend\n\n'outstring=outstring+maxelv.AsString+\",100\"\ntbx_coords.SetText(outstring)\n'lbx_coords.DefineFromList(stringlist)\ntheDialog.Open\n"
)

(Script.415
	Name:	"cap.xygraph.writesnow17"
	SourceCode:	"'#--------------------------------------------------------------------\n' Name:  cap.xygraph.writesnow17\n'\n' Function:  Write cards 3A and 3B required for snow 17\n'#---------------------------------------------------------------------\n\ntheView=av.GetActiveDoc\n'theGraphicsList=theView.GetGraphics\n'numpoints=0\n'elevList=List.Make\n'areaList=List.Make\n'for each g in theGraphicsList\n'  if (g.GetObjectTag<>nil) then\n'    gTag=g.GetObjectTag\n'    if (gTag.get(0)) then\n'       elevList.Add(gTag.Get(1))\n'       areaL
ist.Add(gTag.Get(2))\n'       numpoints=numpoints+1\n'    end\n'  end\n'end\n'if (numpoints>12) then\n'  msgbox.report(\"NWSRFS Allows a Maximum of 12 Points to define\" + nl +\n'  \"the area-elevation curve. (not including first and last points)\"+nl+\n'   \"You have more than 12 points. Use the Green Flag\"+nl+ \n'  \"to identify points that you wish to remove from consideration.\",script.the.getname)\n'  exit\n'end \n\n'---\ntagList=theView.GetObjectTag\nif (tagList=nil) then\n   msgbox.error(\"Error.  Try rerunning CAP --> Plot
 Graph\",script.the.getname)\nend\n\nxyList=tagList.Get(5)\n'minelv=tagList.Get(5)\n'maxelv=tagList.Get(6)\nnumpoints=xyList.Count\nminelv=xyList.Get(0).Get(0)\nmaxelv=xyList.Get(numpoints-1).Get(0)\noutstring=\"\"\n'--- Card 3A -------------------\nif ((numpoints-2)<10) then  'account for fixed format\n  outstring=outstring+String.MakeBuffer(4)+(numpoints-2).asstring\nelse\n  outstring=outstring+String.MakeBuffer(3)+(numpoints-2).asstring\nend\nminelvstr=minelv.setformat(\"d\").AsString\nmaxelvstr=maxelv.setformat(\"d\").AsString
\nbuf1=String.MakeBuffer(10-minelvstr.count)\nbuf2=String.MakeBuffer(10-maxelvstr.count)\noutstring=outstring+buf1+minelvstr+buf2+maxelvstr++\"METR\"+nl\n'** rain-snow elevation time series identifier not supplied by ArcView\n\n'--- Card 3B -- write all but min and max points\ni=0\ncardcount=1\n'msgbox.info(xyList.count.asstring,\"\")\nfor each l in xyList\n  if ((i=0) or (i=(numpoints-1))) then  'do not include min or max points \n     i=i+1\n     continue\n  end\n  if (cardcount>4) then 'make new line when num points exceed
s 4\n    outstring=outstring+nl\n    cardcount=1\n  end\n  elevstr = l.Get(0).setformat(\"d\").AsString\n  bufe = String.MakeBuffer(10-elevstr.count)\n  area = l.Get(1)\n  areafract = area / 100\n  areastr = areafract.SetFormat(\"d.dd\").AsString.Right(3)\n  outstring=outstring+bufe+elevstr+\"  \"+areastr\n  i=i+1\n  cardcount=cardcount+1\nend \n\n'prompt for an output file name\ntheProject=av.GetProject\nworkdir=theProject.GetWorkDir\nbasin_name=tagList.Get(6)\noutdir=Filename.Merge(workdir.AsString,basin_name)\noutfname=outdir.Ma
keTmp(\"mcp3A3B\",\"txt\")\noutfile=TextFile.Make(outfname,#file_perm_write)\n\noutfile.Write(outstring,outstring.count)\nmsgbox.info(\"Card 3A and 3B format written successfully to:\"++outfname.AsString,script.the.getname)"
)

(Script.416
	Name:	"capaaa.computestatistics"
	SourceCode:	"'#---------------------------------------------------------------------\n' name: cap.computestatistics\n'\n' called by: cap.dlg_stats.lbt_ok.click\n'\n' Description: function that calculates statistics\n'\n' Modified: 8/16/2000 by ZYZ\n'#----------------------------------------------------------------------\n'\n'----parameters passed from calling script\n  dat_nameStr = Self.Get(0)   'Data name string\n  bsn_idStr = Self.Get(1)     'Selected Basin ID name string\n  fieldList = Self.Get(2)     'List of fields that record
s will be added\n  dGrid = Self.Get(3)         'A grid to be processed on\n  maskgList = Self.Get(4)     'A list of mask grids for zonal calculation, default 1?\n  aVTab = Self.Get(5)         'A table that holds the records\n  \n  zones = maskgList.count    'Obtain number of zones divided\n  \n  '----Add records to the table\n  \n  \n    theMin = dGrid.getstatistics.get(0)\n    theMax = dGrid.getstatistics.get(1)\n    theMean = dGrid.GetStatistics.Get(2)\n    'theStd = dGrid.GetStatistics.Get(3)\n     \n    '---Add Record
s   \n    rec = aVTab.AddRecord\n\n    aVTab.SetValue(fieldList.Get(0),rec,dat_nameStr)\n    aVTab.SetValue(fieldList.Get(1),rec,theMean)\n    aVTab.SetValue(fieldList.Get(2),rec,theMin)\n    aVTab.SetValue(fieldList.Get(3),rec,theMax)\n    'aVTab.SetValue(fieldList.Get(4),rec,theStd)\n    \n    if (zones > 1) then\n       for each zone in 1..zones \n         ' if (maskgList.Get(zone-1).Is(grid)) then msgbox.info(\"grid OK\",\"\") end\n        \n          zGrid = dGrid * maskgList.Get(zone-1)\n          'msgbox.info(dGrid.Ge
tname++\"found\",\"\")\n          theMin = zGrid.getstatistics.get(0)\n          theMax = zGrid.getstatistics.get(1)\n          theMean = zGrid.GetStatistics.Get(2)\n          'msgbox.info(\"zone\"++zone.asstring++theMean.asstring,\"\")\n\n          field_count = zone * 4  '**This needs to be changes if new field is added\n          aVTab.SetValue(fieldList.Get(field_count),rec,nil)\n          aVTab.SetValue(fieldList.Get(field_count+1),rec,theMean)\n          aVTab.SetValue(fieldList.Get(field_count+2),rec,theMin)\n        
  aVTab.SetValue(fieldList.Get(field_count+3),rec,theMax)\n       end   \n    end   \n   \n"
)

(Script.417
	Name:	"capaaa.dlg_about.lbt_ok.click"
	SourceCode:	"'Name: cap.dlg_about.lbt_ok.click\n'\n\nSelf.GetDialog.Close"
)

(Script.418
	Name:	"capaaa.dlg_stats.lbt_ok.click"
	SourceCode:	"'#-------------------------------------------------------\n'  Name: cap.dlg_stats.lbt_ok.click\n'\n'  Description: Calculation statistics for selected grid\n'\n'  Modified:  8/15/2000 by Ziya\n'  08/29/2000\n'#-------------------------------------------------------       \n\nchkfile=linefile.make(\"/none/gis/cap/out/chkfile.txt\".asfilename,#file_perm_write)\n\npptunit=\"(in)\"\npeunit=\"(in)\"\nelvunit=\"(m)\"\n\nthedlg=av.finddialog(\"dlg_stats\")\n\n' -----Gets Sub-basin's View\n  vSub_basin = av.GetActiveDoc\n  subtagdict = vSub_ba
sin.GetObjectTag\n  workdir=av.getproject.GetWorkDir\n    \n  if (subtagdict = nil) then \n     msgbox.warning(\"Failed to getting dictionary tags for sub-basin\", \"Sub-basin Tags\")\n  end\n  \n  bsn_idstr = subtagdict.Get(\"Subbasin ID Name\").AsString\n  subbsn_datadir=workdir.Clone\n  subbsn_datadir.MergePath(bsn_idstr) \n  statname = subbsn_datadir.MakeTmp((bsn_idstr++\"stat\").Substitute(\" \",\"s\"),\"dbf\")\n  '------Because of the name restriction, only \"s\" is added after the basin ID\n\n'----Check if the basin is sub-divid
ed into zones and create masks for zones\n  zTheme = subtagdict.Get(\"Subbasin Zone Grid\")  \n  maskList = List.Make\n  maskList = {} 'Initialize the maskList\n  if (zTheme=nil) then\n     num_zone = 1\n     msgbox.info(\"There will be no zonal info\",\"\")\n  else   \n     zGrid = zTheme.GetGrid\n     if(zGrid.Is(grid).not) then \n        msgbox.info(\"Zone Grid Error\",\"\") \n        return nil\n        thedlg.close \n     end \n     zVTab = zGrid.GetVTab\n     num_zone = zVTab.GetNumRecords   'Get number of zones\n     for each
 zone in 1..num_zone\n        zmask = (zGrid <> zone).SetNull(1.AsGrid)\n        maskList.Add(zmask)\n     end\n  end      \n     \n \n'-----Define month name list for easy read \n    monList = {\"Jan\",\"Feb\",\"Mar\",\"Apr\",\"May\",\"Jun\",\"Jul\",\"Aug\",\"Sep\",\"Oct\",\"Nov\",\"Dec\"}\n    monListLong = {\"January\",\"Feburary\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\"} \n    'monList = {\"Jan\",\"Feb\",\"Mar\", \"Apr\"} '--*****Temp use, uncomment for final version\n'---Create a table to hold statis
tics data\n    fieldList = List.Make\n    fieldList.Add(Field.Make(\"Data Name\", #FIELD_CHAR, 18, 0))\n    fieldList.Add(Field.Make(\"Basin Mean\", #FIELD_FLOAT, 10, 2))    \n    fieldList.Add(Field.Make(\"Basin Min\", #FIELD_FLOAT, 10, 2))\n    fieldList.Add(Field.Make(\"Basin Max\", #FIELD_FLOAT, 10, 2))\n\n    if (num_zone > 1) then\n        for each zone in 1..num_zone\n           fieldList.Add(Field.Make(\" \",#FIELD_VCHAR,1,0))\n           fieldList.Add(Field.Make(\"Zone\"+zone.AsString++\"Mean\", #FIELD_FLOAT, 10, 2))\n    
       fieldList.Add(Field.Make(\"Zone\"+zone.AsString++\"Min\", #FIELD_FLOAT, 10, 2))\n           fieldList.Add(Field.Make(\"Zone\"+zone.AsString++\"Max\", #FIELD_FLOAT, 10, 2))\n        end  \n    end           \n    \n    statVTab = VTab.MakeNew(statname,dbase)\n    if (statVTab.HasError) then \n        msgbox.info(\"Vtab has an error\",\"Vtab error\") \n        return nil\n        thedlg.close \n    end\n  \n    statVTab.AddFields(fieldList)\n'---Show table info --->Moved to the end    \n'    statTable = Table.Make(statVTab)\n'  
  statTable.SetName(\"Statistics:\"++bsn_idstr.Ucase)  'Rename the table name\n     \n\n'---Determine seasonal start/end info\n  compute_seasonal=false\n  if ((theDlg.FindByName(\"chk_ppt_sea\").IsSelected) or (theDlg.FindByName(\"chk_tmp_sea\").IsSelected) or (theDlg.FindByName(\"chk_pe_sea\").IsSelected)) then\n     compute_seasonal=true\n     wfrom = theDlg.FindByName(\"cbx_winter_from\").GetCurrentRow\n     wto = theDlg.FindByName(\"cbx_winter_to\").GetCurrentRow\n     \n     sfromstring = theDlg.FindByName(\"txl_summer_from\"
).GetText\n     stostring = theDlg.FindByName(\"txl_summer_to\").GetText\n     \n     'if winter is selected as the entire season, the sfrom and sto strings will be zero length\n     if ((sfromstring.count=0) or (stostring.count=0)) then\n        compute_seasonal=false\n     else\n        sfrom = monListLong.FindByValue(sfromstring)\n        sto = monListLong.FindByValue(stostring)\n        chkfile.writeelt(wfrom.asstring++wto.asstring++sfrom.asstring++sto.asstring)\n     end\n     'if (wfrom = wto) then msgbox.info(\"Wi
nter Season Month Selection Error\",\"Winter: From = To\") return nil thedlg.close end\n     'if (sfrom >= sto) then msgbox.info(\"Summer Season Month Selection Error\",\"Summer: From = To\") return nil thedlg.close end\n     if (compute_seasonal) then\n        wlist=List.Make\n        slist=List.Make\n        wlist.Add(wfrom)\n        slist.Add(sfrom)\n        while (wfrom<>wto)\n            wfrom=wfrom + 1\n            if (wfrom>11) then\n               wfrom=0\n            end\n            wlist.add(wfrom)\n        end\n    
    while (sfrom<>sto)\n            sfrom=sfrom + 1\n            if (sfrom>11) then\n               sfrom=0\n            end\n            slist.add(sfrom)\n        end     \n     end\n   end\n   \n  \n'----Add calculated statistics to the table's records\n  '----Elevation\n    if (theDlg.FindByName(\"chk_elev\").IsSelected) then\n       dataTheme = subtagdict.Get(\"Subbasin Elevation\")  \n       dataGrid = dataTheme.GetGrid    \n       av.run(\"cap.computestatistics\",{\"Elevation\"++elvunit,bsn_idstr,fieldList,dataGrid,maskList,
statVTab})\n    end     \n   \n  '----annual precipitation\n  if (theDlg.FindByName(\"chk_ppt_ann\").IsSelected) then\n    dataTheme = subtagdict.Get(\"Subbasin Mean Annual Ppt\")  \n    dataGrid = dataTheme.GetGrid\n    av.run(\"cap.computestatistics\",{\"Annual Precip\"++pptunit,bsn_idstr,fieldList,dataGrid,maskList,statVTab})\n  end\n     \n  '----Calculate monthly precipitation statistics \n  if (theDlg.FindByName(\"chk_ppt_mon\").IsSelected) then\n    moncount = 0\n    for each month in 0 .. (monList.Count-1)\n      mon_pptFN
 = subtagdict.Get(\"Subbasin Monthly Ppt\").Get(month)\n                               \n      if (mon_pptFN=nil) then\n         chk=msgbox.yesno(\"Warning: Could not find data for the month of \"++monList.Get(month)++\".  Continue?\",script.the.getname,true)\n         if (chk = true) then continue else return nil thedlg.close end\n      end   \n\n      tmpSrcName = Grid.MakeSrcName(mon_pptFN.AsString)\n      tmpSrcGrid = Grid.Make(tmpSrcName)\n      dataGrid = tmpSrcGrid\n      av.run(\"cap.computestatistics\",{\"   Precip--
>\"+monList.Get(month),bsn_idstr,fieldList,dataGrid,maskList,statVTab})\n      moncount = moncount + 1\n    end\n  end  \n  \n  '---Calculate seasonal precipitation statistics\n  if ((theDlg.FindByName(\"chk_ppt_sea\").IsSelected) and (compute_seasonal)) then\n\n     '----Winter Period\n     dataGrid = 0.AsGrid\n        \n     for each wmon in wlist\n        mon_pptFN = subtagdict.Get(\"Subbasin Monthly Ppt\").Get(wmon)\n        if (mon_pptFN=nil) then\n          chk=msgbox.yesno(\"Warning: Data for the month of \"++monList.Get
(wmon)++\"is missing.  Continue?\",script.the.getname,true)\n          if (chk = true) then continue else return nil thedlg.close end\n        end   \n        tmpSrcName = Grid.MakeSrcName(mon_pptFN.AsString)\n        tmpSrcGrid = Grid.Make(tmpSrcName)\n        dataGrid = dataGrid + tmpSrcGrid\n     end\n     \n     av.run(\"cap.computestatistics\",{\"   Ppt-->Winter\",bsn_idstr,fieldList,dataGrid,maskList,statVTab})\n      \n     '----For Summer season\n     dataGrid = 0.AsGrid\n     for each smon in slist\n        mon_pptFN
 = subtagdict.Get(\"Subbasin Monthly Ppt\").Get(smon)\n        if (mon_pptFN=nil) then\n          chk=msgbox.yesno(\"Warning: Could not find data for the month of \"++monList.Get(smon)++\".  Continue?\",script.the.getname,true)\n          if (chk = true) then continue else return nil thedlg.close end\n        end   \n        tmpSrcName = Grid.MakeSrcName(mon_pptFN.AsString)\n        tmpSrcGrid = Grid.Make(tmpSrcName)\n        'dataGrid = tmpSrcGrid\n        dataGrid = dataGrid + tmpSrcGrid\n     end\n     av.run(\"cap.compu
testatistics\",{\"   Ppt-->Summer\",bsn_idstr,fieldList,dataGrid,maskList,statVTab})\n  end\n  \n '---Other selections \n \n'*** Temperature data analysis \n'    if (theDlg.FindByName(\"chk_tmp_ann\").IsSelected) then\n'       dataTheme = subtagdict.Get(\"Subbasin Mean Annual Tmp\")\n'    end\n\n'***** PE data analysis  \n  '----annual PE\n  if (theDlg.FindByName(\"chk_pe_ann\").IsSelected) then\n    dataTheme = subtagdict.Get(\"Subbasin Annual PE\")  \n    dataGrid = dataTheme.GetGrid\n    av.run(\"cap.computestatistics\",{\"Annual PE
\"++peunit,bsn_idstr,fieldList,dataGrid,maskList,statVTab})\n  end\n     \n  '----Calculate monthly pe statistics \n  if (theDlg.FindByName(\"chk_pe_mon\").IsSelected) then\n    moncount = 0\n    for each month in 0 .. (monList.Count-1)\n      mon_peFN = subtagdict.Get(\"Subbasin Monthly PE\").Get(month)\n                               \n      if (mon_peFN=nil) then\n         chk=msgbox.yesno(\"Warning: Could not find pe data for the month of \"++monList.Get(month)++\".  Continue?\",script.the.getname,true)\n         if (chk =
 true) then continue else return nil thedlg.close end\n      end   \n\n      tmpSrcName = Grid.MakeSrcName(mon_peFN.AsString)\n      tmpSrcGrid = Grid.Make(tmpSrcName)\n      dataGrid = tmpSrcGrid\n      av.run(\"cap.computestatistics\",{\"   PE-->\"+monList.Get(month),bsn_idstr,fieldList,dataGrid,maskList,statVTab})\n      moncount = moncount + 1\n    end\n  end  \n  \n  '---Calculate seasonal pe statistics\n  if ((theDlg.FindByName(\"chk_pe_sea\").IsSelected) and (compute_seasonal)) then\n\n     '----PE Winter Period\n     da
taGrid = 0.AsGrid\n     for each wmon in wlist\n          mon_peFN = subtagdict.Get(\"Subbasin Monthly PE\").Get(wmon)\n          if (mon_peFN=nil) then\n            chk=msgbox.yesno(\"Warning: PE data for the month of \"++monList.Get(wmon)++\"is missing.  Continue?\",script.the.getname,true)\n            if (chk = true) then continue else return nil thedlg.close end\n          end   \n  \n          tmpSrcName = Grid.MakeSrcName(mon_peFN.AsString)\n          tmpSrcGrid = Grid.Make(tmpSrcName)\n          dataGrid = dataGrid
 + tmpSrcGrid\n      end\n        av.run(\"cap.computestatistics\",{\"   PE-->Winter\",bsn_idstr,fieldList,dataGrid,maskList,statVTab})\n     \n      \n     '----PE  Summer season\n   \n       dataGrid = 0.AsGrid\n       for each smon in slist\n          mon_peFN = subtagdict.Get(\"Subbasin Monthly PE\").Get(smon)\n          if (mon_peFN=nil) then\n            chk=msgbox.yesno(\"Warning: Could not find pe data for the month of \"++monList.Get(smon)++\".  Continue?\",script.the.getname,true)\n            if (chk = true) then cont
inue else return nil thedlg.close end\n          end   \n          tmpSrcName = Grid.MakeSrcName(mon_peFN.AsString)\n          tmpSrcGrid = Grid.Make(tmpSrcName)\n          dataGrid = dataGrid + tmpSrcGrid\n       end\n       av.run(\"cap.computestatistics\",{\"   PE-->Summer\",bsn_idstr,fieldList,dataGrid,maskList,statVTab})\n    \n  end\n\n\n'***Forest Percent Cover analysis  --> See zonal info through standard ARC/View user interface\n'---Add a 'percent' field to the Vtab ( a separate table for forest ) besides 'value' 
'count')\n if (theDlg.FindByName(\"chk_forest\").IsSelected) then\n    dataTheme = subtagdict.Get(\"Subbasin Forest Percent Cover\")\n    dataGrid = dataTheme.GetGrid\n     av.run(\"cap.computestatistics\",{\"Forest Cover (pct)\",bsn_idstr,fieldList,dataGrid,maskList,statVTab})\n           \n end\n  \n\n'***Detailed Forest Type analysis\n'--- A separate forest type grid and corresponding vtab must be\n'--- created for each zone  \n  if (theDlg.FindByName(\"chk_detforest\").IsSelected) then\n    detmsg=\"\"\n    dataTheme = subtagdic
t.Get(\"Subbasin Detailed Forest Type\")\n    dataGrid = dataTheme.GetGrid\n    pct_return=av.run(\"cap.addpctfield\",{dataGrid,bsn_idstr})\n    if (pct_return<>nil) then\n      detmsg=detmsg+pct_return\n    end\n    zones=maskList.Count\n    if (zones > 1) then\n       for each zone in 1..zones  \n          zGrid = dataGrid * maskList.Get(zone-1)\n          idstr=bsn_idstr++\"Zone\"++zone.asstring\n          pct_return=av.run(\"cap.addpctfield\",{zGrid,idstr})\n          if (pct_return<>nil) then\n             detmsg=detmsg+nl
+pct_return\n          end\n       end\n    end            \n      \n  end\n    \n'----Show the statistics table in the main project/table window\n    statTable = Table.Make(statVTab)\n    'Rename the table name\n    outname=\"Statistics:\"++bsn_idstr.Ucase\n    outTable=av.FindDoc(outname)\n    'if a stats table already exists, rename to reflect current time\n    if (outTable<>nil) then\n      outname=outname++Date.Now.Asstring\n    end\n    statTable.SetName(outname)    \n    \n    msg=\"Statistics calculations are complete.\"
+nl+\"Results are in the Table:\"+outname\n    if (theDlg.FindByName(\"chk_detforest\").IsSelected) then\n       msg=msg+nl+\"Detailed Forest Tables:\"+nl+detmsg\n    end \n    \n    msgbox.report(msg,script.the.getname)\n    \n    statTable.GetWin.Activate\n\nthedlg.close"
)

(Script.419
	Name:	"capaaa.engtometric"
	SourceCode:	"'msgbox.info(self.geticon.getname,\"\")\nself.seticon(Icon.MakeFromResname(\"Icons.M\"))\n'msgbox.info(self.geticon.getname,\"\")\n\n"
)

(Script.420
	Name:	"fmap.setdefineinfo.click"
	SourceCode:	"'theDictionary=SELF.get(0)\n'anFtab=SELF.get(1)\n'r=SELF.get(2)\n'theTypeList={}\n'theValueList={}\n'theTotalList={}\n'\n'theBasinId=theDictionary.Get(\"BASINID\")\n'theBasinDescription=theDictionary.Get(\"BASINDESCRIPTION\")\n''***if theBasinMeanElevation is defined, it is the name of the dem for computing basin mean***'\n'theBasinMeanElevation=theDictionary.Get(\"BASINMEANELEVATION\") \n'      \n'   if(theBasinId=\"\")then\n'      bsnidFName=theDictionary.Get(\"BASINIDFIELD\")\n'      bsnidField=anFtab.FindField(bsnidFName)\n'   
   theType=bsnidField.getType\n'      theWidth=bsnidField.getWidth\n'      thePrecision=bsnidField.getPrecision\n'      theTypeList.Add(bsnidFName)\n'      theTypeList.Add(theType)\n'      theTypeList.Add(theWidth)\n'      theTypeList.Add(thePrecision)\n'      theValueList.Add(anFtab.ReturnValue(bsnidField,r))\n'   else\n'      bsnidFName=\"\"\n'      bsnidField=\"\"\n'   end\n'   if(theBasinDescription=\"\")then\n'      bsndescrFName=theDictionary.Get(\"BASINDESCRIPTIONFIELD\")\n'      bsndescrField=anFtab.FindField(bsndescrFNa
me)\n'      theType=bsndescrField.getType\n'      theWidth=bsndescrField.getWidth\n'      thePrecision=bsnDescrField.getPrecision\n'      theTypeList.Add(bsndescrFName)\n'      theTypeList.Add(theType)\n'      theTypeList.Add(theWidth)\n'      theTypeList.Add(thePrecision)\n'      theValueList.Add(anFtab.ReturnValue(bsndescrField,r))\n'   else\n'      bsndescrFName=\"\"\n'      bsndescrField=\"\"\n'   end\n'   if(theBasinMeanElevation=\"\")then\n'      bsnmeanelevationFName=theDictionary.Get(\"BASINMEANELEVATIONFIELD\")\n'      b
snmeanelevationField=anFtab.FindField(bsnmeanelevationFName)\n'      theType=bsnmeanelevationField.getType\n'      theWidth=bsnmeanelevationField.getWidth\n'      thePrecision=bsnmeanelevationField.getPrecision\n'      theTypeList.Add(bsnmeanelevationFName)\n'      theTypeList.Add(theType)\n'      theTypeList.Add(theWidth)\n'      theTypeList.Add(thePrecision)\n'      theValueList.Add(anFtab.ReturnValue(bsnmeanelevationField,r))  \n'   else\n'      bsnmeanelevationFName=\"\"\n'      bsnmeanelevationField=\"\"\n'   end\n'  \n
'   if(bsnidField=Nil)then\n'      msgBox.Error(\"A proper basin id field was not defined\",\"Error\")\n'      exit\n'   end\n'\n'   if(bsndescrField=Nil)then\n'      msgBox.Error(\"A proper basin description field was not defined\",\"Error\")\n'      exit\n'   end\n'\n'   if(bsnmeanelevationField=Nil)then\n'      msgBox.Error(\"A proper basin mean elevation field was not defined\",\"Error\")\n'      exit\n'   end\n'theTotalList.Add(theTypeList)\n'theTotalList.Add(theValueList)\n'return theTotalList\n\n"
)

(Script.421
	Name:	"fmap.setdeleteinfo.click"
	SourceCode:	"'theDictionary=SELF.get(0)\n'anFtab=SELF.get(1)\n'r=SELF.get(2)\n'theTypeList={}\n'theValueList={}\n'theTotalList={}\n'\n'theBasinId=theDictionary.Get(\"BASINID\")\n'theBasinDescription=theDictionary.Get(\"BASINDESCRIPTION\")\n''***if theBasinMeanElevation is defined, it is the name of the dem for computing basin mean***'\n'theBasinMeanElevation=theDictionary.Get(\"BASINMEANELEVATION\") \n'      \n'   if(theBasinId=\"\")then\n'      bsnidFName=theDictionary.Get(\"BASINIDFIELD\")\n'      bsnidField=anFtab.FindField(bsnidFName)\n'   
   theType=bsnidField.getType\n'      theWidth=bsnidField.getWidth\n'      thePrecision=bsnidField.getPrecision\n'      theTypeList.Add(bsnidFName)\n'      theTypeList.Add(theType)\n'      theTypeList.Add(theWidth)\n'      theTypeList.Add(thePrecision)\n'      theValueList.Add(anFtab.ReturnValue(bsnidField,r))\n'   else\n'      bsnidFName=\"\"\n'      bsnidField=\"\"\n'   end\n'   if(theBasinDescription=\"\")then\n'      bsndescrFName=theDictionary.Get(\"BASINDESCRIPTIONFIELD\")\n'      bsndescrField=anFtab.FindField(bsndescrFNa
me)\n'      theType=bsndescrField.getType\n'      theWidth=bsndescrField.getWidth\n'      thePrecision=bsnDescrField.getPrecision\n'      theTypeList.Add(bsndescrFName)\n'      theTypeList.Add(theType)\n'      theTypeList.Add(theWidth)\n'      theTypeList.Add(thePrecision)\n'      theValueList.Add(anFtab.ReturnValue(bsndescrField,r))\n'   else\n'      bsndescrFName=\"\"\n'      bsndescrField=\"\"\n'   end\n'   if(theBasinMeanElevation=\"\")then\n'      bsnmeanelevationFName=theDictionary.Get(\"BASINMEANELEVATIONFIELD\")\n'      b
snmeanelevationField=anFtab.FindField(bsnmeanelevationFName)\n'      theType=bsnmeanelevationField.getType\n'      theWidth=bsnmeanelevationField.getWidth\n'      thePrecision=bsnmeanelevationField.getPrecision\n'      theTypeList.Add(bsnmeanelevationFName)\n'      theTypeList.Add(theType)\n'      theTypeList.Add(theWidth)\n'      theTypeList.Add(thePrecision)\n'      theValueList.Add(anFtab.ReturnValue(bsnmeanelevationField,r))  \n'   else\n'      bsnmeanelevationFName=\"\"\n'      bsnmeanelevationField=\"\"\n'   end\n'  \n
'   if(bsnidField=Nil)then\n'      msgBox.Error(\"A proper basin id field was not defined\",\"Error\")\n'      exit\n'   end\n'\n'   if(bsndescrField=Nil)then\n'      msgBox.Error(\"A proper basin description field was not defined\",\"Error\")\n'      exit\n'   end\n'\n'   if(bsnmeanelevationField=Nil)then\n'      msgBox.Error(\"A proper basin mean elevation field was not defined\",\"Error\")\n'      exit\n'   end\n'theTotalList.Add(theTypeList)\n'theTotalList.Add(theValueList)\n'return theTotalList\n\n"
)

(Script.422
	Name:	"fmap.setdumpinfo.click"
	SourceCode:	"'theDictionary=SELF.get(0)\n'anFtab=SELF.get(1)\n'r=SELF.get(2)\n'theTypeList={}\n'theValueList={}\n'theTotalList={}\n'\n'theBasinId=theDictionary.Get(\"BASINID\")\n'theBasinDescription=theDictionary.Get(\"BASINDESCRIPTION\")\n''***if theBasinMeanElevation is defined, it is the name of the dem for computing basin mean***'\n'theBasinMeanElevation=theDictionary.Get(\"BASINMEANELEVATION\") \n'      \n'   if(theBasinId=\"\")then\n'      bsnidFName=theDictionary.Get(\"BASINIDFIELD\")\n'      bsnidField=anFtab.FindField(bsnidFName)\n'   
   theType=bsnidField.getType\n'      theWidth=bsnidField.getWidth\n'      thePrecision=bsnidField.getPrecision\n'      theTypeList.Add(bsnidFName)\n'      theTypeList.Add(theType)\n'      theTypeList.Add(theWidth)\n'      theTypeList.Add(thePrecision)\n'      theValueList.Add(anFtab.ReturnValue(bsnidField,r))\n'   else\n'      bsnidFName=\"\"\n'      bsnidField=\"\"\n'   end\n'   if(theBasinDescription=\"\")then\n'      bsndescrFName=theDictionary.Get(\"BASINDESCRIPTIONFIELD\")\n'      bsndescrField=anFtab.FindField(bsndescrFNa
me)\n'      theType=bsndescrField.getType\n'      theWidth=bsndescrField.getWidth\n'      thePrecision=bsnDescrField.getPrecision\n'      theTypeList.Add(bsndescrFName)\n'      theTypeList.Add(theType)\n'      theTypeList.Add(theWidth)\n'      theTypeList.Add(thePrecision)\n'      theValueList.Add(anFtab.ReturnValue(bsndescrField,r))\n'   else\n'      bsndescrFName=\"\"\n'      bsndescrField=\"\"\n'   end\n'   if(theBasinMeanElevation=\"\")then\n'      bsnmeanelevationFName=theDictionary.Get(\"BASINMEANELEVATIONFIELD\")\n'      b
snmeanelevationField=anFtab.FindField(bsnmeanelevationFName)\n'      theType=bsnmeanelevationField.getType\n'      theWidth=bsnmeanelevationField.getWidth\n'      thePrecision=bsnmeanelevationField.getPrecision\n'      theTypeList.Add(bsnmeanelevationFName)\n'      theTypeList.Add(theType)\n'      theTypeList.Add(theWidth)\n'      theTypeList.Add(thePrecision)\n'      theValueList.Add(anFtab.ReturnValue(bsnmeanelevationField,r))  \n'   else\n'      bsnmeanelevationFName=\"\"\n'      bsnmeanelevationField=\"\"\n'   end\n'  \n
'   if(bsnidField=Nil)then\n'      msgBox.Error(\"A proper basin id field was not defined\",\"Error\")\n'      exit\n'   end\n'\n'   if(bsndescrField=Nil)then\n'      msgBox.Error(\"A proper basin description field was not defined\",\"Error\")\n'      exit\n'   end\n'\n'   if(bsnmeanelevationField=Nil)then\n'      msgBox.Error(\"A proper basin mean elevation field was not defined\",\"Error\")\n'      exit\n'   end\n'theTotalList.Add(theTypeList)\n'theTotalList.Add(theValueList)\n'return theTotalList\n'\n"
)

(Script.423
	Name:	"mape.setdefineinfo.click"
	SourceCode:	"theDictionary=SELF.get(0)\nanFtab=SELF.get(1)\nr=SELF.get(2)\ntheTypeList={}\ntheValueList={}\ntheTotalList={}\n\ntheBasinId=theDictionary.Get(\"BASINID\")\ntheBasinDescription=theDictionary.Get(\"BASINDESCRIPTION\")\n'***if theBasinMeanElevation is defined, it is the name of the dem for computing basin mean***'\ntheBasinMeanElevation=theDictionary.Get(\"BASINMEANELEVATION\") \n      \n   if(theBasinId=\"\")then\n      bsnidFName=theDictionary.Get(\"BASINIDFIELD\")\n      bsnidField=anFtab.FindField(bsnidFName)\n      theType=bsnid
Field.getType\n      theWidth=bsnidField.getWidth\n      thePrecision=bsnidField.getPrecision\n      theTypeList.Add(bsnidFName)\n      theTypeList.Add(theType)\n      theTypeList.Add(theWidth)\n      theTypeList.Add(thePrecision)\n      theValueList.Add(anFtab.ReturnValue(bsnidField,r))\n   else\n      bsnidFName=\"\"\n      bsnidField=\"\"\n   end\n   if(theBasinDescription=\"\")then\n      bsndescrFName=theDictionary.Get(\"BASINDESCRIPTIONFIELD\")\n      bsndescrField=anFtab.FindField(bsndescrFName)\n      theType=bsndescrFiel
d.getType\n      theWidth=bsndescrField.getWidth\n      thePrecision=bsnDescrField.getPrecision\n      theTypeList.Add(bsndescrFName)\n      theTypeList.Add(theType)\n      theTypeList.Add(theWidth)\n      theTypeList.Add(thePrecision)\n      theValueList.Add(anFtab.ReturnValue(bsndescrField,r))\n   else\n      bsndescrFName=\"\"\n      bsndescrField=\"\"\n   end\n   if(theBasinMeanElevation=\"\")then\n      bsnmeanelevationFName=theDictionary.Get(\"BASINMEANELEVATIONFIELD\")\n      bsnmeanelevationField=anFtab.FindField(bsnmean
elevationFName)\n      theType=bsnmeanelevationField.getType\n      theWidth=bsnmeanelevationField.getWidth\n      thePrecision=bsnmeanelevationField.getPrecision\n      theTypeList.Add(bsnmeanelevationFName)\n      theTypeList.Add(theType)\n      theTypeList.Add(theWidth)\n      theTypeList.Add(thePrecision)\n      theValueList.Add(anFtab.ReturnValue(bsnmeanelevationField,r))  \n   else\n      bsnmeanelevationFName=\"\"\n      bsnmeanelevationField=\"\"\n   end\n  \n   if(bsnidField=Nil)then\n      msgBox.Error(\"A proper bas
in id field was not defined\",\"Error\")\n      exit\n   end\n\n   if(bsndescrField=Nil)then\n      msgBox.Error(\"A proper basin description field was not defined\",\"Error\")\n      exit\n   end\n\n   if(bsnmeanelevationField=Nil)then\n      msgBox.Error(\"A proper basin mean elevation field was not defined\",\"Error\")\n      exit\n   end\ntheTotalList.Add(theTypeList)\ntheTotalList.Add(theValueList)\nreturn theTotalList\n\n"
)

(Script.424
	Name:	"mape.setdeleteinfo.click"
	SourceCode:	"theDictionary=SELF.get(0)\nanFtab=SELF.get(1)\nr=SELF.get(2)\ntheTypeList={}\ntheValueList={}\ntheTotalList={}\n\ntheBasinId=theDictionary.Get(\"BASINID\")\ntheBasinDescription=theDictionary.Get(\"BASINDESCRIPTION\")\n'***if theBasinMeanElevation is defined, it is the name of the dem for computing basin mean***'\ntheBasinMeanElevation=theDictionary.Get(\"BASINMEANELEVATION\") \n      \n   if(theBasinId=\"\")then\n      bsnidFName=theDictionary.Get(\"BASINIDFIELD\")\n      bsnidField=anFtab.FindField(bsnidFName)\n      theType=bsnid
Field.getType\n      theWidth=bsnidField.getWidth\n      thePrecision=bsnidField.getPrecision\n      theTypeList.Add(bsnidFName)\n      theTypeList.Add(theType)\n      theTypeList.Add(theWidth)\n      theTypeList.Add(thePrecision)\n      theValueList.Add(anFtab.ReturnValue(bsnidField,r))\n   else\n      bsnidFName=\"\"\n      bsnidField=\"\"\n   end\n   if(theBasinDescription=\"\")then\n      bsndescrFName=theDictionary.Get(\"BASINDESCRIPTIONFIELD\")\n      bsndescrField=anFtab.FindField(bsndescrFName)\n      theType=bsndescrFiel
d.getType\n      theWidth=bsndescrField.getWidth\n      thePrecision=bsnDescrField.getPrecision\n      theTypeList.Add(bsndescrFName)\n      theTypeList.Add(theType)\n      theTypeList.Add(theWidth)\n      theTypeList.Add(thePrecision)\n      theValueList.Add(anFtab.ReturnValue(bsndescrField,r))\n   else\n      bsndescrFName=\"\"\n      bsndescrField=\"\"\n   end\n   if(theBasinMeanElevation=\"\")then\n      bsnmeanelevationFName=theDictionary.Get(\"BASINMEANELEVATIONFIELD\")\n      bsnmeanelevationField=anFtab.FindField(bsnmean
elevationFName)\n      theType=bsnmeanelevationField.getType\n      theWidth=bsnmeanelevationField.getWidth\n      thePrecision=bsnmeanelevationField.getPrecision\n      theTypeList.Add(bsnmeanelevationFName)\n      theTypeList.Add(theType)\n      theTypeList.Add(theWidth)\n      theTypeList.Add(thePrecision)\n      theValueList.Add(anFtab.ReturnValue(bsnmeanelevationField,r))  \n   else\n      bsnmeanelevationFName=\"\"\n      bsnmeanelevationField=\"\"\n   end\n  \n   if(bsnidField=Nil)then\n      msgBox.Error(\"A proper bas
in id field was not defined\",\"Error\")\n      exit\n   end\n\n   if(bsndescrField=Nil)then\n      msgBox.Error(\"A proper basin description field was not defined\",\"Error\")\n      exit\n   end\n\n   if(bsnmeanelevationField=Nil)then\n      msgBox.Error(\"A proper basin mean elevation field was not defined\",\"Error\")\n      exit\n   end\ntheTotalList.Add(theTypeList)\ntheTotalList.Add(theValueList)\nreturn theTotalList\n\n"
)

(Script.425
	Name:	"mape.setdumpinfo.click"
	SourceCode:	"theDictionary=SELF.get(0)\nanFtab=SELF.get(1)\nr=SELF.get(2)\ntheTypeList={}\ntheValueList={}\ntheTotalList={}\n\ntheBasinId=theDictionary.Get(\"BASINID\")\ntheBasinDescription=theDictionary.Get(\"BASINDESCRIPTION\")\n'***if theBasinMeanElevation is defined, it is the name of the dem for computing basin mean***'\ntheBasinMeanElevation=theDictionary.Get(\"BASINMEANELEVATION\") \n      \n   if(theBasinId=\"\")then\n      bsnidFName=theDictionary.Get(\"BASINIDFIELD\")\n      bsnidField=anFtab.FindField(bsnidFName)\n      theType=bsnid
Field.getType\n      theWidth=bsnidField.getWidth\n      thePrecision=bsnidField.getPrecision\n      theTypeList.Add(bsnidFName)\n      theTypeList.Add(theType)\n      theTypeList.Add(theWidth)\n      theTypeList.Add(thePrecision)\n      theValueList.Add(anFtab.ReturnValue(bsnidField,r))\n   else\n      bsnidFName=\"\"\n      bsnidField=\"\"\n   end\n   if(theBasinDescription=\"\")then\n      bsndescrFName=theDictionary.Get(\"BASINDESCRIPTIONFIELD\")\n      bsndescrField=anFtab.FindField(bsndescrFName)\n      theType=bsndescrFiel
d.getType\n      theWidth=bsndescrField.getWidth\n      thePrecision=bsnDescrField.getPrecision\n      theTypeList.Add(bsndescrFName)\n      theTypeList.Add(theType)\n      theTypeList.Add(theWidth)\n      theTypeList.Add(thePrecision)\n      theValueList.Add(anFtab.ReturnValue(bsndescrField,r))\n   else\n      bsndescrFName=\"\"\n      bsndescrField=\"\"\n   end\n   if(theBasinMeanElevation=\"\")then\n      bsnmeanelevationFName=theDictionary.Get(\"BASINMEANELEVATIONFIELD\")\n      bsnmeanelevationField=anFtab.FindField(bsnmean
elevationFName)\n      theType=bsnmeanelevationField.getType\n      theWidth=bsnmeanelevationField.getWidth\n      thePrecision=bsnmeanelevationField.getPrecision\n      theTypeList.Add(bsnmeanelevationFName)\n      theTypeList.Add(theType)\n      theTypeList.Add(theWidth)\n      theTypeList.Add(thePrecision)\n      theValueList.Add(anFtab.ReturnValue(bsnmeanelevationField,r))  \n   else\n      bsnmeanelevationFName=\"\"\n      bsnmeanelevationField=\"\"\n   end\n  \n   if(bsnidField=Nil)then\n      msgBox.Error(\"A proper bas
in id field was not defined\",\"Error\")\n      exit\n   end\n\n   if(bsndescrField=Nil)then\n      msgBox.Error(\"A proper basin description field was not defined\",\"Error\")\n      exit\n   end\n\n   if(bsnmeanelevationField=Nil)then\n      msgBox.Error(\"A proper basin mean elevation field was not defined\",\"Error\")\n      exit\n   end\ntheTotalList.Add(theTypeList)\ntheTotalList.Add(theValueList)\nreturn theTotalList\n\n"
)

(Script.426
	Name:	"mapx.addfields"
	SourceCode:	"theDictionary=SELF.get(0)\nanFtab=SELF.get(1)\nr=SELF.get(2)\ntheTypeList={}\ntheValueList={}\ntheTotalList={}\n\ntheBasinId=theDictionary.Get(\"BASINID\")\ntheBasinDescription=theDictionary.Get(\"BASINDESCRIPTION\")\n'***if theBasinMeanElevation is defined, it is the name of the dem for computing basin mean***'\ntheBasinMeanElevation=theDictionary.Get(\"BASINMEANELEVATION\") \n      \n   if(theBasinId=\"\")then\n      bsnidFName=theDictionary.Get(\"BASINIDFIELD\")\n      bsnidField=anFtab.FindField(bsnidFName)\n      theType=bsnid
Field.getType\n      theWidth=bsnidField.getWidth\n      thePrecision=bsnidField.getPrecision\n      theTypeList.Add(bsnidFName)\n      theTypeList.Add(theType)\n      theTypeList.Add(theWidth)\n      theTypeList.Add(thePrecision)\n      theValueList.Add(anFtab.ReturnValue(bsnidField,r))\n   else\n      bsnidFName=\"\"\n      bsnidField=\"\"\n   end\n   if(theBasinDescription=\"\")then\n      bsndescrFName=theDictionary.Get(\"BASINDESCRIPTIONFIELD\")\n      bsndescrField=anFtab.FindField(bsndescrFName)\n      theType=bsndescrFiel
d.getType\n      theWidth=bsndescrField.getWidth\n      thePrecision=bsnDescrField.getPrecision\n      theTypeList.Add(bsndescrFName)\n      theTypeList.Add(theType)\n      theTypeList.Add(theWidth)\n      theTypeList.Add(thePrecision)\n      theValueList.Add(anFtab.ReturnValue(bsndescrField,r))\n   else\n      bsndescrFName=\"\"\n      bsndescrField=\"\"\n   end\n   if(theBasinMeanElevation=\"\")then\n      bsnmeanelevationFName=theDictionary.Get(\"BASINMEANELEVATIONFIELD\")\n      bsnmeanelevationField=anFtab.FindField(bsnmean
elevationFName)\n      theType=bsnmeanelevationField.getType\n      theWidth=bsnmeanelevationField.getWidth\n      thePrecision=bsnmeanelevationField.getPrecision\n      theTypeList.Add(bsnmeanelevationFName)\n      theTypeList.Add(theType)\n      theTypeList.Add(theWidth)\n      theTypeList.Add(thePrecision)\n      theValueList.Add(anFtab.ReturnValue(bsnmeanelevationField,r))  \n   else\n      bsnmeanelevationFName=\"\"\n      bsnmeanelevationField=\"\"\n   end\n  \n   if(bsnidField=Nil)then\n      msgBox.Error(\"A proper bas
in id field was not defined\",\"Error\")\n      exit\n   end\n\n   if(bsndescrField=Nil)then\n      msgBox.Error(\"A proper basin description field was not defined\",\"Error\")\n      exit\n   end\n\n   if(bsnmeanelevationField=Nil)then\n      msgBox.Error(\"A proper basin mean elevation field was not defined\",\"Error\")\n      exit\n   end\ntheTotalList.Add(theTypeList)\ntheTotalList.Add(theValueList)\nreturn theTotalList\n\n"
)

(Script.427
	Name:	"mapx.basindescription.apply"
	SourceCode:	"theDialog=SELF.getDialog \ntheDictionary=theDialog.getObjectTag\ntheBasinDescription=Self.getText\ntheDictionary.Set(\"BASINDESCRIPTION\",theBasinDescription)\ntheListBox=theDialog.FindByName(\"1hrmapxListBox\")\nSelf.setListeners({theListBox})\nSelf.BroadCastUpdate\n\n"
)

(Script.428
	Name:	"mapx.basindescription.changed"
	SourceCode:	"theDialog=SELF.getDialog \ntheDictionary=theDialog.getObjectTag\ntheBasinDescription=Self.getText\ntheDictionary.Set(\"BASINDESCRIPTION\",theBasinDescription)\n\n\n"
)

(Script.429
	Name:	"mapx.basindescriptionfield.click"
	SourceCode:	"theDialog=SELF.getDialog \ntheListBox=theDialog.FindByName(\"1hrmapxListBox\")\nSelf.setListeners({theListBox})\nSelf.BroadCastUpdate\n\n\n\n                  \n\n\n\n\n"
)

(Script.430
	Name:	"mapx.basinid.apply"
	SourceCode:	"theDialog=SELF.getDialog \ntheDictionary=theDialog.getObjectTag\ntheBasinId=Self.getText.Trim\ntheDictionary.Set(\"BASINID\",theBasinId)\ntheListBox=theDialog.FindByName(\"1hrmapxListBox\")\nSelf.setListeners({theListBox})\nSelf.BroadCastUpdate\n\n"
)

(Script.431
	Name:	"mapx.basinid.changed"
	SourceCode:	"theDialog=SELF.getDialog \ntheDictionary=theDialog.getObjectTag\ntheBasinId=Self.getText.Trim\ntheDictionary.Set(\"BASINID\",theBasinId)\n\n"
)

(Script.432
	Name:	"mapx.basinidfield.click"
	SourceCode:	"theDialog=SELF.getDialog \ntheListBox=theDialog.FindByName(\"1hrmapxListBox\")\nSelf.setListeners({theListBox})\nSelf.BroadCastUpdate\n \n\n"
)

(Script.433
	Name:	"mapx.basininputtheme.click"
	SourceCode:	"theDialog=SELF.getDialog \ntheListBox=theDialog.FindByName(\"1hrmapxListBox\")\nSelf.setListeners({theListBox})\nSelf.BroadCastUpdate\n\n"
)

(Script.434
	Name:	"mapx.basinmeanelevation.click"
	SourceCode:	"theView=av.getActiveDoc\ntheDialog=SELF.getDialog \ntheDictionary=theDialog.getObjectTag\ntheListBox=theDialog.FindByName(\"1hrmapxListBox\")\ntheBasinMeanElevationField=theDictionary.Get(\"BASINMEANELEVATIONFIELD\")\ntheBasinThemeName=theDictionary.Get(\"BASINTHEME\")\ntheBasinTheme=theView.FindTheme(theBasinThemeName)\ntheField=theBasinTheme.getFtab.FindField(theBasinMeanElevationField)\nif((theField=NIL) AND (theBasinMeanElevationField<>\"Empty\"))then\n   theList=theView.getThemes\n   theNList={}\n   for each t in theList
\n      if(t.getClass.getClassName=\"GTHEME\")then\n         theNlist.Add(t.getName)\n      end\n   end\nelse\n   theList=theBasinTheme.getFtab.getFields\n   theNList={}\n   for each f in theList\n      theNList.add(f.getAlias)\n   end          \n   theNList.Insert(\"NONE (Select DEM to compute)\")\nend\ntheListBox.defineFromList(theNList)   \nSelf.setListeners({theListBox})\nSelf.BroadCastUpdate\n\n\n"
)

(Script.435
	Name:	"mapx.calculatebasinparameters"
	SourceCode:	"theProject=av.getProject\ntheView=av.GetActiveDoc\ntheGraphics=theView.getGraphics\ntheDictionary=SELF.GET(0)\ntheButton= SELF.GET(1)\nthePrj=theView.getProjection\nif(thePrj.isNull.not)then\n   msgBox.info(\"The script expects an unprojected view\",\"Error\")\nend\ntheRect=theView.returnExtent \nif (theView.Is(View).not) then\n   msgbox.info(\"Must have a View as the active document.\",script.the.getname)\n   exit\nend\n\n'***Build Albers Projection ***\ntheAPrj=Albers.Make(theRect)\ntheAPrj.setCentralMeridian(-96)\ntheAPrj.setFa
lseEasting(0)\ntheAPrj.setFalseNorthing(0)\ntheAPrj.setReferenceLatitude(23)\ntheAPrj.setUpperStandardParallel(29.5)\ntheAPrj.setLowerStandardParallel(45.5)\ntheAPrj.reCalculate\n\n'***Make sure dictionary set***'\nif(theDictionary=NIL)then\n   msgBox.ERROR(\"Must first set MAPX information\",\"Error\")\n   exit\nend\n\n'***Define hrap points theme***'\nhrapName=\"hrappts.shp\"\nhrapTheme=theView.FindTheme(hrapName)\nif(hrapTheme=NIL)then\n   msgBox.Error(\"Need an hrapp points theme (hrappts.shp)\",\"Error\")\n   exit\nend\nhrapFtab=hr
apTheme.getFtab\n\n'***see if a mapx or basin dictionary\nif(theDictionary.getName.Contains(\"mapx\"))then\n   theType=\"mapx_area\"\nelse\n   theType=\"basin\"\nend\n\n'***Get dictionary variables***'\ntheMapxid=theDictionary.Get(\"MAPXID\")\n'*** check to make sure mapxid not already defined\ntheDialogB=av.findDialog(\"ofs-mapx-dump\")\ntheDictionaryB=theDialogB.getObjectTag\ntheMapxList=theDictionaryB.Get(\"MAPXAREALIST\")\ntheIndex=theMapxList.findByValue(theMapxid)\nif(theIndex<> -1)then\n   msgBox.Error(\"The mapx area\"++theMapxId
++\"already exists.\"++\"You must delete it first\",\"\")\n   exit\nend\ntheMapxDescription=theDictionary.Get(\"MAPXDESCRIPTION\")\ntheFmapid=theDictionary.Get(\"FMAPID\")\nif(theFmapid=\"NONE\")then\n   theFmapid=\"\"\nend\ntheBasinTheme=theView.FindTheme(theDictionary.Get(\"BASINTHEME\"))\ntheBasinId=theDictionary.Get(\"BASINID\")\ntheBasinDescription=theDictionary.Get(\"BASINDESCRIPTION\")\n'***if theBasinMeanElevation is defined, it is the name of the dem for computing basin mean***'\ntheBasinMeanElevation=theDictionary.Get(\"BASINMEAN
ELEVATION\")\n\n\n\n'**** get some tokens ***'\ntheExistingDir = Filename.getCWD.asString\n'***get ofs input directory ***\nSystem.Execute(\"gad ofs_input>temp.txt\")\ntheTempFileName = (theExistingDir+\"/temp.txt\").asFileName\ntheTFile = LineFile.Make(theTempFileName,#FILE_PERM_READ)\ntheTFile.setScratch(TRUE)\ntheInputDir=theTFile.ReadElt\ntheTFile.Close\n'***get ofs output directory ***\nSystem.Execute(\"gad my_output>temp.txt\")\ntheTempFileName = (theExistingDir+\"/temp.txt\").asFileName\ntheTFile = LineFile.Make(theTempFileN
ame,#FILE_PERM_READ)\ntheTFile.setScratch(TRUE)\ntheOutputDir=theTFile.ReadElt\ntheTFile.Close\n\n'***get ofs rls directory ***\nSystem.Execute(\"gad ofs_rls>temp.txt\")\ntheTempFileName = (theExistingDir+\"/temp.txt\").asFileName\ntheTFile = LineFile.Make(theTempFileName,#FILE_PERM_READ)\ntheTFile.setScratch(TRUE)\ntheBinDir=theTFile.ReadElt\ntheTFile.Close \n\n'*** get editor\nSystem.Execute(\"gad xsets_editor>temp.txt\")\ntheTempFileName = (theExistingDir+\"/temp.txt\").asFileName\ntheTFile = LineFile.Make(theTempFileName,#FILE
_PERM_READ)\ntheTFile.setScratch(TRUE)\ntheEditor=theTFile.ReadElt\ntheTFile.Close\n\n'***get date stamp ***\nSystem.Execute(\"date -u +%Y%m%d.%H%M%S>temp.txt\")\ntheTempFileName = (theExistingDir+\"/temp.txt\").asFileName\ntheTFile = LineFile.Make(theTempFileName,#FILE_PERM_READ)\ntheTFile.setScratch(TRUE)\ntheDateStamp=theTFile.ReadElt\ntheTFile.Close \n\n'**** this is the ofs input file ****\ntheInputFile = (theInputDir+\"/ppinit/\"+theType+\".define.\"+theDateStamp).asFileName\ntheOfsInputFileName = theInputFile.getName\ntheIF
ile = LineFile.Make(theInputFile,#FILE_PERM_WRITE)\n\n'*** this file is the ofs output file ***\ntheOfsOutputFileName= theOutputDir+\"/\"+theType+\".define.\"+theDateStamp\n\n'***Set basintheme to only active theme***'\nbndName=theDictionary.Get(\"BASINTHEME\")\ntheThemes=theView.getThemes\nfor each t in theThemes\n   if(t.getName=bndName)then\n      bndTheme=t\n      t.setActive(TRUE)\n   else\n      t.setActive(FALSE)\n   end\nend\n'***List to hold all information to go in text file***'\noutline=List.Make\n\n'***Determine if need
 to weed***'\ntheReturnList=av.Run(\"mapx.weed_to_Xkm\",{theDictionary,hrapTheme})\nthePolygonList=theReturnList.Get(0)\ntheTypeList=theReturnList.Get(1)\ntheValueList=theReturnList.Get(2)\ntheCount=bndName.Count\ntheWeedName=bndName.Left(theCount-4)+\"_w\"\nbndTheme = av.Run(\"mapx.util.ThemeCreating\",{theWeedName,polygon,theTypeList,theValueList,thePolygonList})\ntheName=bndTheme.getName\ntheOldTheme=theView.FindTheme(theName)\nif(theOldTheme<> Nil)then\n   theView.deleteTheme(theOldTheme)\nend\ntheView.AddTheme(bndTheme)\n
bndFtab=bndTheme.getFtab\n\n'***Check to see if basinid or basindescription field was specified***'\nif(theBasinId=\"\")then\n   bsnidFName=theDictionary.Get(\"BASINIDFIELD\")\n   bsnidField=bndFtab.FindField(bsnidFName)\nelse\n   bsnidFName=\"\"\n   bsnidField=\"\"\nend\nif(theBasinDescription=\"\")then\n   bsndescrFName=theDictionary.Get(\"BASINDESCRIPTIONFIELD\")\n   bsndescrField=bndFtab.FindField(bsndescrFName)\nelse\n   bsndescrFName=\"\"\n   bsndescrField=\"\"\nend\nif(theBasinMeanElevation=\"\")then\n   bsnmeanelevationFName=theDictio
nary.Get(\"BASINMEANELEVATIONFIELD\")\n   bsnmeanelevationField=bndFtab.FindField(bsnmeanelevationFName)\nelse\n   bsnmeanelevationFName=\"\"\n   bsnmeanelevationField=\"\"\nend\n\nif(bsnidField=Nil)then\n   msgBox.Error(\"A proper basin id field was not defined\",\"Error\")\n   exit\nend\n\nif(bsndescrField=Nil)then\n   msgBox.Error(\"A proper basin description field was not defined\",\"Error\")\n   exit\nend\n\nif(bsnmeanelevationField=Nil)then\n   msgBox.Error(\"A proper basin mean elevation field was not defined\",\"Error\")\n   exit\nend\n\n
'***Select each boundary that intersects an hrapp point***'\nhrapFtab.selectByFtab(bndFtab,#FTAB_RELTYPE_ISCOMPLETELYWITHIN ,0,#VTAB_SELTYPE_NEW)\nbndFtab.selectByFtab(hrapFtab,#FTAB_RELTYPE_INTERSECTS ,0,#VTAB_SELTYPE_NEW)\noutline.Add(\"@DEFINE BASIN NEW\")\ntheBasinCount=0\ntheTotalCount=bndFtab.getSelection.Count\n\ntheBasinIdList={}\nfor each brec in bndFtab.getSelection\n   thePolygon=Polygon.MakeNull\n   av.setStatus((brec/theTotalCount)*100)\n   theBasinCount=theBasinCount+1\n   bndFtab.QueryShape(brec,thePrj,the
Polygon)\n  '***Get basin id, description, area and centroid***'    \n   if(bsnidField<>\"\")then\n      bsnid=bndFtab.ReturnValue(bsnidField,brec)\n      if(bsnid.getClass.getClassName<>\"STRING\")then\n         msgBox.Error(\"The value for basin id is not a string: Redefine\"++\n                       \"basin id field\",\"Error\")\n         exit\n      end\n   else\n      theNumber=theBasinCount.asString.Count\n      theName=8-theNumber\n      theBasinId=theBasinId.Left(theName)      \n      bsnid=theBasinId+theBasinCount.asStr
ing\n   end\n   if(bsndescrField<>\"\")then\n      bsndescr=bndFtab.ReturnValue(bsndescrField,brec)\n      if(bsndescr.getClass.getClassName<>\"STRING\")then\n         msgBox.Error(\"The value for basin description is not a string: Redefine\"++\n                       \"basin description field\",\"Error\")\n         exit\n      end\n   else\n      bsndescr=theBasinDescription\n   end\n   if(bsnmeanelevationField<>\"\")then\n      bsnmeanelevation=bndFtab.ReturnValue(bsnmeanelevationField,brec).asString\n      if(bsnmeanelevation.isN
umber.not)then\n         msgBox.Error(\"The value\"++bsnmeanelevation++\"is not a number: Redefine\"++\n                       \"basin mean elevation field\",\"Error\")\n         exit\n      end\n   else\n      theGridTheme=theView.FindTheme(theBasinMeanElevation)\n      theGrid=theGridTheme.getGrid\n      thePolyGrid=theGrid.ExtractByPolygon (thePolygon, Prj.MakeNull, FALSE)\n      theList=thePolyGrid.getStatistics\n      '***this assumes the dem elevation units are in meters\n      bsnmeanelevation=theList.Get(2)\n      bsnm
eanelevation=bsnmeanelevation.asString\n   end\n   '***Determine area [km2] and centroid***\n   aShape=bndFtab.ReturnValue(bndFtab.GetFields.Get(0),brec)\n   area=(aShape.ReturnArea)/1000000.0\n   aCentroid=(aShape.ReturnCenter)\n   areastr=area.Setformat(\"d.dddd\").asstring\n\n    '***Add basin information; Truncate if not right # of characters***'\n   if(bsnid.Count>8)then\n      bsnid=bsnid.Left(8)\n   elseif(bsnid=\"\")then\n      msgBox.Error(\"Must define a basin id\",\"ERROR\")\n   end   \n   if(bsndescr.Count>20)then\n  
    bsndescr=bsndescr.Left(20)\n   elseif(bsndescr=\"\")then\n      bsndescr=\"NONE\"\n   end\n   '*** check to make sure basnid not already defined\n   theDialogB=av.findDialog(\"ofs-basin-dump\")\n   theDictionaryB=theDialogB.getObjectTag\n   theBasinList=theDictionaryB.Get(\"BASINLIST\")\n   theIndex=theBasinList.findByValue(bsnid)\n   if(theIndex <> -1)then\n      msgBox.Error(\"The basin\"++bsnid++\"already exists.\"++\"You must delete it first\",\"\")\n      exit\n   end\n   theBasinIdList.Add(bsnid)\n   outline.Add(\"BASN(METR)\"++
bsnid++\"'\"+bsndescr+\"'\")    \n   \n   '***Get Lat/Lon for basin\n   bndFtab.QueryShape(brec,thePrj,thePolygon)\n   theUPolygon = thePolygon.returnUnProjected(theAPrj)   \n   theXYlist = thePolygon.asPolyline.asMultiPoint.asList\n   numLatLonPoints=(theXYList.Count)\n   theCnt=0\n   theString=\"(\"\n   '***Make sure the points are in clockwise order   \n   'theXYlist=av.Run(\"basin.clockwise\",{theXYlist})   \n   for each pt in theXYlist\n      pt=pt.returnUnprojected(theAPrj)\n      theLat=pt.getY.setFormatPrecision(4)\n    
  theLon=pt.getX.setFormatPrecision(4)\n      if(theLon<0)then\n         theLon=-theLon.setFormatPrecision(4)\n      end\n      if(theCnt=3)then\n         theString=theString+theLat.asString+\" \"+theLon.asString+NL\n         theCnt=0\n      else\n         theString=theString+theLat.asString+\" \"+theLon.asString+\" \"\n         theCnt=theCnt+1\n      end     \n   end\n   theString=theString+\")\"\n   outline.Add(theString)\n   outline.Add(\"AREA(\"+areastr+\")\"++\"ELEV(\"+bsnmeanelevation+\")\")\nend\ntheCnt=0\ntheReturnList={}\nif(theTyp
e=\"mapx_area\")then\n   theReturnList.Add(theMapxid)\n   theReturnList.Add(theBasinidList)\n   theNumOfBasins=theBasinidList.Count.asString\n   if(theNumOfBasins.asNumber=0)then\n      msgBox.Warning(\"No areas defined: Only areas that contain HRAP pixels will be defined\",\"Warning\")\n   end\n   outline.Add(\"@DEFINE AREA NEW\")\n   theString=\"MAPX\"++theMapxid++\"'\"+theMapxDescription+\"'\"++theNumOfBasins+NL\n   theBasinString=\"\"\n   for each id in theBasinIdList\n      theCnt=theCnt+1\n      if(theCnt=4)then\n         theBasi
nString=theBasinString++id+NL\n         theCnt=0\n      else\n         theBasinString=theBasinString++id+\" \"\n      end\n   end\n   outline.Add(theString+theBasinString++theFmapID)\nelse\n   theReturnList.Add(theBasinidList)\nend\ntheNumLines=outline.Count\ntheIFile.Write(outline,theNumLines)\ntheIFile.Close\n\nav.clearStatus\n'***Run ofs to write area/basin info to fs5files\ntheIname=theOfsInputFileName\nif(theButton.Contains(\"no_export\").not)then\n   theIname=theIname.asFileName.getBaseName\n   theOname=theOfsOutputFileName
.asFileName.getBaseName\n   theCallA=\"ofs -p ppinit -i\"++theIname++\"-o\"++theOName\n   theCallB=theEditor++theOfsOutputFileName+\"*\"+\"&\"\n   System.Execute(theCallA)\n   System.Execute(theCallB)\nelse\n   theCallB=theEditor++theIName+\"&\"\n   System.Execute(theCallB)\n   exit\nend\nreturn theReturnList"
)

(Script.436
	Name:	"mapx.calculatebasinparameters.wbasmapx"
	SourceCode:	"theProject=av.getProject\ntheView=av.GetActiveDoc\ntheGraphics=theView.getGraphics\ntheDictionary=SELF.GET(0)\ntheButton= SELF.GET(1)\nthePrj=theView.getProjection\nif(thePrj.isNull.not)then\n   msgBox.info(\"The script expects an unprojected view\",\"Error\")\nend\ntheRect=theView.returnExtent \nif (theView.Is(View).not) then\n   msgbox.info(\"Must have a View as the active document.\",script.the.getname)\n   exit\nend\n'***Make sure dictionary set***'\nif(theDictionary=NIL)then\n   msgBox.ERROR(\"Must first set MAPX information
\",\"Error\")\n   exit\nend\n'***Define hrap points theme***'\nhrapName=\"hrappts.shp\"\nhrapTheme=theView.FindTheme(hrapName)\nif(hrapTheme=NIL)then\n   msgBox.Error(\"Need an hrapp points theme (hrappts.shp)\",\"Error\")\n   exit\nend\n'***see if a mapx or basin dictionary\nif(theDictionary.getName.Contains(\"mapx\"))then\n   mapx=\"yes\"\nelse\n   mapx=\"no\"\nend\n\n'***Get dictionary variables***'\ntheMapxid=theDictionary.Get(\"MAPXID\")\ntheMapxDescription=theDictionary.Get(\"MAPXDESCRIPTION\")\ntheFmapid=theDictionary.Get(\"FMAPID\")\ntheBas
inTheme=theView.FindTheme(theDictionary.Get(\"BASINTHEME\"))\ntheBasinId=theDictionary.Get(\"BASINID\")\ntheBasinDescription=theDictionary.Get(\"BASINDESCRIPTION\")\n'***if theBasinMeanElevation is defined, it is the name of the dem for computing basin mean***'\ntheBasinMeanElevation=theDictionary.Get(\"BASINMEANELEVATION\")\n\n'***Create temporary file for reading tokens and writing rwNWSRFS input***'\ntheProject.getWorkDir.setCWD\nSystem.Execute(\"gad ofs_rls>temp.txt\")\ntheExistingDir = theProject.getWorkDir.asString\ntheT
empFileName = (theExistingDir+\"/temp.txt\").asFileName\ntheTFile = LineFile.Make(theTempFileName,#FILE_PERM_READ)\ntheTFile.setScratch(TRUE)\ntheBinDir=theTFile.ReadElt\ntheTFile.Close\nSystem.Execute(\"gad ofs_input>temp.txt\")\ntheTempFileName = (theExistingDir+\"/temp.txt\").asFileName\ntheTFile = LineFile.Make(theTempFileName,#FILE_PERM_READ)\ntheTFile.setScratch(TRUE)\ntheInputDir=theTFile.ReadElt\ntheTFile.Close\nSystem.Execute(\"gad my_output>temp.txt\")\ntheTempFileName = (theExistingDir+\"/temp.txt\").asFileName\ntheTFi
le = LineFile.Make(theTempFileName,#FILE_PERM_READ)\ntheTFile.setScratch(TRUE)\ntheOutputDir=theTFile.ReadElt\ntheTFile.Close\ntheInputFileName = (theInputDir+\"/ppinit/wbasmapx.input\").asFileName\ntheLogFileName = (theOutputDir+\"/wbasmapx.log\")\ntheFile = LineFile.Make(theInputFileName,#FILE_PERM_WRITE)\nif(theButton=\"no_export\")then\n   System.Execute(\"gad xsets_editor>temp.txt\")\n   theTempFileName = (theExistingDir+\"/temp.txt\").asFileName\n   theTFile = LineFile.Make(theTempFileName,#FILE_PERM_READ)\n   theTFile.se
tScratch(TRUE)\n   theEditor=theTFile.ReadElt\n   theTFile.Close\nend\n\n\n\n\n\n'***Set basintheme to only active theme***'\nbndName=theDictionary.Get(\"BASINTHEME\")\ntheThemes=theView.getThemes\nfor each t in theThemes\n   if(t.getName=bndName)then\n      bndTheme=t\n      t.setActive(TRUE)\n   else\n      t.setActive(FALSE)\n   end\nend\n\n'***Determine if need to weed***'\nbndTheme=av.Run(\"mapx.weed_to_Xkm\",{bndName,theDictionary})\n\nif(bndTheme=Nil)then\n   exit\nend\nbndFtab=bndTheme.GetFtab\n\n\n'***List to hold all information t
o go in text file***'\noutline=List.Make\n\n'***Build Albers Projection ***\ntheAPrj=Albers.Make(theRect)\ntheAPrj.setCentralMeridian(-96)\ntheAPrj.setFalseEasting(0)\ntheAPrj.setFalseNorthing(0)\ntheAPrj.setReferenceLatitude(23)\ntheAPrj.setUpperStandardParallel(29.5)\ntheAPrj.setLowerStandardParallel(45.5)\ntheAPrj.reCalculate\n\n\n'***Check to see if basinid or basindescription field was specified***'\nif(theBasinId=\"\")then\n   bsnidFName=theDictionary.Get(\"BASINIDFIELD\")\n   bsnidField=bndFtab.FindField(bsnidFName)\nelse
\n   bsnidFName=\"\"\n   bsnidField=\"\"\nend\nif(theBasinDescription=\"\")then\n   bsndescrFName=theDictionary.Get(\"BASINDESCRIPTIONFIELD\")\n   bsndescrField=bndFtab.FindField(bsndescrFName)\nelse\n   bsndescrFName=\"\"\n   bsndescrField=\"\"\nend\nif(theBasinMeanElevation=\"\")then\n   bsnmeanelevationFName=theDictionary.Get(\"BASINMEANELEVATIONFIELD\")\n   bsnmeanelevationField=bndFtab.FindField(bsnmeanelevationFName)\nelse\n   bsnmeanelevationFName=\"\"\n   bsnmeanelevationField=\"\"\nend\n\nif(bsnidField=Nil)then\n   msgBox.Error(\"A proper
 basin id field was not defined\",\"Error\")\n   exit\nend\n\nif(bsndescrField=Nil)then\n   msgBox.Error(\"A proper basin description field was not defined\",\"Error\")\n   exit\nend\n\nif(bsnmeanelevationField=Nil)then\n   msgBox.Error(\"A proper basin mean elevation field was not defined\",\"Error\")\n   exit\nend\n\n\n \nhrapxFname=\"hrapx\"\nhrapyFname=\"hrapy\"\nhrapFtab=hrapTheme.GetFtab\n\nhrapxField=hrapFtab.FindField(hrapxFname)\nhrapyField=hrapFtab.FindField(hrapyFname)\n\n'***Select each boundary***'\nhrapFtab.selectByFtab(bndFtab,#FT
AB_RELTYPE_ISCOMPLETELYWITHIN ,0,#VTAB_SELTYPE_NEW)\nbndFtab.selectByFtab(hrapFtab,#FTAB_RELTYPE_INTERSECTS ,0,#VTAB_SELTYPE_NEW)\nbndBitmap=bndFtab.GetSelection\ntheBasinCount=bndBitmap.Count.asString\nthePolygon=Polygon.MakeNull\nif(mapx=\"yes\")then\n   outline.Add(\"MAPX\")\nend\n'***Add dictionary variables and # of basins to ouline list\nif(mapx=\"yes\")then\n   outline.Add(theMapxid++\"'\"+theMapxDescription+\"'\"++theBasinCount++theFmapid)\nend\ntheBasinCount=0\ntheTotalCount=bndFtab.GetSelection.Count\nfor each brec in bn
dFtab.GetSelection\n   av.setStatus((brec/theTotalCount)*100)\n   theBasinCount=theBasinCount+1\n   bndFtab.QueryShape(brec,thePrj,thePolygon)\n  '***Get basin id, description, area and centroid***'    \n   if(bsnidField<>\"\")then\n      bsnid=bndFtab.ReturnValue(bsnidField,brec)\n      if(bsnid.getClass.getClassName<>\"STRING\")then\n         msgBox.Error(\"The value for basin id is not a string: Redefine\"++\n                       \"basin id field\",\"Error\")\n         exit\n      end\n   else\n      bsnid=theBasinId+theBasi
nCount.asString\n   end\n   if(bsndescrField<>\"\")then\n      bsndescr=bndFtab.ReturnValue(bsndescrField,brec)\n      if(bsndescr.getClass.getClassName<>\"STRING\")then\n         msgBox.Error(\"The value for basin description is not a string: Redefine\"++\n                       \"basin description field\",\"Error\")\n         exit\n      end\n   else\n      bsndescr=theBasinDescription\n   end\n   if(bsnmeanelevationField<>\"\")then\n      bsnmeanelevation=bndFtab.ReturnValue(bsnmeanelevationField,brec).asString\n      if(bsnmeane
levation.isNumber.not)then\n         msgBox.Error(\"The value\"++bsnmeanelevation++\"is not a number: Redefine\"++\n                       \"basin mean elevation field\",\"Error\")\n         exit\n      end\n   else\n      theGridTheme=theView.FindTheme(theBasinMeanElevation)\n      theGrid=theGridTheme.getGrid\n      thePolyGrid=theGrid.ExtractByPolygon (thePolygon, Prj.MakeNull, FALSE)\n      theList=thePolyGrid.getStatistics\n      '***this assumes the dem elevation units are in meters\n      bsnmeanelevation=theList.Get(2
)\n      bsnmeanelevation=bsnmeanelevation.asString\n   end\n   '***Determine area [km2] and centroid***\n   aShape=bndFtab.ReturnValue(bndFtab.GetFields.Get(0),brec)\n   area=(aShape.ReturnArea)/1000000.0\n   aCentroid=(aShape.ReturnCenter)\n   areastr=area.Setformat(\"d.dddd\").asstring\n\n   outline.Add(\"BASN\")\n   hrapFtab.selectByPolygon(thePolygon,#vtab_seltype_new)\n   hrapxList=List.Make\n   hrapyList=List.Make\n   hrapyLast=0\n   selcount=0\n   segList=List.Make 'a List x Lists\n   theDistance=9999999\n   thePoint=Po
int.MakeNull\n   for each hrec in hrapFtab.Getselection\n      hrapFtab.QueryShape(hrec,thePrj,thePoint)\n      hrapx=hrapFtab.ReturnValue(hrapxField,hrec)\n      hrapy=hrapFtab.ReturnValue(hrapyField,hrec)\n      if ((hrapy<>hrapyLast) and (selcount<>0)) then\n         '--- write info about current row of cells to a file\n         numcols=hrapxList.Count\n         segList.Add(hrapxList.DeepClone)\n         hrapyList.Add(hrapyLast)\n         hrapxList.Empty\n         hrapxList.Add(hrapx)\n      else\n         hrapxList.
Add(hrapx)\n      end\n      hrapyLast=hrapy\n      selcount=selcount+1\n      theDistanceH=aCentroid.Distance(thePoint)\n      '***Determine centroid in integer hrapx and hrapy coordinates***\n      if(theDistanceH<theDistance)then\n         theDistance=theDistanceH\n         centroidX=hrapx.asString\n         centroidY=hrapY.asString\n      end\n   end\n   '***Add basin information; Truncate if not right # of characters***'\n   if(bsnid.Count>8)then\n      bsnid=bsnid.Left(8)\n   elseif(bsnid=\"\")then\n      msgBox.Error(
\"Must define a basin id\",\"ERROR\")\n   end   \n   if(bsndescr.Count>40)then\n      bsndescr=bsndescr.Left(40)\n   elseif(bsndescr=\"\")then\n      bsndescr=\"NONE\"\n   end\n   outline.Add(bsnid++\"'\"+bsndescr+\"'\"++areastr++bsnmeanelevation++\"( \"+centroidY++centroidX+\" )\")\n   'complete top line\n   numcols=hrapxList.Count\n   hrapyList.Add(hrapyLast)\n   segList.Add(hrapxList.DeepClone)\n   \n   numsegs=segList.Count\n   i=0\n   '***List to hold lineseg information***'\n   outlineA=List.Make\n   for each iseg in ((numsegs-1)..0)
 by -1\n      segStart=segList.get(iseg).get(0).clone\n      xcount=0\n      xlast=0\n      for each x in segList.get(iseg)\n        if ((x<>(xlast+1)) and (xcount<>0)) then\n           if (iseg<>0) then\n             i=i+1\n             aBuffer4=string.MakeBuffer(7-i.asstring.count)\n             val1=hrapyList.Get(iseg).asstring\n             val2=segStart.asstring\n             val3=xlast.asstring\n             aBuffer5=String.MakeBuffer(4-val1.asstring.count)\n             aBuffer6=String.MakeBuffer(4-val2.asstring.
count)\n             aBuffer7=String.MakeBuffer(4-val3.asstring.count)\n             outlineA.add(aBuffer4+i.asstring+abuffer5+val1+abuffer6+val2+abuffer7+val3)\n           end\n           xlast=x.clone\n           segStart=xlast.clone\n        else\n           'do nothing\n           xlast=x.clone\n        end\n        xcount=xcount+1\n      end\n      i=i+1\n      aBuffer4=string.MakeBuffer(7-i.asstring.count)\n      val1=hrapyList.Get(iseg).asstring\n      val2=segStart.asstring\n      val3=xlast.asstring\n      aBuffer5
=String.MakeBuffer(4-val1.asstring.count)\n      aBuffer6=String.MakeBuffer(4-val2.asstring.count)\n      aBuffer7=String.MakeBuffer(4-val3.asstring.count)\n      outlineA.add(aBuffer4+i.asstring+abuffer5+val1+abuffer6+val2+abuffer7+val3)\n   end\n   theString=\"LINESEGS\"++i.asString\n   outline.Add(theString)\n   for each l in outlineA\n      outline.Add(l)\n   end\n   '***Get Lat/Lon for basin\n   bndFtab.QueryShape(brec,thePrj,thePolygon)\n   theUPolygon = thePolygon.returnUnProjected(theAPrj)\n   'theXYlist = theUPol
ygon.asPolyLine.asMultiPoint.asList   \n   theXYlist = thePolygon.asPolyline.asMultiPoint.asList\n   numLatLonPoints=(theXYList.Count)\n   theCnt=0\n   theString=\"\"\n   theString=\"LAT/LON\"++(numLatLonPoints.asString)+NL\n   '***Make sure the points are in clockwise order\n   theXYlist=av.Run(\"basin.clockwise\",{theXYlist})   \n   for each pt in theXYlist\n      pt=pt.returnUnprojected(theAPrj)\n      theLat=pt.getY.setFormat(\"d.dddd\")\n      theLon=pt.getX.setFormat(\"d.dddd\")\n      if(theLon<0)then\n         theLon=-the
Lon\n      end\n      if(theCnt=3)then\n         theString=theString+theLat.asString+\",\"+theLon.asString+NL\n         theCnt=0\n      else\n         theString=theString+theLat.asString+\",\"+theLon.asString+\" \"\n         theCnt=theCnt+1\n      end     \n   end\n   outline.add(theString)\nend\nhrapTheme.ClearSelection\ntheNumLines=outline.Count\ntheFile.Write(outline,theNumLines)\ntheFile.Close\n'***Run code (rwNWSRFS) to write area/basin info to fs5files\nif(theButton=\"Export\")then\n   theCallA=theBinDir+\"/wbasmapx\"++theInputF
ileName.asString++theLogFileName\n   System.Execute(theCallA)\nelse\n   theCallB=theEditor++theInputFileName.asString\n   System.Execute(theCallB)\nend\nmsgBox.info(\"Process Complete\",\"Done\")\n\n\n \n\n\n\n\n\n\n"
)

(Script.437
	Name:	"mapx.delete.click"
	SourceCode:	"'mapx.delete.click\n'this script uses the selected mapx areas to run the @DELETE command\n\ntheProject=av.getProject\ntheView=av.getActiveDoc\ntheDialog=SELF.getDialog\ntheListBox=theDialog.FindByName(\"mapxdeletelist\")\ntheDictionary=theDialog.getObjectTag\ntheButton=SELF.getName \ntheSelectList= theListBox.getSelection\n\n \n'*** run the following ofs command and return the punch file ***'\ntheString=\"@DELETE AREA MAPX\"\ntheAList=\"\"\nfor each a in theSelectList\n   theAList=theAlist++a+NL\nend\ntheString=theString+theAList\n
\ntheCompletionCode=av.Run(\"util.RunOFS\",{theString,\"mapx_area\",\"delete\",\"screen\"})\nif(theCompletionCode=0)then\n   '*** the next set of code uses the index from the list of mapx areas to look into thenewentrylist\n   '*** the newentrylist gives the line number in the totalmapxarealist for the give area\n   '*** using this info rows are deleted from the totalmapxarealist  \n   for each a in theSelectList\n      '***remove areas and definition from dump-mapx dialog dictionary\n      theDialog=av.findDialog(\"ofs-map
x-dump\")\n      theDictionary=theDialog.getObjectTag\n      theMapxTotalList=theDictionary.Get(\"MAPXTOTALLIST\")\n      theMapxList=theDictionary.Get(\"MAPXAREALIST\")\n      theNewEntryList=theDictionary.Get(\"NEWENTRYLIST\")      \n      theMapxListC={}\n      theMapxTotalListC={}\n      theNewEntryListC={}\n      theIndex=theMapxList.FindByValue(a)\n      theStart=theNewEntryList.Get(theIndex)\n      if(theIndex=(theMapxList.Count-1))then\n         theEnd=theMapxTotalList.Count-1\n      else\n         theEnd=theNewEntryLi
st.Get(theIndex+1)\n      end\n      '*** remove elements from mapxlist  \n      theCount=theMapxList.Count\n      for each i in 0..(theCount-1)\n         if(i=theIndex)then\n            continue\n         else\n            theMapxListC.Add(theMapxList.get(i))\n         end\n      end\n      '*** remove elements from newentrylist\n      theCount=theNewEntryList.Count\n      for each i in 0..(theCount-1)\n         if(i<theIndex)then\n            theNewEntryListC.Add(theNewEntryList.get(i))\n         elseif(i>=(theIndex+1))t
hen\n            theDiff=theNewEntryList.get(theIndex+1)-theNewEntryList.get(theIndex)\n            theNewEntryListC.Add(theNewEntryList.get(i)-theDiff)\n         end\n      end\n      '*** remove lines form mapxtotallist\n      theCount=theMapxTotalList.Count\n      for each i in 0..(theCount-1)\n         if((i>=theStart) AND (i<theEnd))then\n            continue\n         else\n            theMapxTotalListC.Add(theMapxTotalList.get(i))\n         end\n      end\n      theMapxList=theMapxListC.DeepClone\n      theMapxTota
lList=theMapxTotalListC.DeepClone\n      theNewEntryList=theNewEntryListC.DeepClone\n      theDialogB=av.findDialog(\"ofs-mapx-delete\")\n      theDictionaryB=theDialogB.getObjectTag\n      theDictionary.Set(\"MAPXAREALIST\",theMapxList)\n      theDictionaryB.Set(\"MAPXAREALIST\",theMapxList)\n      theDictionary.Set(\"MAPXTOTALLIST\",theMapxTotalList)\n      theDictionary.Set(\"NEWENTRYLIST\",theNewEntryList)\n   end\nend\ntheListBox.Update"
)

(Script.438
	Name:	"mapx.deletelistbox.update"
	SourceCode:	"theDialog=SELF.getDialog\ntheListBox=theDialog.FindByName(\"mapxdeletelist\")\ntheDictionary=theDialog.getObjectTag\ntheMapxAreaList=theDictionary.Get(\"MAPXAREALIST\")\ntheListBox.defineFromList(theMapxAreaList)\n "
)

(Script.439
	Name:	"mapx.dialog.close"
	SourceCode:	"theName=SELF.getDialog.getName\nav.FindDialog(theName).close\n'*** Clear out dictionary Variables ***'\ntheDictionary=SELF.getDialog.getObjectTag\nif(theName=\"ofs-mapx-define\")then\n   theDialog=av.findDialog(theName)\n   theDictionary=theDialog.getObjectTag\n   theDictionary.Set(\"MAPXID\",\"\")\n   theDictionary.Set(\"MAPXDESCRIPTION\",\"\")\n   theDictionary.Set(\"BASINTHEME\",\"\")\n   theDictionary.Set(\"BASINIDFIELD\",\"\")\n   theDictionary.Set(\"BASINDESCRIPTIONFIELD\",\"\")\n   theDictionary.Set(\"BASINMEANELEVATIONFIELD\",\"Empty\")
\n   theDictionary.Set(\"BASINID\",\"\")\n   theDictionary.Set(\"BASINDESCRIPTION\",\"\")\n   theDictionary.Set(\"BASINMEANELEVATION\",\"\")\nelseif(theName=\"ofs-basin-define\")then\n   theDictionary.Set(\"BASINTHEME\",\"\")\n   theDictionary.Set(\"BASINIDFIELD\",\"\")\n   theDictionary.Set(\"BASINDESCRIPTIONFIELD\",\"\")\n   theDictionary.Set(\"BASINMEANELEVATIONFIELD\",\"\")\n   theDictionary.Set(\"BASINID\",\"\")\n   theDictionary.Set(\"BASINDESCRIPTION\",\"\")\n   theDictionary.Set(\"BASINMEANELEVATION\",\"\")\nend"
)

(Script.440
	Name:	"mapx.dialog.ok"
	SourceCode:	"'***Get Active View\ntheDialog=SELF.getDialog \ntheDictionary=theDialog.getObjectTag\nif(theDialog.getName=\"ofs-mapx-define\")then\n'***Get parameters from dialog box***'\n   theMapxid=theDialog.FindByName(\"mapxid\")\n   if(theMapxid.isEmpty)then\n      msgBox.Error(\"Must Enter an MAPX area id\",\"ERROR\")\n      exit\n   else\n      mapxid=theMapxid.getText.Trim\n   end\n   theMapxDescription=theDialog.FindByName(\"mapxdescription\")\n   if(theMapxDescription.isEmpty)then\n      mapxdescription=\"NONE\"\n   else\n      mapxdescrip
tion=theMapxDescription.getText\n   end\n   theFmapid=theDialog.FindByName(\"fmapid\")\n   fmapid=theFmapid.getCurrentValue\n   theDictionary.Set(\"FMAPID\",fmapid)\n   theDictionary.Set(\"MAPXID\",mapxid)\n   theDictionary.Set(\"MAPXDESCRIPTION\",mapxdescription)\nend\n'***Run script to calculate parameters and write to FS5FILES***\ntheButton = Self.getName\n'*** theName is returned from \"calculatebasin...\" ***\n'*** =mapxname if define mapx are ***\n'*** =basinname if from define basin area ***\ntheReturnList=av.Run(\"mapx.cal
culatebasinparameters\",{theDictionary,theButton})\nif(theButton.Contains(\"MAPX\"))then\n   theDialog=av.findDialog(\"ofs-mapx-dump\")\n   theDictionary=theDialog.getObjectTag\n   theMapxList=theDictionary.Get(\"MAPXAREALIST\")\n   theLineList=theDictionary.Get(\"MAPXTOTALLIST\")\n   'determine how many lines currently in themapxtotallist\n   'use this to determine linenumber of new entries\n   theCount=theLineList.Count\n   theNewEntryList=theDictionary.Get(\"NEWENTRYLIST\")\n   theName=theReturnList.Get(0)\n   '*** run the fo
llowing ofs command and return the punch file ***'\n   theString=\"@DUMP PUNCH AREA MAPX\"++theName\n   theOfile=av.Run(\"util.RunOFS\",{theString,\"mapx_area\",\"dump\"})\n   if(theOfile=Nil)then\n      exit\n   end\n   av.getProject.getWorkDir.SetCWD\n   theExistingDir=Filename.getCWD.asString\n   theTline={}     \n   theOfile.Read(theTline,theOfile.getSize)\n   theSize=theOfile.getSize\n   for each i in 0..(theSize-1)\n      av.setStatus((i/(theSize-1))*100)\n      theList=theTline.get(i).asTokens(\" \")\n      if(theList.get(0
).contains(\"MAPX\").not)then\n         theLineList.Add(theTline.get(i).asTokens(\" \"))\n         continue\n      else\n         theMapxList.Add(theList.get(1))\n         theNewEntryList.Add(theCount+i)\n         theLineList.Add(theList)\n      end\n   end   \n   theDictionary.Set(\"MAPXTOTALLIST\",theLineList)   \n   theDictionary.Set(\"MAPXAREALIST\",theMapxList)\n   theDictionary.Set(\"NEWENTRYLIST\",theNewEntryList)\n   \n   theDialogB=av.findDialog(\"ofs-basin-dump\")\n   theDictionaryB=theDialogB.getObjectTag\n   theBasinList=
theDictionaryB.Get(\"BASINLIST\")\n   theLineList=theDictionaryB.Get(\"BASINTOTALLIST\")   \n   theNewEntryList=theDictionaryB.Get(\"NEWENTRYLIST\")\n   theCount=theLineList.Count\n   theBList=theReturnList.Get(1)\n   theBasinString=\"\"\n   for each b in theBList\n      theBasinString=theBasinString++b+NL\n   end\n   '*** run the following ofs command and return the punch file ***'\n   theString=\"@DUMP PUNCH UNITS(METR) BASIN PUFORMAT(FIXED) PUMAXDEC(4)\"++theBasinString\n   theOfile=av.Run(\"util.RunOFS\",{theString,\"basin\",\"d
ump\"})\n   if(theOfile=NIL)then\n      exit\n   end\n   av.getProject.getWorkDir.SetCWD\n   theExistingDir=Filename.getCWD.asString\n   theTline={}\n   theOfile.Read(theTline,theOfile.getSize)\n   theSize=theOfile.getSize\n   for each i in 0..(theSize-1)\n      av.setStatus((i/(theSize-1))*100)\n      theList=theTline.get(i).asTokens(\" \")\n      if(theList.get(0).contains(\"BASN\").not)then\n         theLineList.Add(theTline.get(i).asTokens(\" \"))\n         continue\n      else\n         theBasinList.Add(theList.get(1))\n     
    theNewEntryList.Add(theCount+i)\n         theLineList.Add(theList)\n      end\n   end\n   theDictionaryB.Set(\"BASINTOTALLIST\",theLineList)\n   theDictionaryB.Set(\"BASINLIST\",theBasinList)\n   theDictionaryB.Set(\"NEWENTRYLIST\",theNewEntryList)\n   '*** Clear out dictionary Variables ***'\n   theDialog=av.findDialog(\"ofs-mapx-define\")\n   theDictionary=theDialog.getObjectTag\n   theDictionary.Set(\"MAPXID\",\"\")\n   theDictionary.Set(\"MAPXDESCRIPTION\",\"\")\n   theDictionary.Set(\"BASINTHEME\",\"\")\n   theDictionary.Set(\"BASI
NIDFIELD\",\"\")\n   theDictionary.Set(\"BASINDESCRIPTIONFIELD\",\"\")\n   theDictionary.Set(\"BASINMEANELEVATIONFIELD\",\"Empty\")\n   theDictionary.Set(\"BASINID\",\"\")\n   theDictionary.Set(\"BASINDESCRIPTION\",\"\")\n   theDictionary.Set(\"BASINMEANELEVATION\",\"\")\nelse\n   theDialog=av.findDialog(\"ofs-basin-dump\")\n   theDictionary=theDialog.getObjectTag\n   theBasinList=theDictionary.Get(\"BASINLIST\")\n   theLineList=theDictionary.Get(\"BASINTOTALLIST\")\n   theCount=theLineList.Count\n   theNewEntryList=theDictionary.Get(\"NEWENTRYLIST
\")\n   theBlist=theReturnList.Get(0)\n   theBasinString=\"\"\n   for each id in theBlist\n      theBasinString=theBasinString++id+NL\n   end\n   '*** run the following ofs command and return the punch file ***'\n   theString=\"@DUMP PUNCH BASIN PUFORMAT(FIXED) PUMAXDEC(4)\"++theBasinString\n   theOfile=av.Run(\"util.RunOFS\",{theString,\"basin\",\"dump\"})\n   if(theOfile=NIL)then\n      exit\n   end\n   av.getProject.getWorkDir.SetCWD\n   theExistingDir=Filename.getCWD.asString\n   theTline={}\n   theOfile.Read(theTline,theOfile.g
etSize)\n   theSize=theOfile.getSize\n   for each i in 0..(theSize-1)\n      av.setStatus((i/(theSize-1))*100)\n      theList=theTline.get(i).asTokens(\" \")\n      if(theList.get(0).contains(\"BASN\").not)then\n         theLineList.Add(theTline.get(i).asTokens(\" \"))\n         continue\n      else\n         theBasinList.Add(theList.get(1))\n         theNewEntryList.Add(theCount+i)\n         theLineList.Add(theList)\n      end\n   end\n   theDictionary.Set(\"BASINTOTALLIST\",theLineList)\n   theDictionary.Set(\"BASINLIST\",theBasi
nList)\n   theDictionary.Set(\"NEWENTRYLIST\",theNewEntryList)\n   '*** Clear out dictionary varialbes ***\n   theDialog=av.findDialog(\"ofs-basin-define\")\n   theDictionary=theDialog.getObjectTag\n   theDictionary.Set(\"BASINTHEME\",\"\")\n   theDictionary.Set(\"BASINIDFIELD\",\"\")\n   theDictionary.Set(\"BASINDESCRIPTIONFIELD\",\"\")\n   theDictionary.Set(\"BASINMEANELEVATIONFIELD\",\"\")\n   theDictionary.Set(\"BASINID\",\"\")\n   theDictionary.Set(\"BASINDESCRIPTION\",\"\")\n   theDictionary.Set(\"BASINMEANELEVATION\",\"\")\nend\ntheDialog.Close
\n'*** Clear out dictionary Variables ***'\nif(theName=\"ofs-mapx-define\")then\n   theDialog=av.findDialog(theName)\n   theDictionary=theDialog.getObjectTag\n   theDictionary.Set(\"MAPXID\",\"\")\n   theDictionary.Set(\"MAPXDESCRIPTION\",\"\")\n   theDictionary.Set(\"BASINTHEME\",\"\")\n   theDictionary.Set(\"BASINIDFIELD\",\"\")\n   theDictionary.Set(\"BASINDESCRIPTIONFIELD\",\"\")\n   theDictionary.Set(\"BASINMEANELEVATIONFIELD\",\"Empty\")\n   theDictionary.Set(\"BASINID\",\"\")\n   theDictionary.Set(\"BASINDESCRIPTION\",\"\")\n   theDictionary.Set(
\"BASINMEANELEVATION\",\"\")\nelseif(theName=\"ofs-basin-define\")then\n   theDictionary.Set(\"BASINTHEME\",\"\")\n   theDictionary.Set(\"BASINIDFIELD\",\"\")\n   theDictionary.Set(\"BASINDESCRIPTIONFIELD\",\"\")\n   theDictionary.Set(\"BASINMEANELEVATIONFIELD\",\"\")\n   theDictionary.Set(\"BASINID\",\"\")\n   theDictionary.Set(\"BASINDESCRIPTION\",\"\")\n   theDictionary.Set(\"BASINMEANELEVATION\",\"\")\nend"
)

(Script.441
	Name:	"mapx.dialog.update"
	SourceCode:	"theDialog=av.FindDialog(\"ofs-define-mapx\")\ntheDictionary=theDialog.getObjectTag\nif(theDictionary.getName=\"mapxdictionary\")then\n   fmapid=theDictionary.get(\"FMAPID\")\n   mapxid=theDictionary.Get(\"MAPXID\")\n   mapxdescription=theDictionary.Get(\"MAPXDESCRIPTION\")\n   areaunits=theDictionary.Get(\"AREAUNITS\")\n\n   '***Set parameters from dialog box***'\n   \n   theMapxid=theDialog.FindByName(\"mapxid\")\n   mapxid=theMapxid.SetText(mapxid)\n\n   theMapxDescr=theDialog.FindByName(\"mapxdescription\")\n   mapxdescription=theMap
xDescr.setText(mapxdescription)\n\n   theFmapid=theDialog.FindByName(\"fmapid\")\n   fmapid=theFmapid.setText(fmapid)\nend\n\n\n\n"
)

(Script.442
	Name:	"mapx.dump.listbox.apply"
	SourceCode:	" \n\n\n\n"
)

(Script.443
	Name:	"mapx.import.click"
	SourceCode:	"'mapx.import.click\n'this script reads the output file from a ppinit/dump/area/mapx and creates a mapx theme\n'made up of basin boundary theme(s)\n\n\ntheProject=av.getProject\ntheView=av.getActiveDoc\ntheDialog=av.finddialog(\"ofs-mapx-dump\")'SELF.getDialog\ntheListBox=theDialog.FindByName(\"mapxdumplist\")\ntheDictionary=theDialog.getObjectTag\ntheRect=theView.returnExtent\n\n'***Build Albers Projection ***\ntheAPrj=Albers.Make(theRect)\ntheAPrj.setCentralMeridian(-96)\ntheAPrj.setFalseEasting(0)\ntheAPrj.setFalseNorthing(0
)\ntheAPrj.setReferenceLatitude(23)\ntheAPrj.setUpperStandardParallel(29.5)\ntheAPrj.setLowerStandardParallel(45.5)\ntheAPrj.reCalculate\n\n \ntheButton=SELF.getName \ntheAreas= theListBox.getSelection\ntheAcount=theAreas.Count\n'*** get the mapx area dump file with all mapx areas ***'\ntheLineList=theDictionary.Get(\"MAPXTOTALLIST\")\ntheAreaList=theDictionary.Get(\"MAPXAREALIST\")\ntheFirstEntryList=theDictionary.Get(\"NEWENTRYLIST\")\n\n'theCount is the number of lines in the dump file\ntheTotalLines=theLineList.Count\nnextLin
e=0\narea=0\ntheLine=0\nthePos=0\nav.clearMsg\nav.showMsg(\"Importing MAPX Area\") \nWhile(area<>theAcount)\n   theIndex=theAreaList.FindByValue(theAreas.get(area))\n   theLine=theFirstEntryList.get(theIndex)\n   thePos=thePos+1\n   '*** the 2nd entry of each line is the mapx area name ***\n   theAreaName=theLineList.get(theLine).get(thePos)\n   area=area+1   \n   thePos=thePos+1    \n   theDescription=\"\"\n   while(theLineList.get(theLine).get(thePos).isNumber.not)   \n      theDescription=theDescription++theLineList.get(the
Line).get(thePos)\n      thePos=thePos+1\n   end\n   theDescription=theDescription.Substitute(\"'\",\"\")\n   '*** entry 3 (position 2)...n (where n is the entry w/ the number of basins\n   theNumOfBasins=theLineList.get(theLine).get(thePos).asNumber\n   thePos=thePos+1\n   theCnt=0\n   theBasins={}\n   while(theCnt<>theNumOfBasins)\n      'theCountA is the number of entries in theLine\n      theCountA=theLineList.get(theLine).Count\n      for each j in thePos..(theCountA-2)\n         theCnt=theCnt+1\n         theBasins.Add(
theLineList.get(theLine).get(j))\n      end\n      theLine=theLine+1\n      thePos=0\n   end   \n   '*** read basin information for all basins in mapx area ***'\n   theDialogA=av.findDialog(\"ofs-basin-dump\")\n   theDictionaryA=theDialogA.getObjectTag\n   theLineListA=theDictionaryA.Get(\"BASINTOTALLIST\")\n   theBasinListA=theDictionaryA.Get(\"BASINLIST\")\n   theFirstEntryListA=theDictionaryA.Get(\"NEWENTRYLIST\")\n\n   theTotalLinesB=theLineListA.Count\n   basin=0\n   theLineB=0\n   theBcount=theBasins.Count \n   thePolygonLis
t={} \n   theValues={}\n   theExtraFields={}\n   While(basin<>theBcount)\n      theIndex=theBasinListA.FindByValue(theBasins.get(basin))\n      theLineB=theFirstEntryListA.get(theIndex)\n      thePos=0\n      '*** the 1st line 2nd entry is the basin name ***\n      thePos=thePos+1\n      theBasinName=theLineListA.get(theLineB).get(thePos)\n      basin=basin+1\n      thePos=thePos+1\n      '*** from thePos...n (where n is the entry w/ the number of basins\n      theDescription=\"\"\n      while(theLineListA.get(theLineB).ge
t(thePos)<>\"(\") \n         theDescription=theDescription++theLineListA.get(theLineB).get(thePos)\n         thePos=thePos+1\n      end\n      theDescription=theDescription.Substitute(\"'\",\"\")\n      '*** line 2.... has lat lon points\n      ''*** read the rest of the file to get the lat/lon points\n      theLineB=theLineB+1\n      theLatList={}\n      theLonList={} \n      while(theLineListA.get(theLineB).get(0).isNumber)\n         theTempList=theLineListA.get(theLineB) \n         theNumOfPairs=theTempList.Count/2\n      
   for each p in 0..(theNumOfPairs-1)\n            theLat=theTempList.get(p*2).asNumber.setFormatPrecision(4)\n            theLon=theTempList.get(p*2+1).asNumber.setFormatPrecision(4)\n            if(theLon>0)then\n               theLon=(-1.000*theLon).setFormatPrecision(4)\n            end\n            theLatList.Add(theLat)\n            theLonList.Add(theLon)    \n         end\n         theLineB=theLineB+1\n      end\n      '*** get area and elevation information ***'\n      theInfoList=theLineListA.get(theLineB)\n   
   theICount=theInfoList.Count\n      if(theICount>=2)then\n         theAreaString=theInfoList.get(1)\n         theBeg=theAreaString.Indexof(\"(\")\n         theEnd=theAreaString.Indexof(\")\")\n         theNChars=theEnd-theBeg \n         theArea=theAreaString.Middle(theBeg+1,theNChars-1).asNumber\n      else\n         theArea=-999\n      end\n      if(theICount>=3)then\n         theElevationString=theInfoList.get(2) \n         theBeg=theElevationString.Indexof(\"(\")\n         theEnd=theElevationString.Indexof(\")\")\n         
theNChars=theEnd-theBeg\n         theElevation=theElevationString.Middle(theBeg+1,theNChars-1).asNumber\n      else\n         theElevation=-999\n      end\n      theValuesT={theBasinName,theDescription,theArea,theElevation}\n      for each v in theValuesT\n         theValues.Add(v)\n      end\n      theExtraFields={\"Basin_Name\",#FIELD_CHAR,8,0,\"Description\",#FIELD_CHAR,20,0,\"Area_[KM^2]\",#FIELD_LONG,6,0,\"Mean_Elevation_[M]\",#FIELD_LONG,6,0}\n      theCountL=theLatList.Count\n      theList={}\n      thePList={}\n      th
ePolygon=Polygon.MakeNull\n      for each r in 0..(theCountL-1)   \n         theList.Add(Point.Make(theLonList.get(r),theLatList.get(r)).returnProjected(theAprj)) \n      end\n      thePList.Add(theList)\n      thePolygonList.Add(Polygon.Make(thePList))\n      theLineB=theLineB+1\n      if(theLineB=theTotalLines)then\n         theLineB=0\n      end\n   end\n   thePolygon=av.Run(\"mapx.util.ThemeCreating\",{theAreaName+\".shp\",Polygon,theExtraFields,theValues,thePolygonList})\n   theView.AddTheme(thePolygon)\n   thePos=0\nen
d\nav.clearMsg\n\nr = theView.ReturnExtent\n\nif (r.IsEmpty) then\n  return nil\nelseif ( r.ReturnSize = (0@0) ) then\n  theView.GetDisplay.PanTo(r.ReturnOrigin)\nelse\n  theView.GetDisplay.SetExtent(r.Scale(1.1))\n  av.GetProject.SetModified(true)\nend\n\ntheView.Invalidate"
)

(Script.444
	Name:	"mapx.importall.click"
	SourceCode:	"theProject=av.getProject\ntheView=av.getActiveDoc\ntheDialog=av.FindDialog(\"ofs-mapx-dump\")\ntheListBox=theDialog.FindByName(\"mapxdumplist\")\ntheBox=theListBox.returnBox\ntheOrigin=0@0 \ntheRowCount=theListBox.getRowCount\ntheRect=Rect.Make(theOrigin,1@theRowCount)\ntheListBox.setSelection(theRect,FALSE)\ntheList=theListBox.getSelection\nav.Run(\"mapx.import.click\",{}) "
)

(Script.445
	Name:	"mapx.listbox.apply"
	SourceCode:	"theDialog=SELF.getDialog \nif(theDialog.getName.Contains(\"mapx\"))then\n   mapx=\"yes\"\nelse\n   mapx=\"no\"\nend\ntheView=av.getActiveDoc\nif(theView.getClass.getClassName<>\"view\")then\n   msgBox.Error(\"a View must be the active document\",\"ERROR\")\n   exit\nend\ntheDictionary=theDialog.getObjectTag\n\ntheInputBasinTheme=theDialog.FindByName(\"inputbasintheme\")\ntheBasinIdField=theDialog.FindByName(\"basinidfield\")\ntheBasinDescriptionField=theDialog.FindByName(\"basindescriptionfield\")\ntheBasinMeanElevationField=theDialog.FindB
yName(\"basinmeanelevationfield\")\n \n'***Text Boxes***'\ntheBasinID=theDialog.FindByName(\"basinid\")\ntheBasinDescription=theDialog.FindByName(\"basindescription\")\ntheMapxDescription=theDialog.FindByName(\"mapxdescription\")\ntheMapxId=theDialog.FindByName(\"mapxid\")\n\n'***List Boxes***'\ntheListBox=theDialog.FindByName(\"1hrmapxListBox\")\n  \ntheList=theListBox.getList\ntheBasinThemeName=theDictionary.Get(\"BASINTHEME\")\nif(theInputBasinTheme.isSelected)then\n   theInputBasinThemeNameS=theList.get(theListBox.getCurrentRow).a
sString\n   theDictionary.Set(\"BASINTHEME\",theInputBasinThemeNameS.Extract(0))\nelseif(theBasinIdField.isSelected and (theBasinThemeName<>\"\"))then\n   if(theListBox.getCurrentRow=0)then\n      theBasinIdFieldS=theList.get(theListBox.getCurrentRow).asString     \n      theDictionary.Set(\"BASINIDFIELD\",theBasinIdFieldS)\n      theListBox.setVisible(FALSE)\n      theBasinId.setVisible(TRUE)\n   elseif((theListBox.getCurrentRow=1) AND (mapx=\"yes\"))then\n      theBasinIdFieldS=theList.get(theListBox.getCurrentRow).asStri
ng\n      theDictionary.Set(\"BASINIDFIELD\",theBasinIdFieldS)\n      theListBox.setVisible(FALSE)\n      theBasinId.setVisible(TRUE)\n      theBasinId.setText(theMapxId.getText.Trim)\n      theBasinIdText=theBasinId.getText\n      theDictionary.Set(\"BASINID\",theBasinIdText) \n   else\n      theBasinIdFieldS=theList.get(theListBox.getCurrentRow).asString\n      theDictionary.Set(\"BASINIDFIELD\",theBasinIdFieldS)\n      theDictionary.Set(\"BASINID\",\"\")\n      theTheme=theView.FindTheme(theBasinThemeName)\n      theFtab=theT
heme.getFtab\n      theField=theFtab.FindField(theBasinIdFieldS)\n      theList={}\n      for each rec in theFtab.getSelection\n         theName=theFTab.returnValueString(theField,rec)\n         theList.Add(theName)\n      end\n   end\nelseif(theBasinDescriptionField.isSelected and (theBasinThemeName<>\"\"))then\n   if(theListBox.getCurrentRow=0)then\n      theBasinDescriptionFieldS=theList.get(theListBox.getCurrentRow).asString\n      theDictionary.Set(\"BASINDESCRIPTIONFIELD\",theBasinDescriptionFieldS)\n      theListBox
.setVisible(FALSE)\n      theBasinDescription.setVisible(TRUE)\n   elseif((theListBox.getCurrentRow=1) AND (mapx=\"yes\"))then\n      theBasinDescriptionFieldS=theList.get(theListBox.getCurrentRow).asString\n      theDictionary.Set(\"BASINDESCRIPTIONFIELD\",theBasinDescriptionFieldS)\n      theListBox.setVisible(FALSE)\n      theBasinDescription.setVisible(TRUE)\n      theBasinDescription.setText(theMapxDescription.getText)\n      theBasinDescriptionText=theBasinDescription.getText\n      theDictionary.Set(\"BASINDESCRIP
TION\",theBasinDescriptionText)\n   else\n      theBasinDescriptionFieldS=theList.get(theListBox.getCurrentRow).asString    \n      theDictionary.Set(\"BASINDESCRIPTIONFIELD\",theBasinDescriptionFieldS)\n      theDictionary.Set(\"BASINDESCRIPTION\",\"\")\n   end\nelseif(theBasinMeanElevationField.isSelected and (theBasinThemeName<>\"\"))then   \n   theBasinMeanElevationFieldS=theList.get(theListBox.getCurrentRow).asString    \n   theBasinThemeName=theDictionary.Get(\"BASINTHEME\")\n   theBasinTheme=theView.FindTheme(theBasinTh
emeName)\n   theField=theBasinTheme.getFtab.FindField(theBasinMeanElevationFieldS)\n   if(theField<>NIL)then\n   'if(theBasinMeanElevationFieldS=\"NONE (Select DEM to compute)\")then\n      theDictionary.Set(\"BASINMEANELEVATIONFIELD\",theBasinMeanElevationFieldS)\n      theDictionary.Set(\"BASINMEANELEVATION\",\"\")\n    else\n      theDictionary.Set(\"BASINMEANELEVATIONFIELD\",\"\")'theBasinMeanElevationFieldS)\n      theDictionary.Set(\"BASINMEANELEVATION\",theBasinMeanElevationFieldS)\n   end\n   theBasinMeanElevationField.Cli
ck   \nend\n'***Turn on basinid and basindescription radio buttons***'\ntheBasinThemeName=theDictionary.Get(\"BASINTHEME\")\ntheBasinTheme=theView.FindTheme(theBasinThemeName)   \nif(theBasinTheme<>NIL)then \n   theBasinIdField.setEnabled(TRUE)\n   theBasinDescriptionField.setEnabled(TRUE)\n   theBasinMeanElevationField.setEnabled(TRUE)\nend\n\n\n\n\n\n\n"
)

(Script.446
	Name:	"mapx.listbox.update"
	SourceCode:	"theDialog=SELF.getDialog \nif(theDialog.getName.Contains(\"mapx\"))then\n   mapx=\"yes\"\nelse\n   mapx=\"no\"\nend\ntheView=av.getActiveDoc\nif(theView.getClass.getClassName<>\"View\")then\n   msgBox.Error(\"a View must be the active document\",\"Error\")\n   exit\nend\ntheDictionary=theDialog.getObjectTag\n\n'***Radio Buttons***'\n\ntheInputBasinTheme=theDialog.FindByName(\"inputbasintheme\")\ntheBasinIdField=theDialog.FindByName(\"basinidfield\")\ntheBasinDescriptionField=theDialog.FindByName(\"basindescriptionfield\")\ntheBasinMeanElevati
onField=theDialog.FindByName(\"basinmeanelevationfield\")\n\n'***Text Boxes***'\ntheBasinID=theDialog.FindByName(\"basinid\")\ntheBasinDescription=theDialog.FindByName(\"basindescription\")\n\n\n'***List Boxes***'\ntheListBox=theDialog.FindByName(\"1hrmapxListBox\")\n \ntheBasinThemeName=theDictionary.Get(\"BASINTHEME\")\ntheBasinIdFname=theDictionary.Get(\"BASINIDFIELD\")\ntheBasinDescriptionFname=theDictionary.Get(\"BASINDESCRIPTIONFIELD\")\ntheBasinMeanElevationFName=theDictionary.Get(\"BASINMEANELEVATIONFIELD\")\n \n'***Decide which 
controls to show/not show***' \ntheListBox.setVisible(TRUE)\ntheBasinID.setVisible(FALSE)\n \nif(theDialog.getName.Contains(\"dump\").not)then\n   theBasinDescription.setVisible(FALSE)\nend\ntheBasinTheme=theView.FindTheme(theBasinThemeName)\nif(theBasinTheme=NIL)then \n   theBasinIdField.setEnabled(FALSE)\n   theBasinDescriptionField.setEnabled(FALSE)\n   theBasinMeanElevationField.setEnabled(FALSE)\nend\n\nif(theInputBasinTheme.isSelected)then\n   theNList={}\n   theList=theView.getThemes\n   for each t in theList\n      if(
t.getClass.getClassName=\"FTHEME\")then\n         theName=t.getName\n         theFtab=theView.FindTheme(theName).getFtab\n         theTotal=theFtab.getNumRecords.asString\n         theNumSels=theFtab.getNumSelRecords.asString\n         theString=theName++\"(\"+theNumSels++\"out of\"++theTotal++\"records selected)\"\n         theNList.Add(theString)\n      end\n    end   \n   theListBox.defineFromList(theNList)\n   if(theBasinThemeName<>\"\")then\n      theFList={}\n      for each t in theList\n         theFList.add(t.getName)\n   
   end          \n      theNum=theFList.FindByValue(theBasinThemeName)\n      theListBox.goRow(theNum)\n      theListBox.selectCurrent(TRUE)\n   end          \nelseif(theBasinIdField.isSelected)then\n   theList=theBasinTheme.getFtab.getFields\n   theFList={}\n   for each f in theList\n      theFList.add(f.getAlias)\n   end          \n   if(mapx=\"yes\")then\n      theFList.Insert(\"NONE (Use MAPX ID)\")\n   end\n   theFList.Insert(\"NONE (Enter Basin ID)\")\n   if(theBasinIdFname<>\"\")then\n      theListBox.defineFromList(theFLis
t)\n      theNum=theFList.FindByValue(theBasinIdFName)\n      theListBox.goRow(theNum)\n      theListBox.selectCurrent(TRUE)\n   else\n      theListBox.defineFromList(theFList)\n   end   \nelseif(theBasinDescriptionField.isSelected)then\n   theList=theBasinTheme.getFtab.getFields\n   theFList={}\n   for each f in theList\n      theFList.add(f.getAlias)\n   end          \n   if(mapx=\"yes\")then\n      theFlist.Insert(\"NONE (Use MAPX Description)\")\n   end\n   theFList.Insert(\"NONE (Enter Basin Description)\")\n   if(theBasinDe
scriptionFname<>\"\")then\n      theListBox.defineFromList(theFList)\n      theNum=theFList.FindByValue(theBasinDescriptionFName)\n      theListBox.goRow(theNum)\n      theListBox.selectCurrent(TRUE)\n   else\n      theListBox.defineFromList(theFList)\n   end   \nelseif(theBasinMeanElevationField.isSelected)then\n   theList=theListBox.getList\n   theBasinMeanElevation=theDictionary.Get(\"BASINMEANELEVATION\")\n   theBasinMeanElevationField=theDictionary.Get(\"BASINMEANELEVATIONFIELD\")\n   theFList={}\n   for each t in theLis
t\n      theFList.add(t)\n   end          \n   if(theBasinMeanElevationField=\"\")then\n      theNum=theFList.FindByValue(theBasinMeanElevation)\n   else\n      theNum=theFlist.FindByValue(theBasinMeanElevationField)\n   end\n      theListBox.goRow(theNum)\n   theListBox.selectCurrent(TRUE)\nend\n \n\n\n\n\n\n"
)

(Script.447
	Name:	"mapx.setdefineinfo.click"
	SourceCode:	"theDialog=av.FindDialog(\"ofs-mapx-define\")\n'***Set menu Option as object tag\ntheView=av.getActiveDoc\nif(theView.getClass.getClassName<>\"View\")then\n   msgBox.Error(\"a View must be the active document\",\"ERROR\")\n   exit\nend\n\ntheListBox=theDialog.findByName(\"1hrmapxlistbox\")\ntheListBox.Update \ntheDialog.open\n\ntheThemes=theView.getThemes\n'*** Check to see if Hrapp in view ***\nif(theThemes.Count=0)then\n      haveHrapp=FALSE\nend\nfor each t in theTHemes\n   if(t.getName=\"hrappts.shp\")then\n      haveHrapp=TRUE\n      
Break\n   else\n      haveHrapp=FALSE\n   end\nend\nif(haveHrapp.not)then\n   subView=av.Getactivedoc\n   if(subView.Is(View).not)then\n      msgBox.Error(\"A view must be the active document\",\"\")\n      exit\n   end\n   atag=subView.GetObjectTag\n   if (atag=nil) then\n      'msgbox.info(\"Problem with View.\",\"\")\n      exit\n   end\n\n   if (atag.Is(Dictionary).not) then\n      'msgbox.info(\"Problem with View.\",\"\")\n      exit\n   end\n\n   parView=atag.Get(\"Parent View\")\n   if(parView.Is(View).not)then\n      exit\n   end\n   theI
nputDataDir = parView.GetObjectTag.Get(\"Input Directory\")\n   theFileName=(theInputDataDir+\"/hrappts.shp\")\n   theHrappSrc=SrcName.Make(theFileName)\n   if(theHrappSrc=Nil)then    \n      theThemeSrcList=SourceDialog.Show(\"\")\n      if(theThemeSrcList.Count=0)then\n         msgBox.Error(\"Must select an hrapp theme\",\"Need Hrapp Data\")\n         exit\n      end\n      theHrappSrc=theThemeSrcList.get(0)\n   end \n   theHrappftab=Ftab.Make(theHrappSrc)\n   theHrappTheme=Ftheme.Make(theHrappftab)\n   theView.addTheme(theHrap
pTheme)\nend  \n\n\n\n\n\n\n\n"
)

(Script.448
	Name:	"mapx.setdeleteinfo.click"
	SourceCode:	"theDialog=av.FindDialog(\"ofs-mapx-delete\")\n'******\n\n'***Set menu Option as object tag\ntheView=av.getActiveDoc\nif(theView.getClass.getClassName<>\"View\")then\n   msgBox.Error(\"a View must be the active document\",\"ERROR\")\n   exit\nend\ntheThemes=theView.GetThemes\ntheDictionary=theDialog.getObjectTag\nif(theDictionary=NIL)then\n   msgBox.Error(\"Your must first run the Load OFS Basins and Areas script\",\"Error in\"++Script.The.getName)\n   exit\nend\ntheDialog.open\ntheList=theDictionary.Get(\"MAPXAREALIST\")\ntheListBox=theD
ialog.FindByName(\"mapxdeletelist\")\ntheListBox.defineFromList(theList)"
)

(Script.449
	Name:	"mapx.setdumpinfo.click"
	SourceCode:	"theDialog=av.FindDialog(\"ofs-mapx-dump\")\n'******\n\n'***Set menu Option as object tag\ntheView=av.getActiveDoc\nif(theView.getClass.getClassName<>\"View\")then\n   msgBox.Error(\"a View must be the active document\",\"ERROR\")\n   exit\nend\ntheThemes=theView.GetThemes\ntheDictionary=theDialog.getObjectTag\nif(theDictionary=NIL)then\n   msgBox.Error(\"Your must first run the Load OFS Basins and Areas script\",\"Error in\"++Script.The.getName)\n   exit\nend\ntheDialog.open\ntheList=theDictionary.Get(\"MAPXAREALIST\")\ntheListBox=theDia
log.FindByName(\"mapxdumplist\")\ntheListBox.defineFromList(theList)"
)

(Script.450
	Name:	"mapx.util.themecreating"
	SourceCode:	"'****************************************\n'Util.ThemeCreating\n'\n'input: theName,theType,theExtraFields,theValues,theList\n'output: theTheme\n'****************************************\n\n\n'This is a utility program for creating shapefiles it expects\n'{STRING theName, STRING theType, LIST theFields. LISTofLIST theValues LIST theList}\n\ntheName = SELF.get(0) ' the name of the shapefile\ntheType = SELF.get(1) ' the type of shapefile\ntheExtraFields = SELF.get(2) ' name and property of table fields other than id and sh
ape\ntheValues = SELF.get(3) ' value for table fields other than id and shape\ntheList = SELF.get(4) ' List containing shape information \n\nmyProj = av.GetProject\ntheView = av.GetActiveDoc\nthePrj = theView.GetProjection\nnewDir=myProj.GetWorkDir\nif(newDir.IsDir.Not) Then\n  msgBox.Error(newDir++\"is not a valid directory:Check to make sure directories exist\",\"Error in\"++Script.The.getName)\n  exit\nend\nnewDir.SetCWD\n  \n\ntheFileName = Filename.Make(theName)\nif (theFileName = nil) then\n  exit\nend\ntheFileName.setExten
sion(\"shp\")\ntheFtab = FTab.makeNew(theFileName, theType)\ntheTheme = FTheme.make(theFTab)\ntheTheme.setVisible(true)\n\ntheThemeFields = List.make\ntheThemeFields.add(Field.make(\"ID\", #FIELD_SHORT, 16, 0))\n\nif(theExtraFields.IsEmpty.not)then\n   theNum = (theExtraFields.Count)/4\n   for each f in 0..(theNum-1)\n      theThemeFields.add(Field.make(theExtraFields.get(f*4), theExtraFields.get(f*4+1), theExtraFields.get(f*4+2), theExtraFields.get(f*4+3)))\n   end\nend\n\ntheFieldsC = theThemeFields.deepClone\ntheFTab.addFie
lds(theFieldsC)\nif (theFTab.canEdit) then\n  theFTab.setEditable(true)\nelse\n  MsgBox.info(\"Can't edit the output theme\", \"Error\")\n  exit\nend\n\nshapeField = theFTab.findField(\"Shape\")\nIDField = theFTab.findField(\"ID\")\ntheAddField = {}\nif(theExtraFields.isEmpty.not)then\n   theNum = (theExtraFields.Count)/4\n   for each f in 0..(theNum-1)\n      theAddField.Add(theFTab.findField(theExtraFields.get(f*4)))\n   end\nend\n\ntheTheme.getFTab.beginTransaction\nfor each i in 0..(theList.count-1)\n   rec = theFTab.addRecord\n   
theFTab.setValue(IDField, rec, i)\n   if(thePrj.isNull)then\n      theFTab.setValue(shapeField, rec, theList.get(i))\n   else     \n      theFTab.setValue(shapeField, rec, theList.get(i).returnUnprojected(thePrj))\n   end\n   if(theExtraFields.isEmpty.Not)then\n      for each j in 0..(theAddField.Count-1)\n         theFTab.setValue(theAddField.get(j), rec, theValues.get(i*theAddField.Count+j))\n      end\n   end\nend\ntheTheme.getFTab.endTransaction\ntheTheme.getFTab.getSelection.clearAll\ntheTheme.getFTab.updateSelectio
n\nav.getProject.setModified(true)\ntheFTab.setEditable(false)\ntheTheme.StopEditing(TRUE)\nreturn theTheme\n\n\n\n\n\n\n"
)

(Script.451
	Name:	"mapx.weed_to_Xkm"
	SourceCode:	"theDictionary=SELF.Get(0) \nhrapTheme=SELF.Get(1)\n'*** Get the view and its projection***\ntheView = av.GetActiveDoc\nthePrj = theView.GetProjection\nif (thePrj.IsNull) then\n  hasPrj = false\nelse\n  hasPrj = true\n  thePrj = theView.GetProjection\nend\n\n'***Get active themes***\ntheThemes = theView.GetActiveThemes\n\nif (theThemes.Count < 1) then\n  MsgBox.Error(\"Basin theme not defined\",\"*** Error ***\")\n  exit\nend\n\n' Process the active theme\nfor each t in theThemes\n  ' Check that the theme is of the correct type\n  if 
(t.Is( FTHEME).Not) then\n    MsgBox.Error (t.GetName++\"is not a polyline or polygon theme\",\"*** Error ***\")\n    exit\n  end\n\n  theClassName = t.GetFTab.GetShapeClass.GetClassName\n  if ((theClassName = \"Polygon\").Not and (theClassName = \"Polyline\").Not) then\n    MsgBox.Error (t.GetName++\"is not a polyline or polygon theme\",\"*** Error ***\")\n    continue\n  end\n\n  ' Get a tolerance in (distance units) to be used (must be > 0)\n  theOTol = 0.01\n  theMUnits = theView.GetDisplay.GetUnits\n\n  'weed to X km - star at .
01 and increase by .1 if necessary\n  theDUnits = #UNITS_LINEAR_KILOMETERS 'theView.GetDisplay.GetDistanceUnits\n  theUStr = Units.GetFullUnitString(theDUnits).LCase\n      \n  ' Get the name for a new theme, from View.Export script\n\n'  def = FileName.Make(theNewName+\".shp\") \n'  def = FileDialog.Put(def, \".shp\", \"New file for simplified \"+ t.getName)\n  \n   \n'  if (def = NIL) then return nil end\n\n  ' Create a new shapefile theme, from View.Export script\n  anFtab = t.GetFtab\n  shpfld = (anFtab.FindField(\"Shape\"))
\n  if (shpfld.IsVisible.Not) then\n    shpfld.SetVisible(shpfld.IsVisible.Not)\n    WasNotVisible = TRUE\n  else\n    WasNotVisible =FALSE\n  end\n\n  ' This will only export the selected shapes, if any have been selected\n\n  av.ShowMsg(\"Creating new shape file from\"++ t.GetName)\n   \n  if (WasNotVisible) then\n    shpfld.SetVisible(FALSE)\n  end\n\n  ' Find the shape field\n  theSField = anFtab.FindField(\"Shape\")\n\n  ' Set up status bar\n  av.ShowMsg(\"Generalizing new shapes from theme\"++ t.GetName)\n  theSize = anFTab.Get
NumSelRecords\n  if(theSize=0)then\n     msgBox.Error(\"Must select a group of areas to export\",\"Error\")\n     exit\n  end\n  cnt=0\n  thePolygonList={}\n  theValueList={}\n  theTypeList={}\n  for each r in anFTab.getSelection\n    theTotalList = av.Run(\"mapx.addFields\",{theDictionary,anFtab,r})\n    if(theTotalList.Count<>0)then\n       theFTypeList=theTotalList.get(0)\n       theValueList.Add(theTotalList.get(1))\n    end\n    ' Retrieve shape\n    if (theClassName = \"Polygon\") then\n      theOShape = Polygon.MakeNull\n    
else\n      theOShape = Polyline.MakeNull\n    end \n    anFTab.QueryShape(r,theView.GetProjection,theOShape)\n    ' Process each list in the ListofListofPoints    \n    av.setStatus(0)   \n    theCount=theOShape.asList.Count       \n    for each p in theOShape.AsList\n       ' Make a list for collecting the new set of point lists\n       theNShape = List.Make\n       av.setStatus((cnt/theCount)*100)\n       '***Process each shape, make sure no. of points <500***'\n       theNumOfPoints=9999\n       while(theNumOfPoints
>=500)\n         theTol = Units.Convert(theOTol,theDUnits,theMUnits) \n         ' Make a list for collecting the vertices to keep\n         theNList = List.Make\n         ' Set up stack for holding a set of lists of form {index,point}\n         theStack = Stack.Make\n         ' Add first point to the list being assembled, and make it the anchor\n         theAnchor = p.Get(0)\n         if (hasPrj) then\n            theNList.Add(theAnchor.ReturnUnProjected(thePrj))\n         else\n            theNList.Add(theAnchor)\n   
      end\n         aIndex = 0\n\n         ' Add last point to stack\n         fIndex = p.Count - 1\n         theStack.Push({fIndex,p.Get(fIndex)})\n\n         ' Process the points with the Douglas - Peucker approach\n         while (theStack.IsEmpty.Not)\n            ' Process from Anchor (beginning) to Floater (top of stack)\n            fIndex = theStack.Top.Get(0)\n\n            ' Create graphic shape for comparing distances\n            theVect = Line.Make(theAnchor,theStack.Top.Get(1))\n\n            ' Initialize va
lues for comparison\n            theMax = theTol\n            mxIndex = 0\n            ' Find distance\n            for each i in (aIndex + 1) .. (fIndex - 1) ' process middle points\n               dist = theVect.Distance(p.Get(i))\n               ' Check against previous maximum\n               if (dist >= theMax) then  ' this point is out of the tolerance\n                  theMax = dist\n                  mxIndex = i\n               end\n            end\n            ' If a vertex is found outside the current tolera
nce corridor,\n            ' push it onto the stack\n\n            if (mxIndex > 0) then 'a new floater has been found\n               theStack.Push({mxIndex,p.Get(mxIndex)})\n            else  ' add floater to the list for the new shape and move forward\n               if (hasPrj) then\n                  theNList.Add(theStack.Top.Get(1).ReturnUnProjected(thePrj))\n               else\n                  theNList.Add(theStack.Top.Get(1))\n               end\n               ' Make the floater the new anchor\n            
   theAnchor = theStack.Pop.Get(1)\n               aIndex = fIndex\n            end\n         end\n         ' Check for collapsed polygons\n         if ((theNList.Count < 4) and (theClassName = \"Polygon\")) then\n            ' Revert to original polygon\n            if (hasPrj) then\n               theNList = List.Make\n               for each pt in p\n                  theNList.Add(pt.ReturnUnProjected(thePrj))\n                end\n            else\n               theNList = p\n            end\n         end\n         ' Fi
nish up individual lists\n         newCount = theNList.Count\n      \n         '***Make sure newCount<500***'\n         theNumOfPoints=newCount\n         if(theNumofPoints>=500)then \n            theOTol=theOTol+0.1\n         else\n            theOTol=0.01\n         end    \n      end  '***this is end of while loop i added\n      '*** check for duplicate points ***'\n      theClist={}\n      for each pt in theNList\n         theCoord=(pt.getx.asString)+\"/\"+(pt.gety.asString)\n         theCList.Add(theCoord)\n      end\n    
  theCCList=theCList.deepClone\n      theCCList.removeDuplicates\n      thePointList={}\n      for each l in theCClist\n         theCoordList=l.asTokens(\"/\")\n         theX=theCoordList.get(0).asNumber.setFormatPrecision(4)\n         theY=theCoordList.get(1).asNumber.setFormatPrecision(4)\n         thePointList.Add(Point.Make(theX,theY))\n      end\n      '*** end of check for duplicate points ***\n      theNShape.Add(thePointList)\n      'Finish up the shape\n      if (theClassName = \"Polygon\") then\n         theNewSha
pe = Polygon.Make(theNShape)\n      else\n         theNewShape = Polyline.Make(theNShape)\n      end\n      cnt=cnt+1\n      thePolygonList.Add(theNewShape)  \n          end '*** this is end of for loop on sub-basins      \n    '*** check to see if any basinvalues were read from table fields\n  end '***this is end of for loop on records \n  ' Clear status message\n  av.ClearMsg\n  anFTab.SetEditable(false)\nend\n\n'*** make sure rings that contain hrapp points are not included ***'\nhrapFtab=hrapTheme.getFtab\ntheFPolygonL
ist={}\ntheFValueList={}\ntheCount=thePolygonList.Count\nkeep=\"yes\"\nfor each i in 0..(theCount-1) \n   thePolygon=thePolygonList.get(i)\n   for each j in 0..(theCount-1) \n      if(j=i)then\n         continue\n      end\n      thePolygonB=thePolygonList.get(j)\n      if(thePolygon.Contains(thePolygonB))then\n         hrapTheme.ClearSelection\n         hrapTheme.selectByPolygon(thePolygonB,#VTAB_SELTYPE_NEW )\n         if(hrapFtab.getSelection.Count<>0)then\n            thePolygon=thePolygon.returnDifference(thePolygonB)\n
            keep=\"Yes\"\n            msgBox.Warning(\"The basin contains inner holes.  It will not define correctly\"++\n            \"in PPINIT\",\"Warning in:\"++Script.The.getName)\n         end\n      elseif(thePolygon.isContainedIn(thePolygonB))then\n         keep=\"No\"\n         Break\n      else\n         keep=\"Yes\"\n      end\n   end\n   if(keep=\"Yes\")then\n      thePolygon=thePolygon.Clean\n      theFpolygonList.Add(thePolygon)\n      if(theFTypeList.Count<>0)then\n         theList=theValueList.Get(i)\n         theCountB=
theList.Count\n         for each v in 0..(theCountB-1)\n            theFvalueList.Add(theList.Get(v))\n         end\n      end\n   end\nend\n'**************************************************\ntheReturnList={theFPolygonList,theFTypeList,theFvalueList}\nreturn theReturnList\n\n\n\n\n\n\n\n\n"
)

(Script.452
	Name:	"mat.setdefineinfo.click"
	SourceCode:	"32"
)

(Script.453
	Name:	"mat.setdeleteinfo.click"
	SourceCode:	"32"
)

(Script.454
	Name:	"mat.setdumpinfo.click"
	SourceCode:	"32"
)

(Script.455
	Name:	"ofs.checkbox.click"
	SourceCode:	"'ofs.checkbox.click\ntheDialog=SELF.getDialog\n\ntheDefineCheckBox=theDialog.FindByName(\"Define\")\ntheDeleteCheckBox=theDialog.FindByName(\"Delete\")\ntheDumpCheckBox=theDialog.FindByName(\"Dump\")\n\ntheName=Self.getName\n\nif(theName=\"Define\")then\n   theDeleteCheckBox.setSelected(FALSE)\n   theDumpCheckBox.setSelected(FALSE)\nelseif(theName=\"Delete\")then\n   theDefineCheckBox.setSelected(FALSE)\n   theDumpCheckBox.setSelected(FALSE)\nelse\n   theDeleteCheckBox.setSelected(FALSE)\n   theDefineCheckBox.setSelected(FALSE)\nend\n"
)

(Script.456
	Name:	"ofs.dialog.close"
	SourceCode:	"theDialog=SELF.getDialog\ntheDialog.Close\ntheListBox=theDialog.findByName(\"ofslistbox\")\ntheList={}\ntheListBox.defineFromList(theList)\n"
)

(Script.457
	Name:	"ofs.dialog.open"
	SourceCode:	"theDialog=av.findDialog(\"ofs-ppinit\")\ntheDialog.open"
)

(Script.458
	Name:	"ofs.dialog.update"
	SourceCode:	"theDialog=av.FindDialog(\"ofs-basin-dump\")\ntheDictionary=theDialog.getObjectTag\nif(theDictionary=NIL)then\n   enabled=FALSE\nelse\n   enabled=TRUE\nend\nSELF.setEnabled(enabled)"
)

(Script.459
	Name:	"ofs.listbox.apply"
	SourceCode:	"theListBox=SELF\ntheDialog=SELF.getDialog\ntheDefineCheckBox=theDialog.FindByName(\"Define\")\ntheDeleteCheckBox=theDialog.FindByName(\"Delete\")\ntheDumpCheckBox=theDialog.FindByName(\"Dump\")\ntheNumber=theListBox.getCurrentRow\ntheList=theListBox.getList\ntheType=theList.get(theNumber)\nif(theDefineCheckBox.isSelected)then\n   theCommand=\"define\"\nelseif(theDeleteCheckBox.isSelected)then\n   theCommand=\"delete\"\nelseif(theDumpCheckBox.isSelected)then\n   theCommand=\"dump\"\nelse\n   msgBox.Error(\"Must Select an OFS Command (D
efine, Delte, or Dump)\",\"\")\nend\ntheScriptName=thetype+\".set\"+theCommand+\"info.click\"\ntheDialog.Close\ntheList={}\ntheListBox.defineFromList(theList)\nav.Run(theScriptName,\"\")"
)

(Script.460
	Name:	"ofs.listbox.update"
	SourceCode:	"theListBox=SELF\ntheBroadcaster=theListBox.getBroadcaster\ntheName=theBroadcaster.getName\nif(theName=(\"area\"))then\n    theList={\"FMAP\",\"MAP\",\"MAPX\",\"MAT\",\"MAPE\"}\nelseif(theName=(\"basin\"))then\n    theList={\"BASIN\"}\nelseif(theName=(\"station\"))then\n   theList={\"PCPN\",\"TEMP\",\"PE\",\"RRS\"}\nend\ntheListBox.defineFromList(theList)\n"
)

(Script.461
	Name:	"ofs.radiobutton.click"
	SourceCode:	"theDialog=SELF.getDialog\ntheName=theDialog.getName\nif(theName.Contains(\"define\"))then\n   theString=\"define\"\nelseif(theName.Contains(\"delete\"))then\n   theString=\"delete\"\nelse\n   theString=\"dump\"\nend\ntheListBox=theDialog.findByName(\"ofslistbox\")\nSelf.setListeners({theListBox})\nSelf.broadcastUpdate"
)

(Script.462
	Name:	"util.calculatefeaturegeometrysub"
	SourceCode:	"'#---------------------------------------------------------------------------\n' Name:  util.calculatefeaturegeometrysub\n' \n' Description: Slightly modified version of View.CalculateFeatureGeometry\n' that allows this script to be called from another script. \n' The required input FTAB is passed through the SELF object.    \n'--------\n' Name:  View.CalculateFeatureGeometry\n' \n' Title:  Calculates feature geometry values\n'        \n' Topics:  GeoData\n'\n' Description:  Calculates area and perimeter for polygon the
mes and length \n' for line themes. If the View has been projected the calculations are in \n' projected meters. Otherwise the calculations are in 'native' map units.\n' Modify the script to provide calculation in the current report units of\n' the View. The script processes the list of active themes to calculate \n' area and perimeter, or length, depending on the theme type.\n'\n' The script will add the fields: Area and Perimeter to polygon themes, Length\n' to line themes if they do not exist. If the fields exis
t their values will \n' be recalculated. Rerun the script if you change the projection of the view.\n'\n' Requires:  A View with at least one active theme.  You must have write access\n' to the active theme(s).\n'\n' Self:\n'\n' Returns:\n'----------\n'#----------------------------------------------------------------------------\n'\n' Get the view and it's projection if any.\n'\n'theView = av.GetActiveDoc\ntheview=self.get(0)\nthePrj = theView.GetProjection\nif (thePrj.IsNull) then\n  hasPrj = false\nelse\n  hasPrj = true\nend\n
'\n' Get the list of active themes. if there aren't any, let the user know\n' and exit.\n'\n'theActivethemeList = theView.GetActivethemes\n'if (theActivethemeList.Count = 0) then\n'  MsgBox.Error(\"No active themes.\",\"\")\n'  Exit\n'end\n'\n' Loop through the list of active themes. if you can't edit the theme\n' inform the user.\n'\n'For Each thetheme in theActivethemeList\n'thetheme=theview.getactivethemes.get(0)\n \n theftab=self.get(1)  \n   'theFTab = thetheme.GetFTab\n   \n  if (theFTab.CanEdit.Not) then\n    MsgBox.Info(\"C
annot edit table for theme\",\"\")\n  end\n  '\n  ' Make the FTAB editable, and find out which type of feature it is.\n  '\n  theFTab.SetEditable(TRUE)\n  theType = theFTab.FindField(\"shape\").GetType\n  if (theType = #FIELD_SHAPEPOLY) then\n    '\n    ' if it's polygonal check for the existence of the fields \"Area\" and\n    ' Perimeter. if they do not exist, create them.\n    '\n    if (theFTab.FindField(\"Area\") = nil) then\n      theAreaField = Field.Make(\"Area\",#FIELD_DOUBLE,16,3)\n      theFTab.AddFields({theAreaField})\n
    else\n      'ok = MsgBox.YesNo(\"Update Area?\", \"Calculate\", true)\n      'if (ok.Not) then\n        'continue\n      '  exit\n      'end\n      theAreaField = theFTab.FindField(\"Area\")\n    end\n    if (theFTab.FindField(\"Perimeter\") = nil) then\n      thePerimeterField = Field.Make(\"Perimeter\",#FIELD_DOUBLE,16,3)\n      theFTab.AddFields({thePerimeterField})\n    else\n      'ok = MsgBox.YesNo(\"Update Perimeter?\", \"Calculate\", true)\n      'if (ok.Not) then\n      '  continue\n      'end\n      thePerimeterField = the
FTab.FindField(\"Perimeter\")\n    end\n    \n    '\n    ' Loop through the FTAB and find the projected area and perimeter of each \n    ' shape and set the field values appropriately.\n    '\n    theShape = theFTab.ReturnValue(theFTab.FindField(\"shape\"),0)\n    For Each rec in theFTab\n      theFTab.QueryShape(rec,thePrj,theShape)\n      theArea = theShape.ReturnArea\n      thePerimeter = theShape.ReturnLength\n      theFTab.SetValue(theAreaField,rec,theArea)\n      theFTab.SetValue(thePerimeterField,rec,thePerimeter)\n  
  end\n    \n  elseif (theType = #FIELD_SHAPELINE) then\n    '\n    ' if the data source is linear, check for the existence of the \n    ' field \"Length\". if it doesn't exist, create it.\n    '\n    if (theFTab.FindField(\"Length\") = nil) then\n      theLengthField = Field.Make(\"Length\",#FIELD_DOUBLE,16,3)\n      theFTab.AddFields({theLengthField})\n    else\n      'ok = MsgBox.YesNo(\"Update Length?\", \"Calculate\", true)\n      'if (ok.Not) then\n      '  continue\n      'end\n      theLengthField = theFTab.FindField(\"Lengt
h\")\n    end\n     \n    '\n    ' Loop through the FTAB and find the projected length of each shape and set\n    ' the field values appropriately.\n    '   \n    theShape = theFTab.ReturnValue(theFTab.FindField(\"shape\"),0)\n    For Each rec in theFTab\n      theFTab.QueryShape(rec,thePrj,theShape)\n    \n      theLength = theShape.ReturnLength\n      theFTab.SetValue(theLengthField,rec,theLength)\n    end\n    \n  end \n  theFTab.SetEditable(FALSE)\n'end\n"
)

(Script.463
	Name:	"util.coord.hraptoll"
	SourceCode:	"'-----------------------------------------\n' Name: coord.hraptoll\n' Purpose: Convert x,y coordinates from HRAP\n' to longitude,latitude \n' Inputs: lat\n'-----------------------------------------\n'---------------------------------\n' Define HRAP projection constants\n'---------------------------------\nstdlat = 60.asradians\nstdlon = -105\nearthr = 6371200.0\nmesh = 4762.5\nhrapxor = 401\nhrapyor = 1601\n\nhrapx=self.get(0)\nhrapy=self.get(1)\nx = (hrapx - hrapxor)*mesh\ny = (hrapy - hrapyor)*mesh\n    \nbigr = ((x*x) + (y*y
))^0.5\narg = bigr/(earthr*(1 + (stdlat.sin)))\nlat = 90.0 - (2*(arg.atan.asdegrees))\nif ((x<0) and (y<0)) then\n  ang=((((y/x).atan.asdegrees)*(-1)) + 180)*(-1)\nelseif ((x<0) and (y>0)) then\n  ang=((y/x).atan.asdegrees) + 180\nelse\n  ang=(y/x).atan.asdegrees\nend\n'msgbox.info(x.asstring++y.asstring,\"\")\n'msgbox.info(\"ang\"++ang.asstring,\"\")\nif (y>0) then \n  ang = 270.0-stdlon-ang\nelse\n  ang = -90.0-stdlon-ang\nend\nif (ang < 180) then\n  lon = -1 * ang\nelse\n  lon = 360.0 - ang\nend\nreturn {lon,lat}\n"
)

(Script.464
	Name:	"util.createsubbasinviewobjecttag"
	SourceCode:	"'#-----------------------------------------\n' Name:  util.createsubbasinviewobjecttag\n' \n' Description: Use a dictionary to store information\n' for cap subbasin view\n' History: Last modified 4/5/2000 by Ziya, David \n'          Last Modified 8/1/2000\n'          Last Modified 8/3/2000\n'#-----------------------------------------\n\ntheview=self.get(0)\n  \n'tagdict=theview.getobjecttag\n\n'if (tagdict<>nil) then\n'  if (tagdict.getclass.getclassname<>\"Dictionary\") then\n'     msgbox.info(\"View object tag is not a dict
ionary.  Resetting.\",script.the.getname)\n'  elseif (tagdict.get(\"CAPSubbasin\")<>nil) then\n'      'msgbox.info(\"Tag is OK\",script.the.getname)  \n'     'do nothing\n'  else\n'     msgbox.warning(\"View Object Tag is Dictionary but not the correct dictionary. Resetting..\",script.the.getname) \n'  end\n'end\n\n' A dictionary associated with the view stores input and output\n' information\n'pptgList=List.Make   'will contain a list of Filenames\n'tmpgList=List.Make   'will contain a list of Filenames\n'peList=List.Make\n\n'f
or each i in 1..12\n'  pptgList.Add(nil)\n'   tmpgList.Add(nil)\n'   peList.Add(nil)\n'end\n\n'Create CAP dictionary\nsubtagdict=dictionary.make(20)\nsubtagdict.add(\"CAPSubbasin\",true)                 '1              \nsubtagdict.add(\"Parent View\",nil)                  '2  \n'subtagdict.add(\"Subbasin Monthly Ppt\",pptgList)    '3      \n'subtagdict.add(\"Subbasin Monthly Tmp\",tmpgList)    '4\n'subtagdict.add(\"Subbasin Soil Depth\", nil)         '5\n'subtagdict.add(\"Subbasin Slope Grid\",nil)          '6\nsubtagdict.add(\"Subb
asin RF1 Streams\",nil)         '7\nsubtagdict.add(\"Subbasin Polygon\",nil)             '8\n'tagdict.add(\"Subbasin Mask\",nil)             \nsubtagdict.add(\"Subbasin Zone Grid\",nil)           '9\nsubtagdict.add(\"Subbasin Zone Polygons\",nil)       '10\nsubtagdict.add(\"Subbasin Elevation\",nil)           '11\n'subtagdict.add(\"Subbasin Flow Direction\",nil)          '12\n'subtagdict.add(\"Subbasin Flow Accumulation\",nil)       '13        \nsubtagdict.add(\"Subbasin Mean Annual Ppt\",nil)         '14\nsubtagdict.add(\"Subbasin M
ean Annual Tmp\",nil)         '15\nsubtagdict.add(\"Subbasin ID Name\", nil)                '16\n' -- this could also be the forecast group identifier\n'subtagdict.add(\"Subbasin Monthly PE\", peList)          '17\nsubtagdict.add(\"Subbasin Annual PE\",nil)               '18\nsubtagdict.add(\"Subbasin Forest Percent Cover\",nil)    '19\nsubtagdict.add(\"Subbasin Detailed Forest Type\",nil)    '20\n\ntheview.setobjecttag(subtagdict)                 \n \n                 \n \n"
)

(Script.465
	Name:	"util.createviewobjecttag"
	SourceCode:	"'#-----------------------------------------\n' Name:  util.createviewobjecttag\n' \n' Description: Use a dictionary to store input/output \n' information for CAP and ThreshR\n' History: Last modified 4/5/2000 by Ziya, David under Seann's help\n'          Last Modified 8/1/2000\n'#-----------------------------------------\n\ntheview=av.getactivedoc\n  \ntagdict=theview.getobjecttag\n\nif (tagdict<>nil) then\n  if (tagdict.getclass.getclassname<>\"Dictionary\") then\n     msgbox.info(\"View object tag is not a dictionary.  Res
etting.\",script.the.getname)\n  elseif (tagdict.get(\"ThreshR\")<>nil) then\n      'msgbox.info(\"Tag is OK\",script.the.getname)  \n     'do nothing\n  else\n     msgbox.warning(\"View Object Tag is Dictionary but not the correct dictionary. Resetting..\",script.the.getname) \n  end\nend\n\n' A dictionary associated with the view will store input and output\n' information\n\n'Create ThreshR dictionary\ntagdict=dictionary.make(44)\ntagdict.add(\"ThreshR\",true)                  '1\ntagdict.add(\"ModElevation\",nil)              '2\n
tagdict.add(\"Elevation\",nil)                 '3\ntagdict.add(\"Flow Direction\",nil)            '4\ntagdict.add(\"Flow Accumulation\",nil)         '5\ntagdict.add(\"Reference Basins\",nil)          '6\ntagdict.add(\"Reference Stream Lines\",nil)    '7\ntagdict.add(\"Reference Stream Grid\",nil)     '8\ntagdict.add(\"Analysis Polygon Theme\",nil)    '9\ntagdict.add(\"RFC Mask\",nil)                  '10\ntagdict.add(\"Stream Grid\",nil)               '11\ntagdict.add(\"Outlet Grid\",nil)               '12\ntagdict.add(\"Outlet Points\",n
il)             '13\ntagdict.add(\"Subwatershed Polygons\",nil)     '14\ntagdict.add(\"Subwatershed Grid\",nil)         '15\ntagdict.add(\"Stream Lines\",nil)              '16\ntagdict.add(\"State Theme\",nil)               '17\ntagdict.add(\"Region Theme\",nil)              '18\ntagdict.add(\"Downstream Flowlength\",nil)     '19\ntagdict.add(\"Merged Subwatersheds\",nil)      '20\ntagdict.add(\"Data Directory\",nil)            '21\ntagdict.add(\"Zone Theme\",nil)                '22\ntagdict.add(\"Centroids\",nil)                 '23\nta
gdict.add(\"Longest Flow Path\",nil)         '24\ntagdict.add(\"Slope Grid\",nil)                '25\ntagdict.add(\"Run ID\",nil)                    '26\ntagdict.add(\"HRAP Points\",nil)               '27\n\n'---tags added for CAP\ntagdict.add(\"Input Directory\",\"\")            '28\ntagdict.add(\"Output Directory\",\"\")           '29 \ntagdict.add(\"Prism Data Directory\",\"\")       '30 has precip, temp. data\ntagdict.Add(\"Legend Directory\", \"\")          '31 has saved legends and other resources\ntagdict.Add(\"SAC-SMA Directory\",\"\")\n
tagdict.Add(\"PE Data Directory\",\"\")\ntagdict.add(\"Mean Annual Ppt\",nil)        '32\ntagdict.add(\"Mean Annual Tmp\",nil)   '33\ntagdict.add(\"Soil Depth\", nil)               '34\ntagdict.add(\"Selected Sub-basin\",nil)        '35\ntagdict.add(\"RF1 Streams\",nil)               '36\ntagdict.add(\"NOHRSC Basins\",nil)             '37\ntagdict.add(\"Forest Directory\",nil)          '38\ntagdict.add(\"Snow Windows\",nil)              '39\ntagdict.add(\"Snow Directory\",nil)            '40\ntagdict.add(\"Annual PE\",nil)                 '
41\ntagdict.add(\"Forest Percent Cover\",nil)      '42\ntagdict.add(\"Detailed Forest Type\",nil)      '43\n      \ntheview.setobjecttag(tagdict)\n"
)

(Script.466
	Name:	"util.editobjecttags"
	SourceCode:	"'#-----------------------------------------\n' Name:  util.editobjecttags\n' \n' Description: Allow editing of any string object tags \n' If the number of string object tags exceeds 20 \n' the user gets an error message.  \n' History: Create Jan. 5, 2001\n'#-----------------------------------------\n\ntheView=av.GetActiveDoc\ntheDict=theView.GetObjectTag\nif (theDict=nil) then\n   exit\nend\ntheKeys=theDict.ReturnKeys\n\nmsgstring=\"\"\ndefaultList=List.Make\nlabelList=List.Make\nfor each k in theKeys\n   theobj=theDict.Get(k)\n 
  if (theobj.Is(String)) then\n      defaultList.Add(theobj)\n      labelList.Add(k)\n   end\nend\n\nnewTagList=MsgBox.MultiInput(\"Edit Tags\",\"Edit Tags\",labelList,defaultList)\n\nif (newTagList.count<>0) then\n   'msgbox.info(newtaglist.count.asstring,\"\")\n   for each l in labelList\n      lcount=labelList.FindByValue(l)\n      theDict.Set(l,newTagList.Get(lcount))\n   end\nend\n\n"
)

(Script.467
	Name:	"util.getthms"
	SourceCode:	"'#*****************************************\n' Name: Basin.GetThms, Active or All.\n' Headline: \n' Self: {TheView,ThmAct,ThmType,ShpType}\n'  ThmAct=True, for active thms, False, all thms.\n'  ThmType=[FTheme,GTheme,DbTheme]\n'  ShpType=[Poly,Line,Point,Mpoint]\n' Returns: \n' Description: Get Thms of specified type.  \n' Topics:\n' Search Keys:\n' Requires:\n' History: 4/1/97\n'#*****************************************\nTheView=SELF.Get(0)\nThmAct=SELF.Get(1)  'Active/ALL, Boolean.\nThmType=SELF.Get(2) 'GTheme,FTheme or
 others.\nInfoTitle=\"Theme Identification\"\nIsFThm=False\nThmTypeName=ThmType.GetClassName\n\n  if(ThmTypeName=\"FTheme\")then\n    ShpType=SELF.Get(3)  \n    IsFThm=True\n    if(ShpType=\"POLY\")then\n      ShpTypeEnum=\"#FIELD_SHAPEPOLY\".AsEnum\n    elseif(ShpType=\"LINE\")then\n      ShpTypeEnum=\"#FIELD_SHAPELINE\".AsEnum\n    elseif(ShpType=\"POINT\")then\n      ShptypeEnum=\"#FIELD_SHAPEPOINT\".AsEnum \n    elseif(ShpType=\"MPOINT\")then\n      ShpTypeEnum=\"#FIELD_SHAPEMULTIPOINT\".AsEnum \n    else    \n      msgbox.info(\"Use POLY,L
INE,POINT or MPOINT as 3rd argument\",InfoTitle)\n      return nil    \n    end  \n  end\n\n  if(ThmAct)then\n    TheThms=TheView.GetActiveThemes\n  else \n    TheThms=TheView.GetThemes     'Get All Themes\n  end \n   \n  if(theThms.Count=0)then\n    msgbox.info(\"No active themes found in the view:\"++TheView.GetName,InfoTitle)\n    return nil\n  end\n\nThmList=List.Make\n  for each Thm in TheThms\n    if(Thm.Is(ThmType))then\n      if(IsFthm)then  'for an FTheme, further chk its shape type\n        FType=Thm.GetFtab.FindField(\"
Shape\").GetType\n        if(FType=ShpTypeEnum)then\n          ThmList.Add(Thm)\n        end      \n      else\n        ThmList.Add(Thm)\n      end  \n    end\n  end \n  \n  if(ThmList.Count=0)then\n    if(ThmAct)then\n      msgbox.info(\"No Active\"++ThmTypeName++\"theme is found in the view:\"++TheView.GetName,InfoTitle)\n    else\n      msgbox.info(\"No\"++ThmTypeName++\"is found in the view:\"++TheView.GetName,InfoTitle)\n    end\n    return nil\n  else\n    return ThmList  'Normal return\n  end\n"
)

(Script.468
	Name:	"util.legendconversion"
	SourceCode:	"'-------------------------------------\n' Name: util.legendconversion\n'\n' Description:  Transform Legend Labels to be \n' factors of the classification ranges\n'--------------------------------------\ntheView=av.GetActiveDoc\nconvList={\"mm to in\",\"m to ft\",\"same as values\"} \n'convFact={25.4,0.03937,1}\nconvFact={0.03937,3.281,1}\noutUnit={\"in\",\"ft\",\"\"}\nconv=msgbox.ChoiceAsString(convList,\"Choose a conversion for Labels\",\"Units Conversion\")\nif (conv=nil) then\n   exit \nend\nconvindex=convList.FindbyValue(conv)\ncf=con
vFact.Get(convindex)\nfor each t in theView.GetActiveThemes\n   theLegend=t.GetLegend\n   theClassifications=theLegend.GetClassifications\n   count=0\n   for each c in theClassifications\n      count=count+1\n      theMax=c.ReturnMaximum\n      theMin=c.ReturnMinimum\n      if (theMax<>nil) then\n         newMax=theMax*cf\n      end\n      if (theMin<>nil) then\n         newMin=theMin*cf\n      end\n      if (newMin>newMax) then\n         c.SetLabel(\"No Data\")\n      else\n         if (count=1) then\n            c.SetLabel(ne
wMin.setformat(\"d.d\").asString++\"-\"++newMax.SetFormat(\"d.d\").AsString++outUnit.Get(convindex))\n         else\n            c.SetLabel(newMin.setformat(\"d.d\").asString++\"-\"++newMax.SetFormat(\"d.d\").AsString)\n         end\n      end\n   end\n   t.UpdateLegend\nend\n       "
)

(Script.469
	Name:	"util.ofs.loadOfs"
	SourceCode:	"'Neftali Cajina\n'12/6/2002\n\n'this code creates dictionary variables which are object tags for each of the\n'6 dialogs.  For 3 of the dialogs ofs jobs are run to populate list type dictionary \n'variables\nav.ClearMsg\nav.ShowMsg(\"Loading OFS Data\")\n\n'*** create dictionary for define basin dialog ***'\ntheDialog=av.FindDialog(\"ofs-basin-define\")\ntheDictionary=theDialog.getObjectTag\nif((theDictionary.getName=\"basindictionary\").not)then  \n   '***Create a BASIN Dictionary***'\n   theDictionary=Dictionary.Make(9)\n   t
heDictionary.setName(\"basindictionary\")\n   theDictionary.Add(\"BASINTHEME\",\"\")\n   theDictionary.Add(\"BASINIDFIELD\",\"\")\n   theDictionary.Add(\"BASINDESCRIPTIONFIELD\",\"\")\n   theDictionary.Add(\"BASINMEANELEVATIONFIELD\",\"Empty\")\n   theDictionary.Add(\"BASINID\",\"\")\n   theDictionary.Add(\"BASINDESCRIPTION\",\"\")\n   theDictionary.Add(\"BASINMEANELEVATION\",\"\")\n   '***Set object tag parameters***'\n   theDialog.setObjectTag(theDictionary)\nend\n\n'*** create dictionary for dump basin dialog and fill BASINLIST ***'\ntheDialog=av
.FindDialog(\"ofs-basin-dump\")\ntheDictionary=theDialog.getObjectTag\nif((theDictionary.getName=\"basindumpdictionary\").not)then   \n   '***Create a BASIN Dictionary***'\n   theDictionary=Dictionary.Make(2)\n   theDictionary.setName(\"basindumpdictionary\")\n   theDictionary.Add(\"BASINLIST\",{})\n   theDictionary.Add(\"NEWENTRYLIST\",{})\n   theDictionary.Add(\"BASINTOTALLIST\",{})\n   '***Set object tag parameters***'\n   theDialog.setObjectTag(theDictionary)\nend\n'*** run the following ofs command and return the punch file *
**'\ntheString=\"@DUMP PUNCH UNITS(METR) BASIN PUFORMAT(FIXED) PUMAXDEC(4) ALL\"\ntheOfile=av.Run(\"util.RunOFS\",{theString,\"basin\",\"dump\"})\nav.getProject.getWorkDir.SetCWD\ntheExistingDir=Filename.getCWD.asString\ntheTline={}     \ntheOfile.Read(theTline,theOfile.getSize)\ntheLineList={}\ntheBasinList={}\ntheNewEntryList={}\ntheSize=theOfile.getSize\nfor each i in 0..(theSize-1)\n   av.setStatus((i/(theSize-1))*100)\n   theList=theTline.get(i).asTokens(\" \")\n   if(theList.get(0).contains(\"BASN\").not)then\n      theLineList
.Add(theTline.get(i).asTokens(\" \"))\n      continue\n   else\n      theBasinList.Add(theList.get(1))\n      theNewEntryList.Add(i)\n      theLineList.Add(theList)\n   end\nend\ntheDictionary.Set(\"BASINLIST\",theBasinList)\ntheDictionary.Set(\"BASINTOTALLIST\",theLineList)\ntheDictionary.Set(\"NEWENTRYLIST\",theNewEntryList)\ntheBasinList=theDictionary.Get(\"BASINLIST\")\ntheBasinTotalList=theDictionary.Get(\"BASINTOTALLIST\")\n\n'***create a dictionary for define mapx area dialog ***'\ntheDialog=av.FindDialog(\"ofs-mapx-define\")\nth
eDictionary=theDialog.getObjectTag\nif((theDictionary.getName=\"mapxdictionary\").not)then  \n   theDictionary=Dictionary.Make(12)\n   theDictionary.setName(\"mapxdictionary\")\n   theDictionary.Add(\"FMAPID\",\"\")\n   theDictionary.Add(\"FMAPLIST\",\"\")\n   theDictionary.Add(\"MAPXID\",\"\")\n   theDictionary.Add(\"MAPXDESCRIPTION\",\"\")\n   theDictionary.Add(\"BASINTHEME\",\"\")\n   theDictionary.Add(\"BASINIDFIELD\",\"\")\n   theDictionary.Add(\"BASINDESCRIPTIONFIELD\",\"\")\n   theDictionary.Add(\"BASINMEANELEVATIONFIELD\",\"Empty\")\n   theDictio
nary.Add(\"BASINID\",\"\")\n   theDictionary.Add(\"BASINDESCRIPTION\",\"\")\n   theDictionary.Add(\"BASINMEANELEVATION\",\"\")\n   '***Set object tag parameters***'\n   theDialog.setObjectTag(theDictionary)\nend\ntheString=\"@DUMP PUNCH AREA FMAP ALL\"\ntheOfile=av.Run(\"util.RunOFS\",{theString,\"fmap\",\"dump\"})\nav.getProject.getWorkDir.SetCWD\ntheExistingDir=Filename.getCWD.asString\ntheTline={}\ntheOfile.Read(theTline,theOfile.getSize)\ntheLineList={}\ntheSize=theOfile.getSize\nfor each i in 0..(theSize-1)\n   av.setStatus((i/(theSize-
1))*100)\n   theLineList.Add(theTline.get(i).asTokens(\" \"))\nend\ntheCount=theLineList.Count\ntheFmapList={}\nfor each i in 0..(theCount-1)\n   av.setStatus((i/theCount)*100)\n   if(theLineList.get(i).get(0).contains(\"FMAP\").not)then\n      continue\n   else\n      theFmapList.Add(theLineList.get(i).get(1))\n   end\nend\ntheDictionary.Set(\"FMAPLIST\",theFmapList)\n\ntheList=theDictionary.Get(\"FMAPLIST\")\ntheComboBox=ComboBox.Make\ntheComboBox.setName(\"fmapid\")\ntheComboBox.DefineFromList(theList)\ntheControlPanel=theDialog.get
ControlPanel\ntheRect=Rect.make(100@100,120@80)\ntheControlPanel.Add(theComboBox,theRect)\n\n\n'***create a dictionary for mapx dump dialog***'\ntheDialog=av.FindDialog(\"ofs-mapx-dump\")\ntheDictionary=theDialog.getObjectTag\nif((theDictionary.getName=\"mapxdumpdictionary\").not)then   \n  '***Create a MAPX Dictionary***'\n   theDictionary=Dictionary.Make(3)\n   theDictionary.setName(\"mapxdumpdictionary\")\n   theDictionary.Add(\"MAPXAREALIST\",{})\n   theDictionary.Add(\"NEWENTRYLIST\",{})\n   theDictionary.Add(\"MAPXTOTALLIST\",
{})\n   '***Set object tag parameters***'\n   theDialog.setObjectTag(theDictionary)\nend\n'*** run the following ofs command and return the punch file ***'\ntheString=\"@DUMP PUNCH AREA MAPX ALL\"\ntheOfile=av.Run(\"util.RunOFS\",{theString,\"mapx_area\",\"dump\"})\nav.getProject.getWorkDir.SetCWD\ntheExistingDir=Filename.getCWD.asString\ntheTline={}     \ntheOfile.Read(theTline,theOfile.getSize)\ntheLineList={}\ntheMapxList={}\ntheNewEntryList={}\ntheSize=theOfile.getSize\nfor each i in 0..(theSize-1)\n   av.setStatus((i/(theSize
-1))*100)\n   theList=theTline.get(i).asTokens(\" \")\n   if(theList.get(0).contains(\"MAPX\").not)then\n      theLineList.Add(theTline.get(i).asTokens(\" \"))\n      continue\n   else\n      theMapxList.Add(theList.get(1))\n      theNewEntryList.Add(i)\n      theLineList.Add(theList)\n   end\nend\ntheDictionary.Set(\"MAPXAREALIST\",theMapxList)\ntheDictionary.Set(\"NEWENTRYLIST\",theNewEntryList)\ntheDictionary.Set(\"MAPXTOTALLIST\",theLineList)\ntheDictionary.Set(\"BASINTOTALLIST\",theBasinTotalList)\ntheMapxList=theDictionary.Get(\"M
APXAREALIST\")\n\n'***create a dictionary for delete mapx area dialog\ntheDialog=av.FindDialog(\"ofs-mapx-delete\")\ntheDictionary=theDialog.getObjectTag\nif((theDictionary.getName=\"mapxdeletedictionary\").not)then  \n   theDictionary=Dictionary.Make(12)\n   theDictionary.setName(\"mapxdeletedictionary\")\n   theDictionary.Add(\"MAPXAREALIST\",{})\n   '***Set object tag parameters***'\n   theDialog.setObjectTag(theDictionary)\nend\ntheDictionary.Set(\"MAPXAREALIST\",theMapxList)\nav.ClearStatus\nav.ClearMsg\n\n'***create a dictionar
y for delete basin dialog\ntheDialog=av.FindDialog(\"ofs-basin-delete\")\ntheDictionary=theDialog.getObjectTag\nif((theDictionary.getName=\"basindeletedictionary\").not)then  \n   theDictionary=Dictionary.Make(12)\n   theDictionary.setName(\"basindeletedictionary\")\n   theDictionary.Add(\"BASINLIST\",{})\n   '***Set object tag parameters***'\n   theDialog.setObjectTag(theDictionary)\nend\ntheDictionary.Set(\"BASINLIST\",theBasinList)\nav.ClearStatus\nav.ClearMsg\n"
)

(Script.470
	Name:	"util.ofs.runorder"
	SourceCode:	"av.showMsg(\"Run @ORDER\")\ntheString=\"@DUMP ORDER ALL\"+NL+\"@ORDER\"\nav.Run(\"util.runOfs\",{theString,\"order\",\"order\"})\nav.ClearMsg\n"
)

(Script.471
	Name:	"util.RunOfs"
	SourceCode:	"'this script is used to run an ofs -p ppinit job (theString) and returns the punch file if 3 agrs given\n'returns the ofs completion code if 4 args give (4th arg = anything)\n\ntheString=SELF.get(0)\ntheType=SELF.get(1)\ntheCommand=SELF.get(2)\nav.getProject.getWorkDir.setCWD\ntheExistingDir = Filename.getCWD.asString'Filename.getCWD.asString\n'***get ofs input directory ***\nSystem.Execute(\"gad ofs_input>temp.txt\")\ntheTempFileName = (theExistingDir+\"/temp.txt\").asFileName\ntheTFile = LineFile.Make(theTempFileName,#F
ILE_PERM_READ)\ntheTFile.setScratch(TRUE)\ntheInputDir=theTFile.ReadElt\ntheTFile.Close\n'***get ofs output directory ***\nSystem.Execute(\"gad my_output>temp.txt\")\ntheTempFileName = (theExistingDir+\"/temp.txt\").asFileName\ntheTFile = LineFile.Make(theTempFileName,#FILE_PERM_READ)\ntheTFile.setScratch(TRUE)\ntheOutputDir=theTFile.ReadElt\ntheTFile.Close\n\n'***get ofs rls directory ***\nSystem.Execute(\"gad ofs_rls>temp.txt\")\ntheTempFileName = (theExistingDir+\"/temp.txt\").asFileName\ntheTFile = LineFile.Make(theTempFileNa
me,#FILE_PERM_READ)\ntheTFile.setScratch(TRUE)\ntheBinDir=theTFile.ReadElt\ntheTFile.Close \n\n'***get date stamp ***\nSystem.Execute(\"date -u +%Y%m%d.%H%M%S>temp.txt\")\ntheTempFileName = (theExistingDir+\"/temp.txt\").asFileName\ntheTFile = LineFile.Make(theTempFileName,#FILE_PERM_READ)\ntheTFile.setScratch(TRUE)\ntheDateStamp=theTFile.ReadElt\ntheTFile.Close \n\n'***get the editor ***\nSystem.Execute(\"gad xsets_editor>temp.txt\")\ntheTempFileName = (theExistingDir+\"/temp.txt\").asFileName\ntheTFile = LineFile.Make(theTempFil
eName,#FILE_PERM_READ)\ntheTFile.setScratch(TRUE)\ntheEditor=theTFile.ReadElt\ntheTFile.Close\n\n'**** this is the ofs input file ****\ntheInputFile = (theInputDir+\"/ppinit/\"+theType+\".\"+theCommand+\".\"+theDateStamp).asFileName\ntheOfsInputFileName = theInputFile.getName\ntheIFile = LineFile.Make(theInputFile,#FILE_PERM_WRITE)\n\n'*** this file is the ofs output file ***\ntheOfsOutputFileName= theOutputDir+\"/\"+theType+\".\"+theCommand+\".\"+theDateStamp\ntheIfile.WriteElt(theString)\ntheIfile.Close\n\n'*** execute the ofs -p p
pinit command\ntheIname=theOfsInputFileName.asFileName.getBaseName\ntheOname=theOfsOutputFileName.asFileName.getBaseName\nif(SELF.Count<>4)then\n   theCall=\"sleep 1; ofs -p ppinit -i\"++theIname++\"-o\"++theOname\n   System.Execute(theCall)\nelse\n   theCall=\"sleep 1; ofs -p ppinit -i\"++theIname++\"-o tty\"\n   '***get ofs completion code ***\n   System.Execute(theCall+\">temp.txt\")\n   theTempFileName = (theExistingDir+\"/temp.txt\").asFileName\n   theTFile = LineFile.Make(theTempFileName,#FILE_PERM_READ)\n   theTFile.setScra
tch(TRUE)\n   theSize=theTFile.GetSize\n   theTFile.SetPos(theSize-1)\n   theCompletionCode=theTFile.ReadElt\n   if(theCompletionCode.asNumber<>0)then\n      theCallB=theEditor++theTempFileName.asString+\"&\"\n      system.Execute(theCallB)\n      exit\n   else\n      theTFile.Close \n      return theCompletionCode.asNumber\n   end\nend\n\n'============The next set of code grabs the punch file=========='\n\n'***First find date stamp on output file***'\ntheOutputDir.asFileName.SetCWD\ntheDir=FileName.GetCWD\n\ntheString=theType+\"
.\"+theCommand+\".\"+theDateStamp+\"*\"\ntheFileList=theDir.Read(theString)\ntheFileListA={}  \nfor each f in theFileList\n   if(f.isDir.not)then\n      theFileListA.Add(f)\n   end\nend\n\ntheOutputFileAsString=theFileListA.get(0).asString\ntheOfsDateStamp=theOutputFileAsString.Right(15)\n\n'***Use date stamp to find punch file***'\ntheFileList={}\ntheFileListA={}\ntheString=\"*pun.\"+theOfsDateStamp\ntheFileList=theDir.Read(theString)  \nfor each f in theFileList\n   if(f.isDir.not)then\n      theFileListA.Add(f)\n   end\nend\n\nif (th
eFileListA.Count = 0) then\n  '*** open the output file ***\n  theCallB=theEditor++theOfsOutputFileName+\"*\"+\"&\"\n  System.Execute(theCallB)     \n  return Nil\nelseif (File.Exists(theFileListA.get(0))) then\n  thePunchFileName=theFileListA.get(0)\n  theOfile = LineFile.Make(thePunchFileName, #FILE_PERM_READ)\n  if (theOfile = nil) then\n    MsgBox.Warning(\"Cann't open file: \"+theOfile.GetFullName, \"Error\")\n    exit\n  end  \n  return theOFile\nend\n'=======================================================================
==========\n"
)

(Script.472
	Name:	"util.viewobjecttags"
	SourceCode:	"theView=av.GetActiveDoc\ntheDict=theView.GetObjectTag\n\nif (theDict=nil) then\n  msgbox.info(\"No object tag for this View.\",\"\")\n  exit\nend\ntheKeys=theDict.ReturnKeys\n\nmsgstring=\"\"\nfor each k in theKeys\n   theobj=theDict.Get(k)\n   if (theobj.Is(String)) then\n      msgstring=msgstring+k++\":\"++theDict.Get(k)+nl\n   else\n      msgstring=msgstring+k++\":\"++theDict.Get(k).GetName+nl\n   end\nend\nmsgbox.report(msgstring,\"\")\n"
)