Forum

    • Register
    • Login
    • Search
    • Categories

    File.toString(int formatType)

    Documentation
    5
    16
    248
    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.
    • ulrik
      ulrik last edited by

      According to the documentation, setting "File.toString(Filename)" I should get only the filename with extension, but I get the whole path to the file.
      How do I get only the filename?
      https://docs.hise.audio/scripting/scripting-api/file/index.html#loadasobject

      Hise Develop branch
      MacOs 13, Xcode 14.0.1
      http://musikboden.se

      1 Reply Last reply Reply Quote 0
      • d.healey
        d.healey last edited by

        Those strings are constants, so you need to use File.Filename

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        ulrik 1 Reply Last reply Reply Quote 0
        • ulrik
          ulrik @d.healey last edited by

          @d-healey

          File.Filename
          

          still shows the whole path

          Hise Develop branch
          MacOs 13, Xcode 14.0.1
          http://musikboden.se

          ulrik 1 Reply Last reply Reply Quote 0
          • ulrik
            ulrik @ulrik last edited by ulrik

            @ulrik

            File.NoExtension
            &&
            File.FullPath
            

            is working, but

            File.Filename || File.OnlyExtension
            

            is not working, they both gives the full path

            Hise Develop branch
            MacOs 13, Xcode 14.0.1
            http://musikboden.se

            d.healey 1 Reply Last reply Reply Quote 0
            • d.healey
              d.healey @ulrik last edited by

              @ulrik I seem to remember a while back we discovered a bug with the constants not returning the correct values - @Christoph-Hart

              Each constant just returns a number 0, 1, 2, etc. so for Filename I guess you would use 3.

              Libre Wave - Freedom respecting instruments and effects
              My Patreon - HISE tutorials
              YouTube Channel - Public HISE tutorials

              ulrik 1 Reply Last reply Reply Quote 1
              • ulrik
                ulrik @d.healey last edited by

                @d-healey ahh, yes youโ€™re right, I remember now, thank you David!

                Hise Develop branch
                MacOs 13, Xcode 14.0.1
                http://musikboden.se

                1 Reply Last reply Reply Quote 0
                • d.healey
                  d.healey last edited by

                  Just want to give this a bump because these constants still don't work.

                  In fact none of them work now but I thought some of them did previously...

                  Libre Wave - Freedom respecting instruments and effects
                  My Patreon - HISE tutorials
                  YouTube Channel - Public HISE tutorials

                  Dan Korneff 1 Reply Last reply Reply Quote 0
                  • Dan Korneff
                    Dan Korneff @d.healey last edited by

                    @d-healey Playing with them right now with files downloaded from a server. Here's what I'm seeing
                    .toString(0) = full file path
                    .toString(1) = filename (no extension)

                    Is that different than what you're looking for?

                    Dan Korneff - Producer / Mixer / Audio Nerd

                    d.healey 1 Reply Last reply Reply Quote 0
                    • d.healey
                      d.healey @Dan Korneff last edited by d.healey

                      @dustbro said in File.toString(int formatType):

                      Is that different than what you're looking for?

                      Try to print .toString(File.NoExtension); and you will get an undefined error.

                      Libre Wave - Freedom respecting instruments and effects
                      My Patreon - HISE tutorials
                      YouTube Channel - Public HISE tutorials

                      Dan Korneff ustk 2 Replies Last reply Reply Quote 0
                      • Dan Korneff
                        Dan Korneff @d.healey last edited by

                        @d-healey said in File.toString(int formatType):

                        .toString(File.NoExtension)

                        I don't think you can use anything except an integer for this function.

                        to string.png

                        The integer is passed to the .toString function switch case.

                        switch.png

                        Dan Korneff - Producer / Mixer / Audio Nerd

                        d.healey 1 Reply Last reply Reply Quote 0
                        • d.healey
                          d.healey @Dan Korneff last edited by

                          @dustbro Exactly but those constants should provide that integer so we don't have to use magic numbers

                          Libre Wave - Freedom respecting instruments and effects
                          My Patreon - HISE tutorials
                          YouTube Channel - Public HISE tutorials

                          Dan Korneff 1 Reply Last reply Reply Quote 1
                          • Dan Korneff
                            Dan Korneff @d.healey last edited by

                            @d-healey Do any of the constants work? or are they all broken?

                            Dan Korneff - Producer / Mixer / Audio Nerd

                            d.healey 1 Reply Last reply Reply Quote 0
                            • d.healey
                              d.healey @Dan Korneff last edited by

                              @dustbro said in File.toString(int formatType):

                              @d-healey Do any of the constants work? or are they all broken?

                              These File ones seem to all be broken, but I don't think that's always been the case.

                              Libre Wave - Freedom respecting instruments and effects
                              My Patreon - HISE tutorials
                              YouTube Channel - Public HISE tutorials

                              Lindon 1 Reply Last reply Reply Quote 0
                              • Lindon
                                Lindon @d.healey last edited by

                                @d-healey said in File.toString(int formatType):

                                @dustbro said in File.toString(int formatType):

                                @d-healey Do any of the constants work? or are they all broken?

                                These File ones seem to all be broken, but I don't think that's always been the case.

                                ..its always been the case for me.

                                HISE Development for hire.
                                www.channelrobot.com

                                1 Reply Last reply Reply Quote 0
                                • ustk
                                  ustk @d.healey last edited by ustk

                                  @d-healey @dustbro @Lindon Since the enum is part of the class ScriptFile, it is the reference of the file itself that you have to take for using the enum names, not the File API:

                                  const var myFile =  FileSystem.getFolder(FileSystem.Desktop).getChildFile("myFile.txt");
                                  
                                  Console.print(myFile.toString(myFile.NoExtension));
                                  

                                  It is the same when you use, let's say a simple gain, it's the reference of the effect "myGain" you use to access the different parameters.
                                  For instance myGain.Balance, not Synth.Balance

                                  I know the location in FileSystem for instance are accessed through FileSystem.SpecialLocation,
                                  but in this case, you use the API, not a reference of it that you have created (well, at least if I explain correctly ๐Ÿ™‚ )

                                  I can't help pressing F5 in the forum...

                                  d.healey 1 Reply Last reply Reply Quote 0
                                  • d.healey
                                    d.healey @ustk last edited by

                                    @ustk Oh that's right! Mystery solved, thanks ๐Ÿ™‚

                                    Libre Wave - Freedom respecting instruments and effects
                                    My Patreon - HISE tutorials
                                    YouTube Channel - Public HISE tutorials

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

                                    15
                                    Online

                                    1.1k
                                    Users

                                    7.0k
                                    Topics

                                    64.6k
                                    Posts