File: w_main.srw
Size: 6456
Date: Fri, 22 Feb 2019 22:19:28 +0100
$PBExportHeader$w_main.srw
forward
global type w_main from window
end type
type cb_indirect_history from commandbutton within w_main
end type
type cb_wnetgetuser from commandbutton within w_main
end type
type lb_history from listbox within w_main
end type
type sle_username from singlelineedit within w_main
end type
type st_1 from statictext within w_main
end type
type cb_get from commandbutton within w_main
end type
type cb_set from commandbutton within w_main
end type
type cb_cancel from commandbutton within w_main
end type
end forward

global type w_main from window
integer width = 1842
integer height = 1428
boolean titlebar = true
string title = "Indirect Keyword Variable Demo"
boolean controlmenu = true
long backcolor = 67108864
string icon = "AppIcon!"
boolean center = true
cb_indirect_history cb_indirect_history
cb_wnetgetuser cb_wnetgetuser
lb_history lb_history
sle_username sle_username
st_1 st_1
cb_get cb_get
cb_set cb_set
cb_cancel cb_cancel
end type
global w_main w_main

type variables
n_usernames in_vars

end variables

on w_main.create
this.cb_indirect_history=create cb_indirect_history
this.cb_wnetgetuser=create cb_wnetgetuser
this.lb_history=create lb_history
this.sle_username=create sle_username
this.st_1=create st_1
this.cb_get=create cb_get
this.cb_set=create cb_set
this.cb_cancel=create cb_cancel
this.Control[]={this.cb_indirect_history,&
this.cb_wnetgetuser,&
this.lb_history,&
this.sle_username,&
this.st_1,&
this.cb_get,&
this.cb_set,&
this.cb_cancel}
end on

on w_main.destroy
destroy(this.cb_indirect_history)
destroy(this.cb_wnetgetuser)
destroy(this.lb_history)
destroy(this.sle_username)
destroy(this.st_1)
destroy(this.cb_get)
destroy(this.cb_set)
destroy(this.cb_cancel)
end on

event open;// set an item in the array
in_vars.History[1] = "default"

// get an item from the array
lb_history.AddItem("Item #1 is: " + in_vars.History[1])

end event

type cb_indirect_history from commandbutton within w_main
integer x = 73
integer y = 800
integer width = 443
integer height = 132
integer taborder = 60
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
string text = "Indirect History"
end type

event clicked;Long ll_Upper, ll_Lower
Long ll_idx, ll_max
String ls_history[]

lb_history.Reset()

// get the array bounds
ll_Lower = LowerBound(in_vars.History)
lb_history.AddItem("LowerBound: " + String(ll_Lower))
ll_Upper = UpperBound(in_vars.History)
lb_history.AddItem("UpperBound: " + String(ll_Upper))

// get the indirect array variable
ls_history = in_vars.History

ll_max = UpperBound(ls_history)
For ll_idx = 1 To ll_max
   lb_history.AddItem(ls_history[ll_idx])
Next

end event

type cb_wnetgetuser from commandbutton within w_main
integer x = 73
integer y = 608
integer width = 443
integer height = 132
integer taborder = 40
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
string text = "Get NetUserid"
end type

event clicked;String ls_Username

// get the indirect variable
ls_Username = in_vars.NetUsername

// set the indirect variable
in_vars.Username = ls_Username

lb_history.AddItem("Network Username: " + ls_Username)

end event

type lb_history from listbox within w_main
integer x = 585
integer y = 224
integer width = 1175
integer height = 900
integer taborder = 70
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
boolean vscrollbar = true
boolean sorted = false
borderstyle borderstyle = stylelowered!
end type

type sle_username from singlelineedit within w_main
integer x = 585
integer y = 64
integer width = 1175
integer height = 80
integer taborder = 10
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
borderstyle borderstyle = stylelowered!
end type

type st_1 from statictext within w_main
integer x = 224
integer y = 64
integer width = 329
integer height = 68
integer textsize = -10
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "Username:"
alignment alignment = right!
boolean focusrectangle = false
end type

type cb_get from commandbutton within w_main
integer x = 73
integer y = 416
integer width = 443
integer height = 132
integer taborder = 30
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
string text = "Get Indirect"
end type

event clicked;String ls_Username

// get the indirect variable
ls_Username = in_vars.Username

lb_history.AddItem("Most recent value: " + ls_Username)

end event

type cb_set from commandbutton within w_main
integer x = 73
integer y = 224
integer width = 443
integer height = 132
integer taborder = 20
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
string text = "Set Indirect"
boolean default = true
end type

event clicked;// set the username

String ls_Username

ls_Username = sle_username.text
If ls_Username = "" Then
   MessageBox("Edit Error", "Username is required!")
Else
   // set the indirect variable
   in_vars.Username = ls_Username

   lb_history.AddItem(ls_Username)

   sle_username.text = ""
End If
sle_username.SetFocus()

end event

type cb_cancel from commandbutton within w_main
integer x = 1499
integer y = 1184
integer width = 261
integer height = 100
integer taborder = 80
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
string text = "Cancel"
boolean cancel = true
end type

event clicked;Close(Parent)

end event