logo hyperPad Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Login

    import text file

    Scheduled Pinned Locked Moved
    Help and Support
    4
    10
    544
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • LupoL
      Lupo
      last edited by

      How can I import a prepared text file (e.g. json format or simple comma separated values) into an array?

      RobinsonXR 1 Reply Last reply Reply Quote 1
      • TutorialDoctorT
        TutorialDoctor
        last edited by TutorialDoctor

        A dictionary seems like it would be a more suitable behavior to use instead of an array. What are you trying to accomplish? You can use the HTTP Request behavior if your JSON file is stored somewhere on the internet.

        1 Reply Last reply Reply Quote 1
        • MurtazaM
          Murtaza Admin
          last edited by

          Since apple makes the ios file system difficult to access (until recently with the addition of the files app) you can't exactly import a text file.

          However as suggested, you can have a file stored online somewhere and have you game import it with http requests.

          @RobinsonX has done this quite a bit and may have an example on it.

          1 Reply Last reply Reply Quote 2
          • RobinsonXR
            RobinsonX @Lupo
            last edited by RobinsonX

            @Lupo You can import any text into hyperPad into a behavior.

            The Value behavior is a perfect way to store values, which you can plug it into any other behavior you wish to manipulate this value with. (You can copy and paste values in there)

            If you want to use JSON, you can simply plug the JSON string into Modify Array / Modify Dictionary. In both of these behaviors, there's an option to set the array / dictionary so you can manipulate these data structures to its fullest. :)

            1 Reply Last reply Reply Quote 1
            • RobinsonXR
              RobinsonX
              last edited by

              If you have something other than JSON, say like a comma-seperated list, then you can use something like Text Operation to split a string and form an array.

              1 Reply Last reply Reply Quote 1
              • LupoL
                Lupo
                last edited by

                @RobinsonX I have a few MB comma separated text file I would like to import into array or dictionary. I can put it into Dropbox and with a direct download link I could donwload it with HttpRequest.
                Do you have an example of a GET HttpRequest and reading response and put into array/dictionary?

                RobinsonXR 1 Reply Last reply Reply Quote 1
                • RobinsonXR
                  RobinsonX
                  last edited by

                  @Lupo Currently, there's no way to import text as a file. The only ways are copying and pasting it (yes, it works for larger texts too that is in MB) or using something outside of hyperPad to store your text file and accessing that.

                  If you want to store your text file online, I recommend using something like Firebase by Google. You can store your text file there and then access it via URL without dealing with authentication or advanced API stuff.

                  1 Reply Last reply Reply Quote 0
                  • RobinsonXR
                    RobinsonX @Lupo
                    last edited by

                    @Lupo Here is an example using HTTP Request

                    0E338E6E-1D03-454C-94FA-E4EE34AC49B5.png

                    LupoL 1 Reply Last reply Reply Quote 0
                    • LupoL
                      Lupo @RobinsonX
                      last edited by

                      @RobinsonX Thanks for the sample. But how are the values separated and stored in the array? By magic 😉 or do I need to parse the txt file (comma separated strings)?

                      RobinsonXR 1 Reply Last reply Reply Quote 0
                      • RobinsonXR
                        RobinsonX @Lupo
                        last edited by

                        @Lupo Oh yeah I forgot but you would use Text Operation if you're importing a comma-seperated string.

                        If you use the split feature in that behavior, then it will output an array that can be plugged into Modify Array to set the array.

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post