Announcement

Collapse
No announcement yet.

Custom List manager

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Custom List manager

    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:
    LST081337||Festnetz
    ICO$SKINPATH$include\contacts\userpics\Kai.jpg
    LST+4915153||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 Or 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
    Last edited by pierrotm777; 05-23-2013, 11:37 AM.

  • #2
    just add a "0" to the first line of the list. The first line I believe is supposed to show the number of items in the list.
    mp3Car.com Senior Tech Blogger (Want a product reviewed? Contact me.)
    Follow Me on Twitter or Facebook
    Live mp3Car Facebook Chat

    Comment


    • #3
      Why add a 0 if i use the clload with the TRUE option ?

      Comment


      • #4
        Originally posted by pierrotm777 View Post
        Why add a 0 if i use the clload with the TRUE option ?
        I have no idea how its coded in the core, but in looking at your .txt file, its not plain text. You have lines that RR has to parse, a plain text file would have no LST ICO delimiters associated with it.

        If you're building your text file in your plugin there's no reason to try to build it as plain text, RR still has to do the work to format it based on your delimiter values.
        mp3Car.com Senior Tech Blogger (Want a product reviewed? Contact me.)
        Follow Me on Twitter or Facebook
        Live mp3Car Facebook Chat

        Comment


        • #5
          I use this format because the RR user that ask me to create this manager for him want a minimum into the plugin , just add , delete and modify custom list functions !
          It's why i use this format that RR know directly !

          Comment


          • #6
            Originally posted by pierrotm777 View Post
            I use this format because the RR user that ask me to create this manager for him want a minimum into the plugin , just add , delete and modify custom list functions !
            It's why i use this format that RR know directly !
            So you're not creating the list, you're simply adding/removing/modifying an item in the list? Whatever plugin or program that's creating the list simply needs to place a "0" placeholder in the top line of the text file. Then your code above works just fine.
            Last edited by Sonicxtacy02; 05-23-2013, 10:13 AM.
            mp3Car.com Senior Tech Blogger (Want a product reviewed? Contact me.)
            Follow Me on Twitter or Facebook
            Live mp3Car Facebook Chat

            Comment


            • #7
              I suppose that the line objFile.Write("0") add a 0 on the first line but i don't understand the need of this 0.

              Comment


              • #8
                Originally posted by pierrotm777 View Post
                I suppose that the line objFile.Write("0") add a 0 on the first line but i don't understand the need of this 0.
                The 0 is technically supposed to contain the number of items in the list. Its my assumption that it was added to the Custom List code for future-proofing or something, but it doesn't really have any value that I know of. The bottom line is CLLOAD expects the list items to begin on line 2 of the text file. That's the way the file is parsed.
                mp3Car.com Senior Tech Blogger (Want a product reviewed? Contact me.)
                Follow Me on Twitter or Facebook
                Live mp3Car Facebook Chat

                Comment


                • #9
                  I obtain exactly the same issue:
                  Original list:
                  Code:
                  0
                  LST081337||Festnetz
                  ICO$SKINPATH$include\contacts\userpics\Kai.jpg
                  LST+4915153||CarHandy
                  ICO$SKINPATH$include\contacts\userpics\CarHandy.jpg
                  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
                  List modified:
                  Code:
                  0
                  LST081337||Festnetz
                  ICO$SKINPATH$include\contacts\userpics\Kai.jpg
                  LST+4915153||CarHandy
                  ICO$SKINPATH$include\contacts\userpics\CarHandy.jpg
                  LST+4915153||Carton
                  ICO$SKINPATH$include\Contacts\userpics\CarHandy.jpg
                  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
                  As you can to see, the blue lines aren't replaced by the red lines !
                  This are the green lines that are replaced !
                  Last edited by pierrotm777; 05-23-2013, 11:37 AM.

                  Comment


                  • #10
                    Originally posted by pierrotm777 View Post
                    I obtain exactly the same issue:
                    Original list:
                    Code:
                    0
                    LST081337||Festnetz
                    ICO$SKINPATH$include\contacts\userpics\Kai.jpg
                    LST+4915153||CarHandy
                    ICO$SKINPATH$include\contacts\userpics\CarHandy.jpg
                    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
                    List modified:
                    Code:
                    0
                    LST081337||Festnetz
                    ICO$SKINPATH$include\contacts\userpics\Kai.jpg
                    LST+4915153||CarHandy
                    ICO$SKINPATH$include\contacts\userpics\CarHandy.jpg
                    LST+4915153||Carton
                    ICO$SKINPATH$include\Contacts\userpics\CarHandy.jpg
                    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
                    As you can to see, the blue lines aren't replaced by the red lines !
                    This are the green lines that are replaced !
                    did you modify your command so that everything shifts to compensate for the new line? you have to factor out line 1 when building your array
                    mp3Car.com Senior Tech Blogger (Want a product reviewed? Contact me.)
                    Follow Me on Twitter or Facebook
                    Live mp3Car Facebook Chat

                    Comment


                    • #11
                      Originally posted by Sonicxtacy02 View Post
                      did you modify your command so that everything shifts to compensate for the new line? you have to factor out line 1 when building your array
                      It's not important because the function 'GiveLineNumberForString' return the real line !

                      Comment


                      • #12
                        I'm honestly out of suggestions here. I'm just lookin at the code snippets you've offered and trying to help. Only other thing i'd say try is remove the ;TRUE parameter from your CLLOAD.
                        Last edited by Sonicxtacy02; 05-23-2013, 12:55 PM.
                        mp3Car.com Senior Tech Blogger (Want a product reviewed? Contact me.)
                        Follow Me on Twitter or Facebook
                        Live mp3Car Facebook Chat

                        Comment


                        • #13
                          I have found my issues!
                          Firstly, GiveLineNumberForString doesn't return the good line , i think that is because the list is a UNICODE file ?
                          Secondly, when i put my list into an array, i forgot than the first value is 0 not 1 !
                          So my code can to be:
                          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, strLine, strNewContents
                              'GiveLineNumberForString CustomList, StringToMofify
                              ReturnedLineNumberForString = (Val(RRSDK.GetUserVar("PBCLPOS")) * 2) - 1
                              'RRSDK.SetUserVar "StringToMofify", StringToMofify & " --> " & ReturnedLineNumberForString
                              Set objFSO = CreateObject("Scripting.FileSystemObject")
                              Set objFile = objFSO.OpenTextFile(CustomList, ForReading, True, -1)
                              allLines = objFile.ReadAll
                              'MsgBox allLines.Line 'number of lines
                              arrLines = Split(allLines, vbCrLf)
                              arrLines(ReturnedLineNumberForString - 1) = "LST" & CLText & "||" & CLDescription
                              arrLines(ReturnedLineNumberForString) = "ICO" & CLImg
                              objFile.Close
                              Set objFSO = CreateObject("Scripting.FileSystemObject")
                              Set objFile = objFSO.OpenTextFile(CustomList, ForWriting, True, -1)
                              'RRSDK.SetUserVar "LN", UBound(arrLines)
                              'For x = 0 To UBound(arrLines)
                                  'objFile.Write (arrLines(x) & vbCrLf)
                              'Next
                              Dim MyLine
                              For Each MyLine In arrLines
                                  objFile.Write (MyLine & vbCrLf)
                              Next
                              
                              objFile.Close
                              
                          End Sub
                          I replace my command 'GiveLineNumberForString CustomList, StringToMofify' by the line:
                          Code:
                          ReturnedLineNumberForString = (Val(RRSDK.GetUserVar("PBCLPOS")) * 2) - 1
                          where RRSDK.GetUserVar("PBCLPOS") is the CLPOS value.
                          Last edited by pierrotm777; 05-28-2013, 05:41 AM.

                          Comment


                          • #14
                            For future ref, that first line in the file tells RR what line you want selected when the file/list is loaded, with the default being the first item or item 0. You can see this if you select an item farther down in the list and then do a CLSAVE cmd and then look at the first line. Item that was selected when that list was saved will be that first line +1
                            RideRunner...The #1 FE, PERIOD.

                            Current Project: DFXVoice [v1.0 Released]
                            Next in line: RRMedia v2.0

                            DFX 5.1.1 Skin
                            Appstore Link

                            My RideRunner Plugins
                            RRMedia
                            RRExtended
                            DFXVoice

                            "There are no bugs - only undocumented features."

                            Comment


                            • #15
                              the problem of clsave is, that clsave deletes the line with the icon-path.
                              so, we needed a plugin, which do this job.
                              and it works :-)
                              RR-Skin: BMW OpenBM Skin for E39 [never ending progress :-(]
                              RR-Plugin: IBusCommunicatoRR new Updates

                              Comment

                              Working...
                              X