Page 1 of 2 12>
Topic Options
#139709 - 2005-05-14 12:45 AM Where is my logic wrong
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
I am trying to read some very large log files and put them into a graphical interface to make it easier for the average tech to read them.

I am having a problem with the incrementation of my counter in the functions of Increase() and Decrease().

I am sure that I have my logic messed up somewhere but I just am not getting it. Please help.

Here is the code
Code:
 


Break On
Global $D[], $T[], $E[], $C[], $TE[], $BY, $count
Dim $Input, $file, $read, $DT, $er[], $rb[]

;Later add text box to let user specify the file they want to read

$File = "Unity_TSP.txt"
$Count = 0
$System = CreateObject("Kixtart.System")

;KD START

$Form = $System.Form()
$Form.BackColor = 212,208,200
$Form.Height = 432
$Form.Left = 233
$Form.Text = "Error Log Reader"
$Form.Top = 55
$Form.Width = 678

$Server = $Form.Controls.Label()
$Server.BackColor = 212,208,200
$Server.Height = 23
$Server.Left = 105
$Server.Text = ""
$Server.Top = 15
$Server.Width = 100

$Label3 = $Form.Controls.Label()
$Label3.BackColor = 212,208,200
$Label3.Height = 23
$Label3.Left = 0
$Label3.Text = "Date"
$Label3.Top = 45
$Label3.Width = 100

$Label4 = $Form.Controls.Label()
$Label4.BackColor = 212,208,200
$Label4.Height = 23
$Label4.Left = 0
$Label4.Text = "Server Name"
$Label4.Top = 15
$Label4.Width = 100

$Date = $Form.Controls.Label()
$Date.BackColor = 212,208,200
$Date.Height = 23
$Date.Left = 105
$Date.Text = ""
$Date.Top = 45
$Date.Width = 100

$Label6 = $Form.Controls.Label()
$Label6.BackColor = 212,208,200
$Label6.Height = 23
$Label6.Left = 225
$Label6.Text = "Time"
$Label6.Top = 45
$Label6.Width = 100

$Time = $Form.Controls.Label()
$Time.BackColor = 212,208,200
$Time.Height = 23
$Time.Left = 330
$Time.Text = ""
$Time.Top = 45
$Time.Width = 100

$Label8 = $Form.Controls.Label()
$Label8.BackColor = 212,208,200
$Label8.Height = 23
$Label8.Left = 0
$Label8.Text = "Error Type"
$Label8.Top = 75
$Label8.Width = 100

$LER = $Form.Controls.Label()
$LER.BackColor = 212,208,200
$LER.Height = 23
$LER.Left = 105
$LER.Text = ""
$LER.Top = 75
$LER.Width = 100

$Label10 = $Form.Controls.Label()
$Label10.BackColor = 212,208,200
$Label10.Height = 23
$Label10.Left = 0
$Label10.Text = "Reported By:"
$Label10.Top = 105
$Label10.Width = 100

$Reporter = $Form.Controls.Label()
$Reporter.BackColor = 212,208,200
$Reporter.Height = 23
$Reporter.Left = 105
$Reporter.Text = ""
$Reporter.Top = 105
$Reporter.Width = 100

$Label12 = $Form.Controls.Label()
$Label12.BackColor = 212,208,200
$Label12.Height = 23
$Label12.Left = 0
$Label12.Text = "Error Message"
$Label12.Top = 150
$Label12.Width = 100

$Record = $Form.Controls.Label()
$Record.BackColor = 212,208,200
$Record.Height = 23
$Record.Left = 225
$Record.Top = 150
$Record.Width = 100
$Record.Text = ""

$EC = $Form.Controls.Label()
$EC.BackColor = 212,208,200
$EC.Height = 178
$EC.Left = 15
$EC.Text = ""
$EC.Top = 180
$EC.Width = 634

$Button1 = $Form.Controls.Button()
$Button1.FontSize = 12
$Button1.Height = 23
$Button1.Left = 90
$Button1.Text = "<<"
$Button1.Top = 375
$Button1.Width = 75
$Button1.OnClick = "Decrease($count)"

$Button2 = $Form.Controls.Button()
$Button2.FontSize = 12
$Button2.Height = 23
$Button2.Left = 240
$Button2.Text = ">>"
$Button2.Top = 375
$Button2.Width = 75
$Button2.OnClick = "Increase($count)"

$Button3 = $Form.Controls.Button()
$Button3.Height = 23
$Button3.Left = 495
$Button3.Text = "Exit"
$Button3.Top = 375
$Button3.Width = 75
$Button3.OnClick = "Cancel()"

;KD END

;Build Arrays.
;+++++++

Open(1,$file)
$input = Readline(1)
While @Error = 0
Redim Preserve $D[$count]
Redim Preserve $T[$count]
Redim Preserve $E[$count]
Redim Preserve $C[$count]
Redim Preserve $TE[$count]
Redim Preserve $BY[$count]
$read = Split($input," ")
$DT = Split($read[0]," ")
$Er = Split($read[1],".")
$RB = Split($read[3],":")
$D[$count] = $DT[0]
$T[$count] = $DT[1]
$E[$count] = $Er[1]
$C[$count] = $read[2]
$TE[$count] = $read[3]
$BY[$count] = $RB[0]
$count = $count +1
$input = Readline(1)
Loop
Close (1)

$count = 0
Update($count)


$Form.Show

While $Form.Visible
$=Execute($Form.DoEvents())
Loop
Exit 1

Function Update ($count)
If $count = 0
$Button1.Enable = "False"
Else
$Button1.Enable = "True"
EndIf
If $Count = Ubound($TE)
$Button2.Enable = "False"
Else
$Button2.Enable = "True"
EndIf
$Server.Text = $C[$count]
$Date.Text = $D[$count]
$Time.Text = $T[$count]
$Reporter.Text = $BY[$count]
$LER.Text = $E[$count]
$EC.Text = $TE[$count]
$Record.Text = "Record "+($count+1)+" of "+Ubound($TE)
EndFunction

Function Increase($count)
$count = $count+1
Update($count)
EndFunction

Function Decrease($count)
$count = $count-1
update($count)
EndFunction

Function Cancel()
Quit(1)
EndFunction



Here is a sample input line from the file (it is a single line, broken here to prevent window scrolling)
 
 
2005-05-11 10:24:52 Daemon.Warning hcphxuvm00000 CiscoUnity_TSP: N/A: Cisco Unity-CM TSP device 4 (Cisco Unity port 1): Failed blind transfer to extension 74400. Busy tone detected. If this is a persistent problem, it may indicate a problem on the Cisco Unity and/or Cisco CallManager. Verify that transfers are working. For more information, click: http://www.CiscoUnitySupport.com/find.php

 
[Long line removed by NTDOC]
 


Edited by NTDOC (2005-05-14 01:20 AM)

Top
#139710 - 2005-05-14 01:02 AM Re: Where is my logic wrong
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
Please break up the long line so that the window does not need to be scrolled.

Why not use some of the available UDFs and/or some scripts that have already been posted for similar tasks.

Then wrap it up in KiXforms.

 

Top
#139711 - 2005-05-14 01:05 AM Re: Where is my logic wrong
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Sorry about the long line, but thought that it would want to be seen as is.

As for the UDF's and Scripts, I don't learn how do it correctly that way. I would like to know why/how it is supposed to work so that I don't have to alway's depend on someone else.

I will go take a look at them however and maybe I can figure it out from there.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#139712 - 2005-05-14 01:20 AM Re: Where is my logic wrong
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
I removed the long line.

You shouldn't be passing $count to the event functions. Make it a Global.

Top
#139713 - 2005-05-14 01:31 AM Re: Where is my logic wrong
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Thanks. But can you explain to me why passing the $count to the functions would not allow it to update.

I removed it and all works well (well still have some other issues to fix but that is another thing).

I am assuming (and please correct me if I am wrong) that when passing $count to the function it is orginally sent = to 0, I then add 1 to it, but when it exits the function it returns to 0.

I had thought that by declaring it as a global would fix it, but I had to not pass it to the function before it would hold the value. I am not sure that I am understanding how the function would return it as a 0 even though it was declared as a global.

Thanks
_________________________
Today is the tomorrow you worried about yesterday.

Top
#139714 - 2005-05-14 01:55 AM Re: Where is my logic wrong
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
My feeling is that you understand why it didn't work. Basically, since you were declaring $count as a parameter to your event function, you were always working with a "local copy" of the variable, and incrementing $count in the event function simply incremented the local copy, not the global. As soon as you exited the function, the local version of $count was discarded. Like DOC says, think its best to keep $count global.

Edited by Shawn (2005-05-14 01:57 AM)

Top
#139715 - 2005-05-14 03:30 AM Re: Where is my logic wrong
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Use of globals in UDFs are evil and almost always unnecessary. Values should be passed by parms and returned by the function.
Code:
break on
$Count = 1

for $X = 1 to 10
$Count = Increase($Count)
$Count ?
next
?
for $X = 1 to 10
$Count = Decrease($Count)
$Count ?
next

Function Increase($count)
$count = $count+1
$Increase = $count
EndFunction

Function Decrease($count)
$count = $count-1
$Decrease = $count
EndFunction

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#139716 - 2005-05-14 05:37 AM Re: Where is my logic wrong
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Wont argue with you - your right. Just that avoiding globals is a pita using Kixforms with Kixtart.
Top
#139717 - 2005-05-15 05:28 PM Re: Where is my logic wrong
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
I think that I get it now. Everytime that I pass $count into the UDF, it almost like I am doing a ReDim.

I appreciate the explanation. Now to try and get the rest of it to work the way that I want.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#139718 - 2005-05-15 06:45 PM Re: Where is my logic wrong
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
No.
Reread Shawn's explanation. You are not REDIMming one $Count var. You have two $Count vars, one global and the other local to the UDF.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#139719 - 2005-05-15 07:29 PM Re: Where is my logic wrong
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
The only reason I have in KiXforms scripts to use global variables is to make the KiXforms objects themselves gLOBAL as the functions manipulating the KiXforms objects are easier to write. Outseide ofthe actual objects everyhting can be passed into functions as parameters or be stored as Expandos.
_________________________
There are two types of vessels, submarines and targets.

Top
#139720 - 2005-05-15 07:33 PM Re: Where is my logic wrong
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
I agree with Jens - I do the same thing too. Since most Kixforms objects are global anyways, store global data in the objects themselves - as expandos or in the object TAG property. Expandos are an advanced Kixforms feature - can discuss if you want to get into that.

-Shawn

Top
#139721 - 2005-05-16 05:10 PM Re: Where is my logic wrong
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Expandos? Now I am truelly lost and confused.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#139722 - 2005-05-16 06:30 PM Re: Where is my logic wrong
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
From the Manual

Quote:

Remarks
The Object object supports dynamic (expando) properties, or properties that can be added and removed while the script is running. These properties can have any name, including numbers. A name of a property that is a simple identifier can be written after a period that follows the object name, such as:

$Object = $System.Object()

; Add two expando properties, 'Name' and 'Age'

$Object.Name = "Fred"
$Object.Age = 53





Top
#139723 - 2005-05-16 06:41 PM Re: Where is my logic wrong
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Okay I understand that I can basically add my own properties to an object, but why?

It seems to me that you would use the expando properties to adjust another property, so why not modify it directly?
_________________________
Today is the tomorrow you worried about yesterday.

Top
#139724 - 2005-05-16 07:00 PM Re: Where is my logic wrong
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Because they are your own, user-defined properties. You can make them (mean) whatever you want them to mean. And they don't exist until you create them. They're like variables that reside inside the object itself.

Why use them ? Because the variables live with the object, and can be passed around with the object - no need for globals and extra params to functions.

Top
#139725 - 2005-05-16 07:55 PM Re: Where is my logic wrong
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Okay. Now I just have to play around a bit to see how to make it work for me.

Now onto another point...

In this same script I have several arrays, that I would like to be able to scan and build a combobox list from. I know that I could do a for each, but there is alot of repition within each of the array's. How would you suggest that I build a list that would only contain one instance of each type of item within the array.

For example the $C[] array holds the name of a server for each element.

I just am not sure of how I want to sort out and only get one instance from the array.

Here is the newest version of the code at this time.

Code:
  


Break On
Global $D[], $T[], $E[], $C[], $TE[], $BY, $count
Dim $Input, $file, $read, $DT, $er[], $rb[], $listing


$Count = 0
$System = CreateObject("Kixtart.System")

;KD START

$Form = $System.Form()
$Form.BackColor = 212,208,200
$Form.Height = 432
$Form.Left = 233
$Form.Text = "Error Log Reader"
$Form.Top = 55
$Form.Width = 678

$Server = $Form.Controls.Label()
$Server.BackColor = 212,208,200
$Server.Height = 23
$Server.Left = 105
$Server.Text = ""
$Server.Top = 15
$Server.Width = 200

$Label3 = $Form.Controls.Label()
$Label3.BackColor = 212,208,200
$Label3.Height = 23
$Label3.Left = 0
$Label3.Text = "Date"
$Label3.Top = 45
$Label3.Width = 100

$Label4 = $Form.Controls.Label()
$Label4.BackColor = 212,208,200
$Label4.Height = 23
$Label4.Left = 0
$Label4.Text = "Server Name"
$Label4.Top = 15
$Label4.Width = 100

$Date = $Form.Controls.Label()
$Date.BackColor = 212,208,200
$Date.Height = 23
$Date.Left = 105
$Date.Text = ""
$Date.Top = 45
$Date.Width = 100

$Label6 = $Form.Controls.Label()
$Label6.BackColor = 212,208,200
$Label6.Height = 23
$Label6.Left = 225
$Label6.Text = "Time"
$Label6.Top = 45
$Label6.Width = 100

$Time = $Form.Controls.Label()
$Time.BackColor = 212,208,200
$Time.Height = 23
$Time.Left = 330
$Time.Text = ""
$Time.Top = 45
$Time.Width = 100

$Label8 = $Form.Controls.Label()
$Label8.BackColor = 212,208,200
$Label8.Height = 23
$Label8.Left = 0
$Label8.Text = "Error Type"
$Label8.Top = 75
$Label8.Width = 100

$LER = $Form.Controls.Label()
$LER.BackColor = 212,208,200
$LER.Height = 23
$LER.Left = 105
$LER.Text = ""
$LER.Top = 75
$LER.Width = 100

$Label10 = $Form.Controls.Label()
$Label10.BackColor = 212,208,200
$Label10.Height = 23
$Label10.Left = 0
$Label10.Text = "Reported By:"
$Label10.Top = 105
$Label10.Width = 100

$Reporter = $Form.Controls.Label()
$Reporter.BackColor = 212,208,200
$Reporter.Height = 23
$Reporter.Left = 105
$Reporter.Text = ""
$Reporter.Top = 105
$Reporter.Width = 200

$Label12 = $Form.Controls.Label()
$Label12.BackColor = 212,208,200
$Label12.Height = 23
$Label12.Left = 0
$Label12.Text = "Error Message"
$Label12.Top = 225
$Label12.Width = 100

$Record = $Form.Controls.Label()
$Record.BackColor = 212,208,200
$Record.Height = 23
$Record.Left = 345
$Record.Top = 375
$Record.Width = 100
$Record.Text = ""

$EC = $Form.Controls.Label()
$EC.BackColor = 212,208,200
$EC.Height = 100
$EC.Left = 15
$EC.Text = ""
$EC.Top = 255
$EC.Width = 634

$Button1 = $Form.Controls.Button()
$Button1.FontSize = 12
$Button1.Height = 23
$Button1.Left = 90
$Button1.Text = "<<"
$Button1.Top = 375
$Button1.Width = 75
$Button1.OnClick = "Decrease()"

$Button2 = $Form.Controls.Button()
$Button2.FontSize = 12
$Button2.Height = 23
$Button2.Left = 240
$Button2.Text = ">>"
$Button2.Top = 375
$Button2.Width = 75
$Button2.OnClick = "Increase()"

$Button3 = $Form.Controls.Button()
$Button3.Height = 23
$Button3.Left = 495
$Button3.Text = "Exit"
$Button3.Top = 375
$Button3.Width = 75
$Button3.OnClick = "Cancel()"

$DirList = $Form.Controls.ComboBox()
$DirList.DropDownStyle = 2
$DirList.DropDownWidth = 156
$DirList.Height = 21
$DirList.Left = 495
$DirList.Sorted = "False"
$DirList.Text = ""
$DirList.Top = 15
$DirList.Width = 156
$DirList.OnSelectedIndexChanged = "Build()"


$Label14 = $Form.Controls.Label()
$Label14.BackColor = 212,208,200
$Label14.Height = 19
$Label14.Left = 375
$Label14.Text = "Please select log file"
$Label14.Top = 15
$Label14.Width = 113

$Label15 = $Form.Controls.Label()
$Label15.BackColor = 212,208,200
$Label15.Height = 23
$Label15.Left = 255
$Label15.Text = "Search Criteria"
$Label15.Top = 135
$Label15.Width = 100

$ComboBox2 = $Form.Controls.ComboBox()
$ComboBox2.DropDownWidth = 121
$ComboBox2.Height = 21
$ComboBox2.Left = 105
$ComboBox2.Sorted = "False"
$ComboBox2.Top = 180
$ComboBox2.Width = 121

$ComboBox3 = $Form.Controls.ComboBox()
$ComboBox3.DropDownWidth = 121
$ComboBox3.Height = 21
$ComboBox3.Left = 345
$ComboBox3.Sorted = "False"
$ComboBox3.Top = 180
$ComboBox3.Width = 121

$Label16 = $Form.Controls.Label()
$Label16.BackColor = 212,208,200
$Label16.Height = 23
$Label16.Left = 0
$Label16.Text = "Server"
$Label16.Top = 180
$Label16.Width = 100

$Label17 = $Form.Controls.Label()
$Label17.BackColor = 212,208,200
$Label17.Height = 23
$Label17.Left = 240
$Label17.Text = "Error Type"
$Label17.Top = 180
$Label17.Width = 100

$Label18 = $Form.Controls.Label()
$Label18.BackColor = 212,208,200
$Label18.Height = 17
$Label18.Left = 465
$Label18.Text = "Reported By"
$Label18.Top = 180
$Label18.Width = 81

$ComboBox4 = $Form.Controls.ComboBox()
$ComboBox4.DropDownWidth = 121
$ComboBox4.Height = 21
$ComboBox4.Left = 550
$ComboBox4.Sorted = "False"
$ComboBox4.Top = 180
$ComboBox4.Width = 121

;KD END

;Get log file from user
Listing()
$DirList.SelectedIndex = 0

$Form.Show

While $Form.Visible
$=Execute($Form.DoEvents())
Loop
Exit 1

Function Listing ()
$temp = Dir(@scriptdir+"\*.txt")
While $temp <> "" and @error = 0
$DirList.AddItem($temp)
$temp = Dir()
Loop
EndFunction

Function Build()
;Build Arrays.
;+++++++

Open(1,$DirList.Text)
$input = Readline(1)
While @Error = 0
Redim Preserve $D[$count]
Redim Preserve $T[$count]
Redim Preserve $E[$count]
Redim Preserve $C[$count]
Redim Preserve $TE[$count]
Redim Preserve $BY[$count]
$read = Split($input," ")
$DT = Split($read[0]," ")
$Er = Split($read[1],".")
$RB = Split($read[3],":")
$D[$count] = $DT[0]
$T[$count] = $DT[1]
$E[$count] = $Er[1]
$C[$count] = $read[2]
$TE[$count] = $read[3]
$BY[$count] = $RB[0]
$count = $count +1
$input = Readline(1)
Loop
Close (1)

$count = 0
Update()

EndFunction

Function Update ()
If $count = 0
$Button1.Enabled = "False"
Else
$Button1.Enabled = "True"
EndIf
If $Count = Ubound($TE)
$Button2.Enabled = "False"
Else
$Button2.Enabled = "True"
EndIf
$Server.Text = $C[$count]
$Date.Text = $D[$count]
$Time.Text = $T[$count]
$Reporter.Text = $BY[$count]
$LER.Text = $E[$count]
$EC.Text = $TE[$count]
$Record.Text = "Record "+($count+1)+" of "+Ubound($TE)
EndFunction

Function Increase()
$count = $count+1
Update()
EndFunction

Function Decrease()
$count = $count-1
update()
EndFunction

Function Cancel()
Quit(1)
EndFunction

_________________________
Today is the tomorrow you worried about yesterday.

Top
#139726 - 2005-05-16 10:34 PM Re: Where is my logic wrong
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Found this UDF and I am working on making it work.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#139727 - 2005-05-19 10:39 PM Re: Where is my logic wrong
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Well I got the issue with the sorting into combo fields figured out.

But now I am trying to build some filters that will sort throught the array's and only return the specified information to another array for display.

I have it doing one sort just fine (the Filter() UDF), but I am stumped on how to make it do multi filter process.

Code:
  


Break On
SetOption(NoVarsinStrings, ON)
SetOption(WrapatEOL, ON)

Global $D[], $T[], $E[], $C[], $TE[], $BY[], $count, $Flag
Global $D1[], $T1[], $E1[], $C1[], $TE1[], $BY1[]
Dim $Input, $file, $read, $DT, $er[], $rb[], $listing

$System = CreateObject("Kixtart.System")

;KD START

$Form = $System.Form()
$Form.BackColor = 212,208,200
$Form.Height = 432
$Form.Left = 233
$Form.Text = "Error Log Reader"
$Form.Top = 55
$Form.Width = 678

$Server = $Form.Controls.Label()
$Server.BackColor = 212,208,200
$Server.Height = 23
$Server.Left = 105
$Server.Text = ""
$Server.Top = 15
$Server.Width = 200

$Label3 = $Form.Controls.Label()
$Label3.BackColor = 212,208,200
$Label3.Height = 23
$Label3.Left = 0
$Label3.Text = "Date"
$Label3.Top = 45
$Label3.Width = 100

$Label4 = $Form.Controls.Label()
$Label4.BackColor = 212,208,200
$Label4.Height = 23
$Label4.Left = 0
$Label4.Text = "Server Name"
$Label4.Top = 15
$Label4.Width = 100

$Date = $Form.Controls.Label()
$Date.BackColor = 212,208,200
$Date.Height = 23
$Date.Left = 105
$Date.Text = ""
$Date.Top = 45
$Date.Width = 100

$Label6 = $Form.Controls.Label()
$Label6.BackColor = 212,208,200
$Label6.Height = 23
$Label6.Left = 225
$Label6.Text = "Time"
$Label6.Top = 45
$Label6.Width = 100

$Time = $Form.Controls.Label()
$Time.BackColor = 212,208,200
$Time.Height = 23
$Time.Left = 330
$Time.Text = ""
$Time.Top = 45
$Time.Width = 100

$Label8 = $Form.Controls.Label()
$Label8.BackColor = 212,208,200
$Label8.Height = 23
$Label8.Left = 0
$Label8.Text = "Error Type"
$Label8.Top = 75
$Label8.Width = 100

$LER = $Form.Controls.Label()
$LER.BackColor = 212,208,200
$LER.Height = 23
$LER.Left = 105
$LER.Text = ""
$LER.Top = 75
$LER.Width = 100

$Label10 = $Form.Controls.Label()
$Label10.BackColor = 212,208,200
$Label10.Height = 23
$Label10.Left = 0
$Label10.Text = "Reported By:"
$Label10.Top = 105
$Label10.Width = 100

$Reporter = $Form.Controls.Label()
$Reporter.BackColor = 212,208,200
$Reporter.Height = 23
$Reporter.Left = 105
$Reporter.Text = ""
$Reporter.Top = 105
$Reporter.Width = 200

$Label12 = $Form.Controls.Label()
$Label12.BackColor = 212,208,200
$Label12.Height = 23
$Label12.Left = 0
$Label12.Text = "Error Message"
$Label12.Top = 225
$Label12.Width = 100

$Record = $Form.Controls.Label()
$Record.BackColor = 212,208,200
$Record.Height = 23
$Record.Left = 345
$Record.Top = 375
$Record.Width = 100
$Record.Text = ""

$EC = $Form.Controls.Label()
$EC.BackColor = 212,208,200
$EC.Height = 100
$EC.Left = 15
$EC.Text = ""
$EC.Top = 255
$EC.Width = 634

$Button1 = $Form.Controls.Button()
$Button1.FontSize = 12
$Button1.Height = 23
$Button1.Left = 90
$Button1.Text = "<<"
$Button1.Top = 375
$Button1.Width = 75
$Button1.OnClick = "Decrease()"

$Button2 = $Form.Controls.Button()
$Button2.FontSize = 12
$Button2.Height = 23
$Button2.Left = 240
$Button2.Text = ">>"
$Button2.Top = 375
$Button2.Width = 75
$Button2.OnClick = "Increase()"

$Button3 = $Form.Controls.Button()
$Button3.Height = 23
$Button3.Left = 495
$Button3.Text = "Exit"
$Button3.Top = 375
$Button3.Width = 75
$Button3.OnClick = "Cancel()"

$DirList = $Form.Controls.ComboBox()
$DirList.DropDownStyle = 2
$DirList.DropDownWidth = 156
$DirList.Height = 21
$DirList.Left = 495
$DirList.Sorted = "False"
$DirList.Text = ""
$DirList.Top = 15
$DirList.Width = 156
$DirList.OnSelectedIndexChanged = "Build()"


$Label14 = $Form.Controls.Label()
$Label14.BackColor = 212,208,200
$Label14.Height = 19
$Label14.Left = 375
$Label14.Text = "Please select log file"
$Label14.Top = 15
$Label14.Width = 113

$Label15 = $Form.Controls.Label()
$Label15.BackColor = 212,208,200
$Label15.Height = 23
$Label15.Left = 255
$Label15.Text = "Search Criteria"
$Label15.Top = 135
$Label15.Width = 100

$ServSort = $Form.Controls.ComboBox()
$ServSort.DropDownWidth = 121
$ServSort.Height = 21
$ServSort.Left = 105
$ServSort.Sorted = "False"
$ServSort.Top = 180
$ServSort.Width = 121
$ServSort.OnSelectedIndexChanged = "Filter()"

$ErrorSort = $Form.Controls.ComboBox()
$ErrorSort.DropDownWidth = 121
$ErrorSort.Height = 21
$ErrorSort.Left = 345
$ErrorSort.Sorted = "False"
$ErrorSort.Top = 180
$ErrorSort.Width = 121
$ErrorSort.OnSelectedIndexChanged = "Filter()"

$Label16 = $Form.Controls.Label()
$Label16.BackColor = 212,208,200
$Label16.Height = 23
$Label16.Left = 0
$Label16.Text = "Server"
$Label16.Top = 180
$Label16.Width = 100

$Label17 = $Form.Controls.Label()
$Label17.BackColor = 212,208,200
$Label17.Height = 23
$Label17.Left = 240
$Label17.Text = "Error Type"
$Label17.Top = 180
$Label17.Width = 100

$Label18 = $Form.Controls.Label()
$Label18.BackColor = 212,208,200
$Label18.Height = 17
$Label18.Left = 465
$Label18.Text = "Reported By"
$Label18.Top = 180
$Label18.Width = 81

$ReportSort = $Form.Controls.ComboBox()
$ReportSort.DropDownWidth = 121
$ReportSort.Height = 21
$ReportSort.Left = 550
$ReportSort.Sorted = "False"
$ReportSort.Top = 180
$ReportSort.Width = 121
$ReportSort.SelectedIndexChanged = "Filter()"

;KD END

$Count = 0

Listing()

$ServSort.Additem("None",0)
$ErrorSort.Additem("None",0)
$ReportSort.Additem("None",0)

$DirList.SelectedIndex = -1
$ServSort.SelectedIndex = 0
$ErrorSort.SelectedIndex = 0
$ReportSort.SelectedIndex = 0



$Form.Show

While $Form.Visible
$=Execute($Form.DoEvents())
Loop

Exit 1


;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++
; Functions
;++++++++++++++++++++++++++++++++++++++++++++++++++++++

Function Listing ()
$temp = Dir("k:\scripts\parsing\*.txt")

While $temp <> "" and @ERROR = 0
$DirList.AddItem($temp)
$temp = Dir()
Loop
EndFunction

;======================================================
Function Build()

Open(1,$DirList.Text)
$input = ReadLine(1)
While @ERROR = 0
ReDIM Preserve $D[$count]
ReDIM Preserve $T[$count]
ReDIM Preserve $E[$count]
ReDIM Preserve $C[$count]
ReDIM Preserve $TE[$count]
ReDIM Preserve $BY[$count]
$read = Split($input," ")
$DT = Split($read[0]," ")
$Er = Split($read[1],".")
$RB = Split($read[3],":")
$D[$count] = $DT[0]
$T[$count] = $DT[1]
$E[$count] = $Er[1]
$C[$count] = $read[2]
$TE[$count] = $read[3]
$BY[$count] = $RB[0]
$count = $count +1
$input = ReadLine(1)
Loop
Close (1)

$count = 0
Update()
For Each $Name In $C
Sort($ServSort, $Name)
Next
For Each $Name In $E
Sort($ErrorSort, $Name)
Next
For Each $Name In $BY
Sort($ReportSort, $Name)
Next

EndFunction

;======================================================
Function Sort($CtrlName, $Name)

$Exist = "False"
For $lstIndex = 0 to $CtrlName.ListCount
$CtrlName.ListIndex = $lstIndex
If $CtrlName.Text = $Name
$Exist = "True"
Exit()
EndIf
Next

If $Exist = "False"
$CtrlName.AddItem ($Name)
EndIf

EndFunction

;======================================================
Function Filter()

$Flag = "True"
$Count = 0
$Count2 = 0
For Each $Server In $C
If $ServSort.Text = $Server
ReDIM Preserve $D1[$Count]
ReDIM Preserve $T1[$Count]
ReDIM Preserve $E1[$Count]
ReDIM Preserve $C1[$count]
ReDIM Preserve $TE1[$Count]
ReDIM Preserve $BY1[$count]
$D1[$Count] = $D[$Count2]
$T1[$Count] = $T[$Count2]
$E1[$Count] = $E[$Count2]
$C1[$Count] = $C[$Count2]
$TE1[$Count] = $TE[$Count2]
$By1[$Count] = $BY[$Count2]
$count = $count + 1
EndIf

$Count2 = $Count2 + 1
Next
$Count = 0
Update2 ()

EndFunction

;======================================================
Function Update ()
If $count = 0
$Button1.Enabled = "False"
Else
$Button1.Enabled = "True"
EndIf

If $Count = UBound($TE)
$Button2.Enabled = "False"
Else
$Button2.Enabled = "True"
EndIf

$Server.Text = $C[$count]
$Date.Text = $D[$count]
$Time.Text = $T[$count]
$Reporter.Text = $BY[$count]
$LER.Text = $E[$count]
$EC.Text = $TE[$count]
$Record.Text = "Record "+($count+1)+" of "+UBound($TE)
EndFunction

;======================================================
Function Update2 ()

If $count = 0
$Button1.Enabled = "False"
Else
$Button1.Enabled = "True"
EndIf

If $Count = UBound($TE1)
$Button2.Enabled = "False"
Else
$Button2.Enabled = "True"
EndIf

$Server.Text = $C1[$count]
$Date.Text = $D1[$count]
$Time.Text = $T1[$count]
$Reporter.Text = $BY1[$count]
$LER.Text = $E1[$count]
$EC.Text = $TE1[$count]
$Record.Text = "Record "+($count+1)+" of "+UBound($TE1)
EndFunction

;======================================================
Function Increase()

$count = $count+1

If $Flag = "False"
Update()
Else
Update2()
EndIf
EndFunction

;======================================================
Function Decrease()

$count = $count-1

If $Flag = "False"
update()
Else
Update2()
EndIf
EndFunction

;======================================================
Function Cancel()

Quit(1)
EndFunction


_________________________
Today is the tomorrow you worried about yesterday.

Top
#139728 - 2005-05-20 09:51 AM Re: Where is my logic wrong
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Code:
I have it doing one sort just fine (the Filter() UDF), but I am stumped on how to make it do multi filter process.



Provide a simple example of what you are tying to do. It doesn't need to be a full working script - you can use pseudo code if you like.

Top
Page 1 of 2 12>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 369 anonymous users online.
Newest Members
rrosell, PatrickPinto, Raoul, Timothy, Jojo67
17877 Registered Users

Generated in 0.181 seconds in which 0.097 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org