#89954 - 2002-11-28 10:08 PM
Re: KixForms and the Cancel button
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Hi ArchAngle,
Number of ways to do this, tell you how I usually implement it. I leverage the TAG property that every object has - its a general-purpose, user-definable variant that you can use to store numbers and strings - in this instance, we will store a flag in the WAIT form tag that gets set depending on which button was clicked. Then we can build that flag into the DoEvents loop. Plus, using this strategy, one can check to see what button was click ... heres your code with the slight modifications:
code:
break on cls cmdGet_List() exit Function cmdGet_List() Dim $Wait $Wait = CreateObject("Kixtart.FORM") $Wait.CAPTION = "Select a Target" $Wait.SCALEWIDTH = 200 $Wait.SCALEHEIGHT = 250 $Wait.FONTSIZE = 12 $Wait.FONTNAME = "Arial" $Wait.PrintXY(20,20,"Select Computer Type") $Wait.CENTER $Corporate = $Wait.OptionButton $Corporate.FONTSIZE = 11 $Corporate.FONTNAME = "Arial" $Corporate.Caption = "Corporate" $Corporate.Left = 45 $Corporate.Top = 50 $Corporate.Width = 100 $Corporate.Height = 25 $Stores = $Wait.OptionButton $Stores.Caption = "Stores" $Stores.Left = 45 $Stores.Top = 80 $Stores.Width = 100 $Stores.Height = 25 $All = $Wait.OptionButton $All.Caption = "All Units" $All.Left = 45 $All.Top = 110 $All.Width = 100 $All.Height = 25 $Failed = $Wait.OptionButton $Failed.Caption = "Failed List" $Failed.Left = 45 $Failed.Top = 140 $Failed.Width = 130 $Failed.Height = 25 $Button2 = $Wait.CommandButton("Ok") $Button2.Left = 25 $Button2.Top = 205 $Button2.Width = 50 $Button2.Height = 25 $Button2.OnClick = "$$Wait.Tag=1" ; <--- here $Button3 = $Wait.CommandButton("Cancel") $Button3.Left = 105 $Button3.Top = 205 $Button3.Width = 75 $Button3.Height = 25 $Button3.OnClick = 0 $Button3.OnClick = "$$Wait.Tag=2" ; <--- and here $Wait.Tag = 0 ; <--- here $Wait.Show $FORM.Refresh While $Wait.Visible And Not $Wait.Tag ; <--- here $=Execute($Wait.DoEvents) Loop If $Wait.Tag = 1 ?"OK CLICKED" EndIf EndFunction
hope this helps.
-Shawn [ 28. November 2002, 22:10: Message edited by: Shawn ]
|
|
Top
|
|
|
|
#89962 - 2002-11-29 09:12 PM
Re: KixForms and the Cancel button
|
ArchAngel96
Getting the hang of it
Registered: 2002-10-20
Posts: 70
|
There are 4 radio buttons on the "page". So what I want is the ability to click one, correct myself and click a different one, then hit the ok button to perform the function. I know, this is a little more like wishfull thinking, but I could try, right?
What I'm thinking now as I revisit this, is to set $$X=1, $$X=2, and so one and then do an if statement, based on this formula. But I'm wondering if this is correct. [ 29. November 2002, 21:15: Message edited by: ArchAngel96 ]
_________________________
penny = the target
the playing field = three football fields side by side
you = only allowed to stand on the outside of the playing field
tool you get to use to find the penny = a ONE INCH LAWN DART
get the level of difficulty?
|
|
Top
|
|
|
|
#89965 - 2002-11-29 09:32 PM
Re: KixForms and the Cancel button
|
ArchAngel96
Getting the hang of it
Registered: 2002-10-20
Posts: 70
|
Does this seem right? (Its kinda hard to test me script since I'm home and its for work...)
code:
"OptionButton3".Onclick = "$x=3
If $Wait.Tag = 1 Goto cmdList() EndIf
EndFunction
Function cmdList()
$temp = "%temp%\netview.tmp" $list = "%temp%\list.tmp"
Shell '%comspec% /c net view >"$temp"'
Select Case $x=1 ;-------------------------------- ; For all systems ;-------------------------------- If Open(1,"$temp") = 0 $line = ReadLine(1) While @error=0 If $line AND SubStr($line,1,4) = "\\S0" OR $line AND SubStr($line,1,3) = "\\W" OR $line AND SubStr($line,1,3) = "\\L" $hostname=SubStr($line,3,InStr($line," ")-1) Open(2, "$list", 5) = 0 WriteLine(2, $hostname + Chr(13) + Chr(10)) Close(2) EndIf $line = ReadLine(1) Loop $_ = Close(1) EndIf
Case $x=2 ;------------------------------------- ; if statement for S' ;------------------------------------- If Open(1,"$temp") = 0 $line = ReadLine(1) While @error=0 If $line AND SubStr($line,1,4) = "\\S0" $hostname=SubStr($line,3,InStr($line," ")-1) Open(2, "$list", 5) = 0 WriteLine(2, $hostname + Chr(13) + Chr(10)) Close(2) EndIf $line = ReadLine(1) Loop $_ = Close(1) EndIf
Case $x=3 ;----------------------------------- ; if statement for Corporate ;----------------------------------- If Open(1,"$temp") = 0 $line = ReadLine(1) While @error=0 If $line AND SubStr($line,1,3) = "\\W" OR $line AND SubStr($line,1,3) = "\\L" $hostname=SubStr($line,3,InStr($line," ")-1) ?"hostname=" $hostname Open(2, "$list", 5) = 0 WriteLine(2, $hostname + Chr(13) + Chr(10)) Close(2) EndIf $line = ReadLine(1) Loop $_ = Close(1) EndIf
Case $x=4 ;--------------------------------- ; use the failed list to run the ; inventory against. ;---------------------------------
EndFunction
_________________________
penny = the target
the playing field = three football fields side by side
you = only allowed to stand on the outside of the playing field
tool you get to use to find the penny = a ONE INCH LAWN DART
get the level of difficulty?
|
|
Top
|
|
|
|
#89969 - 2002-11-29 10:06 PM
Re: KixForms and the Cancel button
|
ArchAngel96
Getting the hang of it
Registered: 2002-10-20
Posts: 70
|
This is what I have so far. If you look at all my posts, you'll see what all I'm trying to do with this little wanna be "program". As far as looking like your's, not sure but I've used others work as examples for what it is that I'm trying to accomplish. I appologise if I'm stepping on anyone's "toes". I'm really just trying to teach myself kix and kixforms by doing this little exercise.
code:
Break On Dim $Intro Dim $Button2, $Button1 $x = 0
$Intro = CreateObject("Kixtart.Form") $Intro.Icon = "SHELL32.DLL;19"
$Intro.Caption = "Hardware Inventory" $Intro.SCALEHEIGHT = 402 $Intro.SCALEWIDTH = 600 $Intro.FONTNAME = "Arial" $Intro.FONTSIZE = 9 $Intro.CENTER
$fraBanner = $Intro.PictureBox $fraBanner.BACKCOLOR = $Intro.RGB(255,255,255) $fraBanner.HEIGHT = 70 $fraBanner.Left = 10 $fraBanner.TOP = 10 $fraBanner.WIDTH = 585
$picBanner = $fraBanner.Image $picBanner.Picture = "shell32.dll;16" $picBanner.HEIGHT = 60 $picBanner.Left = 5 $picBanner.TOP = 5 $picBanner.WIDTH = 60
; Draw on the banner $fraBanner.FONTSIZE = 12 $fraBanner.FONTNAME = "verdana" $fraBanner.ForeColor = 0 $fraBanner.PrintXY(70,0,"This program is used to conduct a hardware inventory on") $fraBanner.PrintXY(70,15,"the selected computers within the domain via remote.") $fraBanner.PrintXY(70,30,"The information is retrieved with the use of WMI.") $fraBanner.FONTBOLD = 1 $fraBanner.FONTSIZE = 10 $fraBanner.ForeColor = $Intro.RGB(0,100,100) $fraBanner.PrintXY(73,46,"Powered by KiX v@KIX AND Kixforms v"+$Form.Version) $fraBanner.FONTBOLD = 0 $fraBanner.FONTSIZE = 10
$Button1 = $Intro.CommandButton("Get List") $Button1.FontSize = 12 $Button1.Left = 25 $Button1.Top = 115 $Button1.Width = 100 $Button1.Height = 25 $Button1.OnClick = "cmdGet_List()"
$fraGetList = $Intro.Frame("Details") $fraGetList.HEIGHT = 75 $fraGetList.Left = 135 $fraGetList.TOP = 85 $fraGetList.WIDTH = 435
$Intro.FONTSIZE = 12 $Intro.FONTNAME = "verdana" $Intro.ForeColor = 0 $Intro.PrintXY(145,101,"This will get a list of computers on the current ") $Intro.PrintXY(145,117,"domain. The search paramiters for this search will ") $Intro.PrintXY(145,135,"be: All, Corporate or Store Machines.")
$Button2 = $Intro.CommandButton("Get" + Chr(13) + Chr(10) + "Inventory") $Button2.MultiLine = 1 $Button2.FONTNAME = "verdana" $Button2.FontSize = 12 $Button2.Left = 25 $Button2.Top = 200 $Button2.Width = 100 $Button2.Height = 50
$Intro.FONTNAME = "Arial" $Intro.FONTSIZE = 9 $fraGetInvent = $Intro.Frame("Details") $fraGetInvent.HEIGHT = 75 $fraGetInvent.Left = 135 $fraGetInvent.TOP = 185 $fraGetInvent.WIDTH = 435
$Intro.FONTSIZE = 11 $Intro.FONTNAME = "verdana" $Intro.ForeColor = 0 $Intro.PrintXY(145,200,"Use the selected list to conduct a hardware inventory.") $Intro.PrintXY(145,216,"The inventory will get model type and hardware info ") $Intro.PrintXY(145,235,"and port the data to a CSV file on DC01")
$ButtonExit = $Intro.CommandButton("Exit") $ButtonExit.FONTNAME = "Arial" $ButtonExit.FONTSIZE = 10 $ButtonExit.FONTBOLD = 1 $ButtonExit.TOP = 367 $ButtonExit.WIDTH = 129 $ButtonExit.HEIGHT = 23 $ButtonExit.Left = 445 $ButtonExit.OnClick = "quit()"
$Intro.Show While $Intro.Visible $=Execute($Intro.DoEvents) Loop
Exit 1
Function cmdGet_List()
Dim $Wait
$Wait = CreateObject("Kixtart.FORM") $Wait.CAPTION = "Select a Target" $Wait.SCALEWIDTH = 200 $Wait.SCALEHEIGHT = 250 $Wait.FONTSIZE = 12 $Wait.FONTNAME = "Arial" $Wait.PrintXY(20,20,"Select Computer Type") $Wait.CENTER
$Corporate = $Wait.OptionButton $Corporate.FONTSIZE = 11 $Corporate.FONTNAME = "Arial" $Corporate.Caption = "Corporate" $Corporate.Left = 45 $Corporate.Top = 50 $Corporate.Width = 100 $Corporate.Height = 25 $Corporate.OnClick = "$$x=1"
$Stores = $Wait.OptionButton $Stores.Caption = "Stores" $Stores.Left = 45 $Stores.Top = 80 $Stores.Width = 100 $Stores.Height = 25 $Stores.OnClick = "$$x=2"
$All = $Wait.OptionButton $All.Caption = "All Units" $All.Left = 45 $All.Top = 110 $All.Width = 100 $All.Height = 25 $All.OnClick = "$$x=3"
$Failed = $Wait.OptionButton $Failed.Caption = "Failed List" $Failed.Left = 45 $Failed.Top = 140 $Failed.Width = 130 $Failed.Height = 25 $Failed.OnClick = "$$x=4"
$Button2 = $Wait.CommandButton("Ok") $Button2.Left = 25 $Button2.Top = 205 $Button2.Width = 50 $Button2.Height = 25 $Button2.OnClick = "$$Wait.Tag=1" ; <--- here
$Button3 = $Wait.CommandButton("Cancel") $Button3.Left = 105 $Button3.Top = 205 $Button3.Width = 75 $Button3.Height = 25 $Button3.OnClick = 0 $Button3.OnClick = "$$Wait.Tag=2" ; <--- and here
$Wait.Tag = 0 ; <--- here $Wait.Show $Wait.Refresh
While $Wait.Visible AND NOT $Wait.Tag ; <--- here $=Execute($Wait.DoEvents) Loop
If $Wait.Tag = 1 Goto cmdList() EndIf
EndFunction
Function cmdList()
$temp = "%temp%\netview.tmp" $list = "%temp%\list.tmp"
Shell '%comspec% /c net view >"$temp"'
Select Case $x=1 ;-------------------------------- ; For all systems ;-------------------------------- If Open(1,"$temp") = 0 $line = ReadLine(1) While @error=0 If $line AND SubStr($line,1,4) = "\\S0" OR $line AND SubStr($line,1,3) = "\\W" OR $line AND SubStr($line,1,3) = "\\L" $hostname=SubStr($line,3,InStr($line," ")-1) Open(2, "$list", 5) = 0 WriteLine(2, $hostname + Chr(13) + Chr(10)) Close(2) EndIf $line = ReadLine(1) Loop $_ = Close(1) EndIf
Case $x=2 ;------------------------------------- ; if statement for S' ;------------------------------------- If Open(1,"$temp") = 0 $line = ReadLine(1) While @error=0 If $line AND SubStr($line,1,4) = "\\S0" $hostname=SubStr($line,3,InStr($line," ")-1) Open(2, "$list", 5) = 0 WriteLine(2, $hostname + Chr(13) + Chr(10)) Close(2) EndIf $line = ReadLine(1) Loop $_ = Close(1) EndIf
Case $x=3 ;----------------------------------- ; if statement for Corporate ;----------------------------------- If Open(1,"$temp") = 0 $line = ReadLine(1) While @error=0 If $line AND SubStr($line,1,3) = "\\W" OR $line AND SubStr($line,1,3) = "\\L" $hostname=SubStr($line,3,InStr($line," ")-1) ?"hostname=" $hostname Open(2, "$list", 5) = 0 WriteLine(2, $hostname + Chr(13) + Chr(10)) Close(2) EndIf $line = ReadLine(1) Loop $_ = Close(1) EndIf
Case $x=4 ;--------------------------------- ; use the failed list to run the ; inventory against. ;---------------------------------
EndFunction
[ 29. November 2002, 22:07: Message edited by: ArchAngel96 ]
_________________________
penny = the target
the playing field = three football fields side by side
you = only allowed to stand on the outside of the playing field
tool you get to use to find the penny = a ONE INCH LAWN DART
get the level of difficulty?
|
|
Top
|
|
|
|
#89971 - 2002-11-29 11:23 PM
Re: KixForms and the Cancel button
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
I was thinking more along the lines of code like this - to my mind, seems clean and simple and straight-forward:
code:
break on cls cmdGet_List() exit Function cmdGet_List() Dim $Wait $Wait = CreateObject("Kixtart.FORM") $Wait.CAPTION = "Select a Target" $Wait.SCALEWIDTH = 200 $Wait.SCALEHEIGHT = 250 $Wait.FONTSIZE = 12 $Wait.FONTNAME = "Arial" $Wait.PrintXY(20,20,"Select Computer Type") $Wait.CENTER $Corporate = $Wait.OptionButton $Corporate.FONTSIZE = 11 $Corporate.FONTNAME = "Arial" $Corporate.Caption = "Corporate" $Corporate.Left = 45 $Corporate.Top = 50 $Corporate.Width = 100 $Corporate.Height = 25 $Stores = $Wait.OptionButton $Stores.Caption = "Stores" $Stores.Left = 45 $Stores.Top = 80 $Stores.Width = 100 $Stores.Height = 25 $All = $Wait.OptionButton $All.Caption = "All Units" $All.Left = 45 $All.Top = 110 $All.Width = 100 $All.Height = 25 $Failed = $Wait.OptionButton $Failed.Caption = "Failed List" $Failed.Left = 45 $Failed.Top = 140 $Failed.Width = 130 $Failed.Height = 25 $Button2 = $Wait.CommandButton("Ok") $Button2.Left = 25 $Button2.Top = 205 $Button2.Width = 50 $Button2.Height = 25 $Button2.OnClick = "$$Wait.Tag=1" $Button3 = $Wait.CommandButton("Cancel") $Button3.Left = 105 $Button3.Top = 205 $Button3.Width = 75 $Button3.Height = 25 $Button3.OnClick = 0 $Button3.OnClick = "$$Wait.Tag=2"
$Wait.Tag = 0 $Wait.Show $FORM.Refresh While $Wait.Visible And Not $Wait.Tag $=Execute($Wait.DoEvents) Loop If $Wait.Tag = 1 Select Case $Corporate.Value = 1 ?"Corporate processing..." Case $Stores.Value = 1 ?"Stores processing..." Case $All.Value = 1 ?"All processing..." Case $Failed.Value = 1 ?"Failed processing..." EndSelect EndIf EndFunction
[ 29. November 2002, 23:24: Message edited by: Shawn ]
|
|
Top
|
|
|
|
#89972 - 2002-11-29 11:28 PM
Re: KixForms and the Cancel button
|
Lonkero
KiX Master Guru
   
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
mmm... also, to shorten even from shawns code, I would tell you a shortcut... instead of separately calling every controls left/top and so on properties, you can do it on init.
$control=$form.somecontrol(specific_or_empty,left,top,width,height)
so for example, ok button would be: code:
$Button2 = $Wait.Button("Ok",25,205,50,25)$Button2.OnClick = "$$Wait.Tag=1"
that's just fine tuning but once you learn to use it, you see your code size reducing to really small
_________________________
!download KiXnet
|
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 1003 anonymous users online.
|
|
|