5 Replies Latest reply on Apr 10, 2008 2:01 PM by Newsgroup_User

    Save forlder to desktop (cross platform)

    rafa@mediatech Level 1
      Hello everyone:
      I have a cross platform headache. My customer wants to be able to save some documents to the desktop when the user click the "save docs" button.

      I know how to make it work on PC...makes a folder with the name I want and saves documents in that folder. How can I make the same code work crossplatform? This is the code I use to save a folder with documents on a PC desktop.

      on mouseup me
      desk = baSysFolder( "desktop" )
      ok = baCreateFolder( desk&"FOLDER NAME" )
      oK = baCopyFile( the moviepath&"documents\something.pdf" , desk&"FOLDER NAME\something.pdf" , "IfNewer" )
      end if
      end


      Any ideas?

      Rafael
        • 1. Re: Save forlder to desktop (cross platform)
          Level 7
          The problem is that you are using '\' characters as the path delimiters.
          On Mac, they would be colons ':'.

          You can find the path delimiter like this:

          gDelim=the last char of the moviePath

          Then, everywhere that you have a backslash, replace it with

          "&gDelim&"

          (including the quotes). That should do it.
          • 2. Re: Save forlder to desktop (cross platform)
            rafa@mediatech Level 1
            Hey Mike...you are everywhere!

            Ok...sorry, I do have a movie script as follows:
            on startmovie me
            global gPlatform, gDelimiter
            if the platform contains "Windows" then
            gPlatform="win"
            gDelimiter="\"
            else if the platform contains "Macintosh" then
            gPlatform="mac"
            gDelimiter=":"
            else
            gPlatform="none"
            Gdelimiter="none"
            end if
            end
            I thought that would take care of the delimiter issue, it works fine with my "open document" code, but not with the "create folder with docs inside" code

            I got director to create a folder on the desktop of the MAC, but the folder is empty... what do you think is the problem?
            • 3. Re: Save forlder to desktop (cross platform)
              Level 7
              The baCopyFile command will return an error code if it is not working.
              That error message will tell you what is wrong.

              instead of this:

              oK = baCopyFile( the moviepath&"documents\something.pdf" , desk&"FOLDER
              NAME\something.pdf" , "IfNewer" )

              try this:

              put baCopyFile( the moviepath&"documents"&gDelimiter&"something.pdf" ,
              desk&"FOLDER NAME"&gDelimiter&"something.pdf" , "IfNewer" )

              I switched the backslashes to "&gDelimiter&" and added the word put to
              the front. Now, when it run,s it will put an error code in the message
              window. Look up that code in the BuddyAPI docs and it will tell you
              what the problem is.
              • 4. Re: Save forlder to desktop (cross platform)
                rafa@mediatech Level 1
                hey Mike:
                I tried this, and it works...I believe the issue was the name of the file I was trying to copy. My customer gave me a file that was 38 chars. long. I made it 10 chars, and now it copies fine. Here is the code I used:
                (Thanks for all you help)
                • 5. Re: Save forlder to desktop (cross platform)
                  Level 7
                  Yeah- Macs have problems with long filenames (or rather pathnames). The
                  path to the desktop is very long and added to that the filename... I'm
                  not sure what the limit is, but I have stopped using the desktop as a
                  storage folder for Macs because of that.