string functions

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • deguix
    Major Dude
    • Dec 2002
    • 1354

    #31
    * finding index of char/substr in string
    Maybe a change to StrStr to do that, so I have to work a little bit...

    * finding first occurence char from subset in string starting from index.
    You can do this using StrCpy to customize where it will start and use StrStr Function.

    * replacing char/substring in string
    Use StrReplace Function.

    * conversion to/from C-style strings (for easier using strings in Windows functions).
    Hmmmm... maybe using System plugin or Math plugin. I will try to search.

    * concatenating string (in current system name of veriable is joined with following text, which can make trouble in some cases) OR append-to-text function.
    One command resume it all: StrCpy.

    PS. How to display path text from string char in Label control of dialog window? I have to convert it to C-style string; creating such function in current script would be quite painful.
    Use NSISToIO inside header file. (I don't know if this is right if you want to do that in a normal dialog from Windows or something)
    My Wiki Pages

    Working now on:
    New projects. (language: any)

    Comment

    • kichik
      M.I.A.
      [NSIS Dev, Mod]
      • Oct 2001
      • 11343

      #32
      conversion to/from C-style strings (for easier using strings in Windows functions).
      NSIS uses C-style strings. What do you mean by this?
      NSIS FAQ | NSIS Home Page | Donate $
      "I hear and I forget. I see and I remember. I do and I understand." -- Confucius

      Comment

      • kichik
        M.I.A.
        [NSIS Dev, Mod]
        • Oct 2001
        • 11343

        #33
        Any estimate to when 1.00 will be ready?
        NSIS FAQ | NSIS Home Page | Donate $
        "I hear and I forget. I see and I remember. I do and I understand." -- Confucius

        Comment

        • deguix
          Major Dude
          • Dec 2002
          • 1354

          #34
          Hehehe, I bought a new game and I and my brother couldn't stop to play it until now... but it is nearly done. 6:00 AM of tomorrow is done, or more soon if it is possible... (sharing pc problems, you know)
          My Wiki Pages

          Working now on:
          New projects. (language: any)

          Comment

          • deguix
            Major Dude
            • Dec 2002
            • 1354

            #35
            Version 1.00 done. Included the header file and manual.

            Changes:

            - Added documentation.
            - Renamed header file to "StrFunc.nsh".
            - Added 1 function, StrLoc.
            - Modified StrStrAdv, removed some lines.
            - Fixed StrTok, 2 simple numbers made it loop everytime.
            - Fixed some small issues in the header file.
            Attached Files
            My Wiki Pages

            Working now on:
            New projects. (language: any)

            Comment

            • kichik
              M.I.A.
              [NSIS Dev, Mod]
              • Oct 2001
              • 11343

              #36
              Thanks.

              I tried to write an example file for the header file but stumbled upon a few problems. The example file, including the described problems is attached.

              StrLoc doesn't seem to function when the string it searches for is larger than the string it searches in. I found this because I got confused of the readme which states the usage line is:

              ${StrLoc} ResultVar String StrToSearchIn Direction

              On first look it looks like I'm supposed to put the string that I want searched in StringToSearchIn, but it's the other way around. How about SearchIn SearchFor?

              According to my understanding, the next line should return "abc", but it doesn't:

              ${StrStrAdv} $0 "abcabcabc" "abc" "<" ">" "0" "1"

              It returns an empty string. If I search for the second occurrence of "abc" in "abcabcabc", starting from the right position, it should find the second set of "abc", but it doesn't.

              StrSort doesn't seem to want to search for more than one char (line 136). It also has a problem if you want to search for "error" (line 139).

              And last but not least, StrTok gets stuck in an endless loop if the token number is 0.
              Attached Files
              NSIS FAQ | NSIS Home Page | Donate $
              "I hear and I forget. I see and I remember. I do and I understand." -- Confucius

              Comment

              • deguix
                Major Dude
                • Dec 2002
                • 1354

                #37
                Version 1.01, all bugs you said are fixed:

                - Fixed Documentation about StrSort and StrTok.
                - Fixed StrTok default value for the string part. Now it's "L".
                - Fixed StrStrAdv fixed wrong search when had a combination of same substrings one after another in a string.
                - Fixed StrLoc, when a string isn't found, don't return any value at all.

                Read the manual for see more details.
                Attached Files
                My Wiki Pages

                Working now on:
                New projects. (language: any)

                Comment

                • kichik
                  M.I.A.
                  [NSIS Dev, Mod]
                  • Oct 2001
                  • 11343

                  #38
                  StrLoc and StrSort are still not working right. The documentation of StrSort got mixed up. It's talking about StringToSearch but there is no such parameter on the usage line. Example attached.
                  Attached Files
                  NSIS FAQ | NSIS Home Page | Donate $
                  "I hear and I forget. I see and I remember. I do and I understand." -- Confucius

                  Comment

                  • kichik
                    M.I.A.
                    [NSIS Dev, Mod]
                    • Oct 2001
                    • 11343

                    #39
                    Fixed StrLoc, removed StrSort and added to CVS.
                    NSIS FAQ | NSIS Home Page | Donate $
                    "I hear and I forget. I see and I remember. I do and I understand." -- Confucius

                    Comment

                    • deguix
                      Major Dude
                      • Dec 2002
                      • 1354

                      #40
                      Oh right, as you wish...
                      My Wiki Pages

                      Working now on:
                      New projects. (language: any)

                      Comment

                      • deguix
                        Major Dude
                        • Dec 2002
                        • 1354

                        #41
                        But I did another version, adding my new AdvStrSort, and fixing spelling errors in the documentation:

                        New in 1.02 - 02/07/04:
                        -----------------------

                        - Fixed Documentation about StrLoc. "Direction" is really
                        "OffsetDirection".
                        - Added my new AdvStrSort, and removed the old one.
                        I tested the new function all night until now, and it's working.

                        Kichik, don't dispair. Use the same example you're using just adding the new qualities of AdvStrSort (called inside as StrSort). Nothing was changed in other functions.

                        Example of use - StrSort:

                        code:
                        ${StrSort} $0 "This is just an example" " just" "" "ple" "0" "0"

                        $0 = "This is an exam"

                        ;"This is just an example" is the String
                        ;" just" is the CenterStr
                        ;"" is the LeftStr
                        ;"ple" is the RightStr
                        ;Display LeftStr and RightStr FALSE
                        ;Display CenterStr FALSE

                        Attached Files
                        My Wiki Pages

                        Working now on:
                        New projects. (language: any)

                        Comment

                        • kichik
                          M.I.A.
                          [NSIS Dev, Mod]
                          • Oct 2001
                          • 11343

                          #42
                          Are you sure you want to keep the old version of the readme and not use my changes?

                          This StrSort call fails:

                          ${StrSort} $0 "This is just an example" "j" "" "" "1" "0"
                          StrCmp $0 "This is ust an example" 0 strsorterror
                          NSIS FAQ | NSIS Home Page | Donate $
                          "I hear and I forget. I see and I remember. I do and I understand." -- Confucius

                          Comment

                          • deguix
                            Major Dude
                            • Dec 2002
                            • 1354

                            #43
                            Yep. Because the last "0" says that will not include the CenterStr.

                            I did your changes in my documentation. Only if had any more changes you did in other functions but StrLoc...

                            You can do any changes to it, I can't go to Internet 9:00AM to 10:00PM (but sometimes I can with a little help...).
                            My Wiki Pages

                            Working now on:
                            New projects. (language: any)

                            Comment

                            • kichik
                              M.I.A.
                              [NSIS Dev, Mod]
                              • Oct 2001
                              • 11343

                              #44
                              But it does include CenterStr, that's the problem.

                              The zip you've attached doesn't include a single change I made to the readme.
                              NSIS FAQ | NSIS Home Page | Donate $
                              "I hear and I forget. I see and I remember. I do and I understand." -- Confucius

                              Comment

                              • deguix
                                Major Dude
                                • Dec 2002
                                • 1354

                                #45
                                Fixed and included your changes in the readme.
                                Attached Files
                                My Wiki Pages

                                Working now on:
                                New projects. (language: any)

                                Comment

                                Working...
                                X