Announcement

Collapse
No announcement yet.

Easy Array Scan question :)

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

  • Easy Array Scan question :)

    It dawned on my why this is not working....
    Array Scan g_Files(), = "!", To lResult


    g_Files contains a list of files and that file is indeed in that list...

    As c:\foldername\!

    The file is used as a license file, LZH used to employ this technique.

    So I don't want to remove directory names from the file list simply because the files might not all be in the same directory and I don't want to have another array for directories....

    Anybody see a workaround here short of doing this:

    For x = 1 to 10
    if Right$(g_Files(x),1) = "!" Then LicenseFlag = %TRUE
    Next

    ------------------
    Scott
    mailto:[email protected][email protected]</A>
    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

  • #2
    Perhaps there is a way to take advantage of the COLLATE feature to weight the "!" and search for the string using the > operator? I don't have a lot of experience with COLLATE, but it appears to be possible.



    ------------------
    Bernard Ertl
    Bernard Ertl
    InterPlan Systems

    Comment


    • #3
      The LB_FINDSTRING message can be used to find the first string in
      a list box that contains the specified search. Could be useful here.


      ------------------

      Comment


      • #4
        Code:
        Type MyFiles
         Folder as String   * 200
         FileName as String * 60
        End Type
        
        Dim FileTest as String*60 
        Lset FileTest = "!"
        Array Scan g_Files(),FROM 201 TO 260, =FileTest, To lResult
        ------------------
        Fred
        mailto:[email protected][email protected]</A>
        http://www.oxenby.se



        [This message has been edited by Fred Oxenby (edited February 01, 2001).]
        Fred
        mailto:[email protected][email protected]</A>
        http://www.oxenby.se

        Comment


        • #5
          Thanks guys, preciate the tips but it has to be precise, some files may contain ! and throw it off..
          It's going to be a for next loop, it's only 10 to 100 files anyway...


          Soctt

          ------------------
          Scott
          mailto:[email protected][email protected]</A>
          Scott Turchin
          MCSE, MCP+I
          http://www.tngbbs.com
          ----------------------
          True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

          Comment


          • #6
            Scott,

            If other files may contain the ! then you may want to check for
            RIGHT$(filename$,2) = "\!" to make sure the ! is the filename.

            Trivial, but you never know.

            Mike

            ------------------

            Comment


            • #7
              As fast as PowerBasic is, this ought to work nicely

              This *DOES* work nicely in fact Was just two extra lines of code but no bigge..

              Code:
              For lLoop = 1 To g_FileIndex
                  If Right$(g_Files(lLoop),1) = "!" Then g_hdLicenseFlag = 1
              Next
              ------------------
              Scott
              mailto:[email protected][email protected]</A>
              Scott Turchin
              MCSE, MCP+I
              http://www.tngbbs.com
              ----------------------
              True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

              Comment


              • #8
                what happens if there are a file named "\dont_use_me_!" ?


                ------------------
                Fred
                mailto:[email protected][email protected]</A>
                http://www.oxenby.se



                [This message has been edited by Fred Oxenby (edited February 01, 2001).]
                Fred
                mailto:[email protected][email protected]</A>
                http://www.oxenby.se

                Comment


                • #9
                  Good point:


                  Code:
                  For lLoop = 1 To g_FileIndex
                      If Dir$(g_Files(lLoop)) = "!" Then g_hdLicenseFlag = 1
                  Next
                  ------------------
                  Scott
                  mailto:[email protected][email protected]</A>
                  Scott Turchin
                  MCSE, MCP+I
                  http://www.tngbbs.com
                  ----------------------
                  True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

                  Comment


                  • #10
                    Scott --

                    This may be a silly question, but...

                    I assume that your program is reading the file names into the string array to begin with, whether they are from a DIR$ loop or a text file or whatever. Why not check for the file during that step, instead of placing the file names into the array and then searching for "!" in a separate step?

                    -- Eric


                    ------------------
                    Perfect Sync: Perfect Sync Development Tools
                    Email: mailto:[email protected][email protected]</A>
                    "Not my circus, not my monkeys."

                    Comment

                    Working...
                    X