HISE Logo Forum
    • Categories
    • Register
    • Login

    File.toString(int formatType)

    Scheduled Pinned Locked Moved Documentation
    16 Posts 5 Posters 854 Views
    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.
    • ulrikU
      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 15.3.1, Xcode 16.2
      http://musikboden.se

      1 Reply Last reply Reply Quote 0
      • d.healeyD
        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

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

          @d-healey

          File.Filename
          

          still shows the whole path

          Hise Develop branch
          MacOs 15.3.1, Xcode 16.2
          http://musikboden.se

          ulrikU 1 Reply Last reply Reply Quote 0
          • ulrikU
            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 15.3.1, Xcode 16.2
            http://musikboden.se

            d.healeyD 1 Reply Last reply Reply Quote 0
            • d.healeyD
              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

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

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

                Hise Develop branch
                MacOs 15.3.1, Xcode 16.2
                http://musikboden.se

                1 Reply Last reply Reply Quote 0
                • d.healeyD
                  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 KorneffD 1 Reply Last reply Reply Quote 0
                  • Dan KorneffD
                    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.healeyD 1 Reply Last reply Reply Quote 0
                    • d.healeyD
                      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 KorneffD ustkU 2 Replies Last reply Reply Quote 0
                      • Dan KorneffD
                        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.healeyD 1 Reply Last reply Reply Quote 0
                        • d.healeyD
                          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 KorneffD 1 Reply Last reply Reply Quote 1
                          • Dan KorneffD
                            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.healeyD 1 Reply Last reply Reply Quote 0
                            • d.healeyD
                              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

                              LindonL 1 Reply Last reply Reply Quote 0
                              • LindonL
                                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
                                • ustkU
                                  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 :) )

                                  Can't help pressing F5 in the forum...

                                  d.healeyD 1 Reply Last reply Reply Quote 0
                                  • d.healeyD
                                    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

                                    13

                                    Online

                                    1.7k

                                    Users

                                    11.8k

                                    Topics

                                    103.1k

                                    Posts