Dim CharList
Charlist = " ,/.!@#$%^&*()?><';:+-=_[]{}|" & vbCrLf & vbTab & vbCr & vbLf & vbNewLine & vbBack

Set fso = CreateObject ("Scripting.FileSystemObject")
Set tsTextInFile = fso.OpenTextFile ("STUDENT.TXT", 1, False)

txtTextOutFile = "STU-rc-out.txt"
Set fso = CreateObject ("Scripting.FileSystemObject")
Set tsTextOutFile = fso.OpenTextFile (txtTextOutFile, 8,True)

While Not tsTextInFile.AtEndOfStream
	
	strRecord = tsTextInFile.ReadLine
	arrRecord = Split (strRecord, ";")
		
	rec1 = arrRecord(0)
	commaPos = InStr(1,arrRecord(1),",",1)
	
	If commaPos = 0 then
		tmpRec2 = Left(arrRecord(1),15)
	Else
		tmpRec2 = Left(Left(arrRecord(1),commaPos - 1),15)
	End If
	
	rec2 = CleanWord(tmpRec2)
	tmpRec3 = Left(arrRecord(2),10)
	rec3 = CleanWord(tmpRec3)
	rec4 = arrRecord(3)
	rec5 = arrRecord(4)
	tmpRec6 = arrRecord(5)
	
	If Left(tmpRec6,1) = "0" Then
		If tmpRec6 = "00" Then
			rec6 = "K"
		Else
			rec6 = Right(tmpRec6,1)
		End If
	Else
		rec6 = tmpRec6
	End If
	
	tsTextOutFile.Write Chr(34) & rec1 & Chr(34) & "," &  Chr(34) & rec2 & Chr(34) & "," & Chr(34) & rec3 & Chr(34) & "," & Chr(34) & rec4 & Chr(34) & "," & Chr(34) & rec5 & Chr(34) & "," & Chr(34) & rec6 & Chr(34) & vbNewLine
	
Wend

wscript.echo "Script Complete"


Function CleanWord(vstrWord)

    'Function removes punctuation values from the word and returns
    'only those values not included in the CharList constant
    
    Dim j
    Dim oneChar
    
    For j = 1 To Len(vstrWord)
        oneChar = Mid(vstrWord, j, 1)
        If (InStr(CharList, oneChar) = 0) Then
            CleanWord = CleanWord & oneChar
        End If
    Next
    
End Function