Thread: vbscript help
View Single Post
Old 2008-11-12, 07:40   #12
Patrick123
 
Patrick123's Avatar
 
Jan 2006
JHB, South Africa

157 Posts
Default

Quote:
Originally Posted by IronBits View Post
All my filenames that I parse end with .org.txt so I'm making copies of the original files to create the .txt and .csv files.
I suppose if someone passed the filename Results.txt as an argument, this would fail...
Yes, I see that very likely you will end up opening your input file for output. The best may be to check if the output file exists first or if the two files are the same & give an error message.

The other piece of code:
Code:
        Team_Name = MyArray(1)
        arrMyTeamName = Split(Team_Name,"_",-1,1)
        if arrMyTeamName(0) = "gd" Then UserName = Team_Name End If
        If arrMyTeamName(0) = "Free-DC" Then UserName = arrMyTeamName(1) End If
        If arrMyTeamName(0) = "AMDUsers" Then UserName = arrMyTeamName(1) End If
        If arrMyTeamName(0) = "ArsTechnica" Then UserName = arrMyTeamName(1) End If
        If arrMyTeamName(0) = "XtremeSystems" Then UserName = arrMyTeamName(1) End If
        If arrMyTeamName(0) = "Team_Italia" Then UserName = arrMyTeamName(1) End If
        If arrMyTeamName(0) = "XGrubbersKickAss" Then UserName = arrMyTeamName(1) End If
        If arrMyTeamName(0) = "Ukraine" Then UserName = arrMyTeamName(1) End If
        If arrMyTeamName(0) = "Singapura" Then UserName = arrMyTeamName(1) End If
        If arrMyTeamName(0) = "RaidersOfTheLostPrime" Then UserName = arrMyTeamName(1) End If
My suggestion is to try not to hardcode data in you program at all if you can help it, rather use something like this:
Code:
        Team_Name = MyArray(1)
        arrMyTeamName = Split(Team_Name,"_",-1,1)
        If UBound(arrMyTeamName) > 0 then
             UserName = arrMyTeamName(1)
        Else
             UserName = Team_Name
        End If

Regards
Patrick
Patrick123 is offline   Reply With Quote