Announcement

Collapse
No announcement yet.

List Box Object (loading at runtime)

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

  • List Box Object (loading at runtime)

    Sugestion:

    A function that Imports a TXT file at run time in a list box object.

    Thanks,

    Rene Baccarelli de Almeida
    Practica Global Media
    Sao Paulo - Brasil

  • #2
    Re: List Box Object

    From another post:


    What you could do in this case is read the text file using a TEXT FILE->READ action which would read the text file into a variable. Just make sure that it is formatted correctly with the proper delimiters.

    Then you could use a LISTBOX OBJECT->ADD action and place the variable in the "Items to add" field. This should accomplish what you are looking to do.
    Hope that helps.

    Sincerely,
    Darryl Hnatiuk
    Indigo Rose Corporation
    Thanks

    Comment


    • #3
      Re: List Box Object

      Ok, it work´s, but in my txt file I have one item per line and the delimiter is a carriage return ( enter ).

      Comment


      • #4
        Re: List Box Object

        Is that meaning it doesnt work properly?

        Format for txt file (if yurs doesnt work) is more likely to be:

        Item1;;Item2;;Item3 etc etc

        Comment


        • #5
          Re: List Box Object

          I can´t change the TXT file. This file is generated by another program.

          Thanks

          Comment


          • #6
            Re: List Box Object

            Load the file into a variable, then do a search and replace on the text in that variable to replace every carriage return/line feed combination with ;; (or whatever delimiter you intend to use).

            You'll need to set up a pair of design-time constants to represent the carriage return and line feed. Something like this:

            #ASC_CR# <-- assign "13" to this one
            #ASC_LF# <-- assign "10" to this one

            (I may have those ASCII values reversed -- I can never remember which one is which -- but you get the idea.)

            Then replace every "#ASC_CR##ASC_LF#" with ";;" in the string.

            That will convert every newline to a ;;.
            --[[ Indigo Rose Software Developer ]]

            Comment


            • #7
              Re: List Box Object

              Hi,

              If you wanted, you could parse the Text file line by line using our Text File actions.

              mark.
              MSI Factory The Next Generation Intelligent Setup Builder

              Comment


              • #8
                Re: List Box Object

                There may be a way to get all of the information to show properly in a ListBox Object.

                Try making a script that does something like:

                %Count% = "0"
                %LineCount% = TextFile.CountLines("c:\....")
                WHILE (%Count% < %LineCount%)
                . %TextLine% = TextFile.GetLine ("C:\.....",%Count%)
                . ListBoxObject[ListBox1].Add (End,"%TextLine%")
                . %Count% = Evaluate (%Count% + 1)
                END WHILE

                I have not actually tested this script but I think that it will work.


                Comment


                • #9
                  Re: List Box Object

                  Heh, my way only needs 2 actions, and it's faster:

                  %TextFile% = TextFile.Read("filename")
                  %NewString% = String.Replace("%TextFile%", "#ASC_CR##ASC_LF#", ";;")

                  Or just copy and paste this (make sure you change the name of the text file).



                  31
                  0
                  0
                  1

                  2

                  0


                  %TextFile%
                  C:\Music\A-Ha - Lifelines.m3u


                  60
                  0
                  0
                  1

                  2

                  0


                  %NewString%
                  %TextFile%
                  #ASC_CR##ASC_LF#
                  ;;
                  1




                  Make sure you add the two design-time constants on the Configurations tab of the Project Settings dialog, too:

                  Name: #ASC_CR#
                  Value: 13

                  Name: #ASC_LF#
                  Value: 10
                  --[[ Indigo Rose Software Developer ]]

                  Comment

                  Working...
                  X