I try to create a function in vb6 that modify a line of my custom list but the first line isn't delete !
my list format :
Code:
LST08133760093||Festnetz
ICO$SKINPATH$include\contacts\userpics\Kai.jpg
LST+4915153693230||CarHandy
...
I try to create a function in vb6 that modify a line of my custom list but the first line isn't delete !
my list format :
Code:
LST08133760093||Festnetz
ICO$SKINPATH$include\contacts\userpics\Kai.jpg
LST+4915153693230||CarHandy
ICO$SKINPATH$include\contacts\userpics\0_default.png
LST74123||Torsten
ICO$SKINPATH$include\contacts\userpics\0_default.png
LST64123||Peter
ICO$SKINPATH$include\contacts\userpics\0_default.png
LST64189||Heidi
ICO$SKINPATH$include\contacts\userpics\0_default.png
LST147258||Petra
ICO$SKINPATH$include\contacts\userpics\0_default.png
LST55555||Anne
ICO$SKINPATH$include\Contacts\userpics\Anne.Jpg
LST789||Mandy
ICO$SKINPATH$include\Contacts\userpics\Mandy.Jpg
LST963||Lisa
ICO$SKINPATH$include\Contacts\userpics\Lisa.Jpg
LST0815||Hampelmann
ICO$SKINPATH$include\Contacts\userpics\Peter.Jpg
my function in vb6:
Code:
Public Sub ModifyCustomList(ByVal CustomList As String, ByVal StringToMofify As String, ByVal CLText As String, CLDescription As String, CLImg As String)
Dim strPath() As String
Dim lngIndex As Long
strPath() = Split(CLImg, "\")
lngIndex = UBound(strPath)
CLImg = "$SKINPATH$include\Contacts\userpics\" & strPath(lngIndex)
Const ForReading = 1: Const ForWriting = 2
Dim objFSO, objFile, allLines, arrLines, x
GiveLineNumberForString CustomList, StringToMofify
'RRSDK.SetUserVar "StringToMofify", StringToMofify & " --> " & ReturnedLineNumberForString
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(CustomList, ForReading, True, -1)
allLines = objFile.ReadAll
arrLines = Split(allLines, vbCrLf)
arrLines(ReturnedLineNumberForString) = "LST" & CLText & "||" & CLDescription & vbCrLf
arrLines(ReturnedLineNumberForString + 1) = "ICO" & CLImg & vbCrLf
objFile.Close
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(CustomList, ForWriting, True, -1)
For x = 1 To UBound(arrLines)
If x = ReturnedLineNumberForString Then
objFile.Write (arrLines(ReturnedLineNumberForString))
End If
If x = ReturnedLineNumberForString + 1 Then
objFile.Write (arrLines(ReturnedLineNumberForString + 1))
End If
If x ReturnedLineNumberForString + 1 Then
objFile.Write (arrLines(x) & vbCrLf)
End If
Next
objFile.Close
End Sub
Public Sub GiveLineNumberForString(ByVal FileName As String, ByVal strToSearch As String) 'As Integer
Dim strTextLine As String
Dim l As Long
'ReturnedLineNumberForString = 0
Open FileName For Input As #1
Do While Not EOF(1)
l = l + 1
Line Input #1, strTextLine
If InStr(strTextLine, strToSearch) Then
'MsgBox strToSearch & " is on line " & l
ReturnedLineNumberForString = l
End If
Loop
'Return
Close #1
End Sub
I use this command like that:
Code:
'ibuscommunicatorrext;modifycontact;$SKINPATH$phone_list.txt;$NEWNUMBER$|$NEWNAME$|$NEWIMG$
If LCase(Left$(CMD, 32)) = "ibuscommunicatorr;modifycontact;" Then
IconPath = Split(dt(3), "|")
ToLog ("The contact " & RRSDK.GetUserVar("MODNAME") & " is modified")
ToLog ("New number " & IconPath(0))
ToLog ("New name " & IconPath(1))
ToLog ("New icon " & IconPath(2))
ModifyCustomList dt(2), RRSDK.GetUserVar("MODNAME"), IconPath(0), IconPath(1), IconPath(2) 'Number,Name,Icon
ProcessCommand = 2
End If
Thanks for your help