![](https://www.xtremedotnettalk.com/uploads/set_resources_1/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
AFterlife
Avatar/Signature-
Posts
74 -
Joined
-
Last visited
Personal Information
-
.NET Preferred Language
VB
AFterlife's Achievements
Newbie (1/14)
0
Reputation
-
I use to program for home business.Now I only program for fun.
-
Stumped? I waS thinking I want to turn this into a WEBSERVICE.So the class takes care of all the internals.The webpage just calls in the stats.Any thought and or ideas?
-
I was thinking about maybe using predicates for something similar I'm working on. http://www.xtremedotnettalk.com/showthread.php?t=97412 Is it possible to do something similar to this with predicates?Or is that to much? Any tutorials on them?That has me curious.So this is something new with 2005? Or maybe not allow duplicates in added into the list in the first place and tally the totals to the first instance of that player object. This is what the List class looks like... Imports System Imports System.IO Imports System.Net Imports System.Web Public Class CPlayerList1 Private m_Players As New Collection Private Player As CPlayer Public Sub New() 'empty constructor End Sub Public Sub LoadPlayers() Try Const file As String = "pathtoftp" Dim client As New WebClient Dim ftpReq As FtpWebRequest = _ WebRequest.Create(file) ftpReq.Method = WebRequestMethods.Ftp.DownloadFile ftpReq.KeepAlive = True ftpReq.UsePassive = True ftpReq.Credentials = New NetworkCredential( _ "nunya", "business") Dim ftpResp As FtpWebResponse ftpResp = ftpReq.GetResponse Dim ftpRespStream As Stream Dim reader As StreamReader ftpRespStream = ftpResp.GetResponseStream Stream.Synchronized(ftpRespStream) reader = New IO.StreamReader(ftpRespStream, _ System.Text.Encoding.ASCII) Do While StreamReader.Synchronized(reader).Read Dim myPlayer As String myPlayer = reader.ReadLine GetNames(myPlayer) GetKills(myPlayer) getDeaths(myPlayer) GetTk(myPlayer) GetSuicides(myPlayer) GetObjective(myPlayer) Loop reader.Close() Catch ex As Exception Dim mm As New System.Net.Mail.SmtpClient mm.Host = "smtp.charter.net" mm.Send("itower@chartermi.net", "itower@chartermi.net", "error", ex.Message) End Try End Sub Private Sub WritePlayers(ByVal Path As String) End Sub Private Sub GetObjective(ByVal myObjective As String) Dim myplayernames As String myplayernames = getPlayersObjective(myObjective) If myplayernames <> "" Then Player.Objective = getPlayersObjective(myObjective) m_Players.Add(Player) 'Add our player to our collection of players.####NOTE HERE#### End If End Sub Private Function getPlayersObjective(ByVal myObjective As String) Dim reg As Regex = New Regex("Objective:+\s*\w*") Dim m As Match = reg.Match(myObjective) myObjective = m.Value.Replace("Objective: ", "") Return myObjective End Function Private Sub GetTk(ByVal tk As String) Dim myplayernames As String myplayernames = GetPlayerTeamKills(tk) If myplayernames <> "" Then Player.TeamKills = GetPlayerTeamKills(tk) End If End Sub Private Sub getDeaths(ByVal mydeaths As String) Dim myplayernames As String myplayernames = GetPlayerDeaths(mydeaths) If myplayernames <> "" Then Player.Deaths = GetPlayerDeaths(mydeaths) End If End Sub Private Sub GetNames(ByVal myNames As String) Dim myplayernames As String myplayernames = GetPlayerNames(myNames) If myplayernames <> "" Then Player = New CPlayer Player.Name = GetPlayerNames(myNames) End If End Sub Private Sub GetKills(ByVal amyKills As String) Dim myTempKills As String myTempKills = GetPlayerKills(amyKills) If myTempKills <> "" Then Player.Kills = GetPlayerKills(amyKills) End If End Sub Private Sub GetSuicides(ByVal mySuicides As String) Dim myTempKills As String myTempKills = GetPlayerSuicides(mySuicides) If myTempKills <> "" Then Player.Suicides = GetPlayerSuicides(mySuicides) End If End Sub Public Function GetPlayerSuicides(ByVal mySuicides As String) Dim reg As Regex = New Regex("Suicides:+\s*\w*") Dim m As Match = reg.Match(mySuicides) mySuicides = m.Value.Replace("Suicides: ", "") Return mySuicides End Function Public Function GetPlayerDeaths(ByVal myDEaths As String) As String Dim reg As Regex = New Regex("Deaths:+\s*\w*") Dim m As Match = reg.Match(myDEaths) myDEaths = m.Value.Replace("Deaths: ", "") Return myDEaths End Function Public Function GetPlayerNames(ByVal myPlayer As String) As String Dim reg As Regex = New Regex("\:+\s[a-zA-Z0-9<>?,.{}}\+_&=!@#$'%-|`*^:/;()~]+\s+\(u*") Dim m As Match = reg.Match(myPlayer) myPlayer = m.Value.TrimStart(": ").ToString 'changed test players Dim temp As String = myPlayer.Replace("(u", " ") Return temp End Function Public Function GetPlayerKills(ByVal myKills As String) As String Dim reg As Regex = New Regex("]+\sKills:+\s+\w+") Dim m As Match = reg.Match(myKills) myKills = m.Value.TrimStart("]") myKills = myKills.Replace("Kills: ", "") Return myKills End Function Public Function GetPlayerTeamKills(ByVal myTk As String) As String Dim reg As Regex = New Regex("m\s*\sKills:\s*\w*") Dim m As Match = reg.Match(myTk) Dim temp As String = m.Value.Replace("m ", "") temp = temp.Replace("Kills:", "") Return temp End Function Public Shared Function fGETDATE(ByVal myString As String) As String Dim reg As Regex = New Regex("((?<=\[)[^\[\]]*)") Dim m As Match = reg.Match(myString) myString = m.Value.ToString reg = Nothing Return myString End Function Public Function Players() As Collection Return m_Players End Function Public Sub RemovePlayer(ByVal index As Integer) m_Players.Remove(index) End Sub Public Function GetPLAYERCount() As Integer Return m_Players.Count End Function Public Function GetPLAYERObject(ByVal index As Integer) As CPlayer Return m_Players.Item(index) End Function End Class
-
Well, here is a rough idea of what I want. I need a better way to prime this. This is looping through a collection of player objects obviously I don�t want to add the first player objects together just ones that match names throughout the file and then remove the other unneeded player objects from the collection. It�s creating the totals for certain items off of one of our servers. I want redundant player names to be totaled and stored in the first instance of that player object. The rest of the redundant players eliminated. Think I wrote to much code today... :confused: Been writing code since about midnight last night. Sleepy now :confused:Hate when you get going on something sometimes and you can't pull yourself away from it....aaarghhh Private Sub TotalPlayers() Try Dim i As Integer Dim x As Integer With PlayersList For i = 1 To .GetPLAYERCount For x = 1 To .GetPLAYERCount Step 1 Dim kills, deaths, teamkills, suicides, objective As Integer If .GetPLAYERObject(i).Name = .GetPLAYERObject(x).Name Then kills = Convert.ToInt32(.GetPLAYERObject(i).Kills) + Convert.ToInt32(.GetPLAYERObject(x).Kills) .GetPLAYERObject(i).Kills = Convert.ToString(kills) deaths = Convert.ToInt32(.GetPLAYERObject(i).Deaths) + Convert.ToInt32(.GetPLAYERObject(x).Deaths) .GetPLAYERObject(i).Deaths = Convert.ToString(deaths) teamkills = Convert.ToInt32(.GetPLAYERObject(i).TeamKills) + Convert.ToInt32(.GetPLAYERObject(x).TeamKills) .GetPLAYERObject(i).TeamKills = Convert.ToString(teamkills) suicides = Convert.ToInt32(.GetPLAYERObject(i).Suicides) + Convert.ToInt32(.GetPLAYERObject(x).Suicides) .GetPLAYERObject(i).Suicides = Convert.ToString(suicides) objective = Convert.ToInt32(.GetPLAYERObject(i).Objective) + Convert.ToInt32(.GetPLAYERObject(x).Objective) .GetPLAYERObject(i).Objective = Convert.ToString(objective) .RemovePlayer(x) End If Next Next End With WritePlayers() Catch ex As Exception Dim mm As New System.Net.Mail.SmtpClient mm.Host = "smtp.charter.net" mm.Send("itower@chartermi.net", "itower@chartermi.net", "error", ex.ToString) End Try End Sub Yeah I have it now!Disregard this post.I hate when I post and figure it out right away. I'm silly im removing objects...I think I have it.But any suggestions I'll take right now...lol.
-
[PLAIN][RESOLVED]Parsing a file with RegEx[/PLAIN] Hi. I normally use substring and other methods to parse files.But I wanted to try something new.I am parsing the file as its streaming from an FTP server on the Web with ASP.Maybe I am in the wrong section.Plus my first time using REgEx..lol.I downloaded that espresso regex tutorial last night. I am having a problem retriveing all of the player names and I don't know why. Here is a small example output of the file.Oh and my first time trying 2005.I have used 2002 or 2003 in the past. 1158089131 [Tue Sep 12 14:25:31 2006] [Tue Sep 12 14:25:31 2006] ------------------------------------------ [Tue Sep 12 14:25:31 2006] Server started. [Tue Sep 12 18:26:22 2006] Client connected: StoNer [Tue Sep 12 18:26:51 2006] Client connected: ||3RB||Multigun [Tue Sep 12 18:34:52 2006] Client connected: B&F_PROSMOKER [Tue Sep 12 18:36:20 2006] Client connected: ChibiPyro [Tue Sep 12 18:38:40 2006] Client connected: [TF]Sabrina [Tue Sep 12 18:40:14 2006] Client connected: RED_jºnbºy [Tue Sep 12 18:40:42 2006] Client connected: Kalekemo [Tue Sep 12 18:40:46 2006] Client disconnected: RED_jºnbºy [Tue Sep 12 18:41:39 2006] Client connected: ConChip [Tue Sep 12 18:43:35 2006] Client connected: Player [Tue Sep 12 18:45:15 2006] Client disconnected: ConChip [Tue Sep 12 18:45:34 2006] Client disconnected: B&F_PROSMOKER [Tue Sep 12 18:46:31 2006] Client disconnected: Player [Tue Sep 12 18:46:41 2006] Client connected: Player [Tue Sep 12 18:46:47 2006] Client disconnected: Player [Tue Sep 12 18:48:09 2006] [Tue Sep 12 18:48:09 2006] *** Results for Map: Worlds\ReleaseMultiplayer\DOOME4M9v2 [Tue Sep 12 18:48:09 2006] [Tue Sep 12 18:48:09 2006] Team: Team 1 [Tue Sep 12 18:48:09 2006] Score: 7 [Tue Sep 12 18:48:09 2006] [Tue Sep 12 18:48:09 2006] Player: StoNer (uid: ce35bbd1d0cfeb354ad6c51a45e86a80) [Tue Sep 12 18:48:09 2006] Score: 771 [Tue Sep 12 18:48:09 2006] Kills: 30 [Tue Sep 12 18:48:09 2006] Deaths: 16 [Tue Sep 12 18:48:09 2006] Team Kills: 0 [Tue Sep 12 18:48:09 2006] Suicides: 1 [Tue Sep 12 18:48:09 2006] Objective: 645 [Tue Sep 12 18:48:09 2006] [Tue Sep 12 18:48:09 2006] Player: [TF]Sabrina (uid: 3a9f1c3bcabec404751b8ce6db9b3f78) [Tue Sep 12 18:48:09 2006] Score: 20 [Tue Sep 12 18:48:09 2006] Kills: 3 [Tue Sep 12 18:48:09 2006] Deaths: 6 [Tue Sep 12 18:48:09 2006] Team Kills: 0 [Tue Sep 12 18:48:09 2006] Suicides: 0 [Tue Sep 12 18:48:09 2006] Objective: 10 [Tue Sep 12 18:48:09 2006] [Tue Sep 12 18:48:09 2006] Team: Team 2 [Tue Sep 12 18:48:09 2006] Score: 2 [Tue Sep 12 18:48:09 2006] [Tue Sep 12 18:48:09 2006] Player: ||3RB||Multigun (uid: b9e14e8150b253cd0e8a6188dec759c1) [Tue Sep 12 18:48:09 2006] Score: 318 [Tue Sep 12 18:48:09 2006] Kills: 13 [Tue Sep 12 18:48:09 2006] Deaths: 27 [Tue Sep 12 18:48:09 2006] Team Kills: 0 [Tue Sep 12 18:48:09 2006] Suicides: 2 [Tue Sep 12 18:48:09 2006] Objective: 290 [Tue Sep 12 18:48:09 2006] [Tue Sep 12 18:48:09 2006] Player: ChibiPyro (uid: 9c2e0c51e128fd45f3bab7a8cc9a2282) [Tue Sep 12 18:48:09 2006] Score: 188 [Tue Sep 12 18:48:09 2006] Kills: 13 [Tue Sep 12 18:48:09 2006] Deaths: 12 [Tue Sep 12 18:48:09 2006] Team Kills: 0 [Tue Sep 12 18:48:09 2006] Suicides: 0 [Tue Sep 12 18:48:09 2006] Objective: 135 Basically I am creating a Player stats system.I Have 2 classes.CPlayer the defines all the attributes of a player and a CPlayerList(The one I am having problems with Class).This Class creates instances of Cplayer and parses the file then adds them to a collection that can be retrieved by index number.It seems like its starts about 3 players down from top and 3 players up from bottom.My hope was to parse this file everynight once a day and then save it to a file on a different webserver.Parsed comma delimited so it's easy to use.I thought maybe it was having problems reading and parsing the data at the same time.But there is no application.doevents() in ASP.Maybe Threading? I'll show you just the part that seems to be a miss... Try Dim Player As CPlayer Do While reader.Read Dim myPlayer As String If GetPlayerNames(myPlayer) <> Nothing Then Player = New CPlayer Player.Name = GetPlayerNames(myPlayer) lbox.Items.Add(Player.Name) End If Loop reader.Close() Catch ex As Exception End Try 'The Function here Public Function GetPlayerNames(ByVal myPlayer As String) As String Dim reg As Regex = New Regex("\:+\s[a-zA-Z0-9<>?,.{}+_&=!@#$%-|`*^:/;()~]+\s*\(u*") Dim m As Match = reg.Match(myPlayer) myPlayer = m.Value.TrimStart(": ") Dim temp As String = myPlayer.Replace("(u", " ") Return temp End Function EDIT:I figured it out I had to do this Do While reader.Read Dim myPlayer As String Dim TempPlayers As String myPlayer = reader.ReadLine TempPlayers = GetPlayerNames(myPlayer) If TempPlayers <> Nothing Then Player = New CPlayer Player.Name = GetPlayerNames(myPlayer) cList.Items.Add(Player.Name) End If
-
Looks almost identical to a book example I have...
-
This is fun... Spiritual
-
I think this is my first post. my post
-
Yeah pretty much, all the same. I�m much more active in the sister forum, however I'm still not that active as I was say a year ago.
-
Just checked it out, it does if Implements IDisposable is first. But if it's a comma separated list of implements it does not.
-
That�s really interesting to me because just recently I was creating a custom collection that implemented IEnumerable and IDisposable and it didn't do any such thing. No commented code or any snippets. Maybe it is just the order of the implements. I�m going to have to go check this out.
-
Make them sign a non-disclosure agreement.
-
That was an accident in my post.Thats not in my code.
-
What does?Or limit the amount of lines?
-
I need to limit the amount of characters that are able to be put in the textbox depending on what they pick. I thought you could use textbox1.maxlength= the number here But they doesnt work. Any ideas?