Hi.
I would like to use vbscript to reformat text in a musiclibrary.
I allready got good help in building a part of the script.
(Thanks very much to Tom Ogilvy and Helmut Weber...)
Short explanation:
1. Reading a textfile - line by line:
Could be done with the script:
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("c:\composer.txt", ForReading)
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
arrServiceList = Split(strNextLine , vbNewLine)
'Wscript.Echo arrServiceList(0)
For i = 1 to Ubound(arrServiceList)
' Wscript.Echo arrServiceList(i)
Next
Loop
2. Reformat the text in each line by the script:
Dim s 'the text in variable s should be replaced by the text from line 1 in
the textfile.
s = "ADAMS, BRYAN (ENG) + " & "DENVER, JOHN (USA) + JARRE, " & "JEAN
MICHELLE (FRA) + " & "THE BEATLES + THE DOORS"
wscript.echo(SwitchOrder(s))
Public Function SwitchOrder(s)
Dim v,s1,s2,s3,s4,s5,iloc,iloc1
v = Split(s, "+")
For i = LBound(v) To UBound(v)
s1 = Trim(v(i))
iloc = InStr(1, s1, "(", vbTextCompare)
If iloc <> 0 Then
s5 = Trim(Right(s1, Len(s1) - iloc + 1))
s2 = Left(s1, iloc - 1)
iloc1 = InStr(1, s2, ",", vbTextCompare)
s3 = Trim(Left(s2, iloc1 - 1))
s4 = Trim(Right(s2, Len(s2) - iloc1))
s4 = s4 & " " & s3 & " " & s5
v(i) = s4
End If
Next
SwitchOrder = Join(v, " + ")
End Function
3. Write the result into a new textfile
*****Example of a textfile:
DENVER, JOHN (USA) + MOORE, ROGER (USA)
THE BEATLES + STEWART, ROD
...
....
.....
I'm having problem with combining all my information to form the total
script.
Any experts who can answer ?
Best regards
\T.Tei