Livecode 7.0 rc 2 path name issue

Visuals, audio, animation. Blended, not stirred. If LiveCode is part of your rich media production toolbox, this is the forum for you.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

thomthib
Posts: 17
Joined: Wed Mar 05, 2014 1:09 am

Livecode 7.0 rc 2 path name issue

Post by thomthib » Wed Oct 29, 2014 4:45 pm

I have a standalone application in a folder. Within that folder is a sub-folder containing .mp3 or .mov files. The standalone uses a template (template.rev) to create a new stack which is saved in the same folder on the same level as the standalone. The new stack has a button for importing the media files from the sub-folder mentioned previously. When I create a new stack with the standalone application, and then use the new stack to import an .mp3 file from the sub-folder, the player appears and it looks like it's connected to the external file correctly, but when I try to play it nothing happens. The same happens when I try to import a .mov file, but the external file doesn't appear linked to the player. There's just empty space where the video should be but the player controls are visible. Now, if I quit the standalone, restart it, and open the newly created stack, then the players work correctly (I don't even have to re-import the files). I didn't have this problems with LC 6. It seems that when I create a new stack with the standalone, the new stack thinks it is outside the folder or off the path. It doesn't know that it and the media files are where they should be until the standalone is restarted. Here's the code that I use to shorten the path name so that the links still work when moved to another computer ('it'' refers to the complete path name obtained when selecting a file):

put "../"&item -3 of the shortfilepath of it&"/"&item -2 of the shortfilepath of it&"/"&last item of it into fld "glossvideofld" of this cd

This code shortens the path name starting with the main folder where the standalone, new stack and sub-folders are located. This way the links will still work if the folder is moved to another computer.

So, why do I have to restart the standalone for it to recognize the pathname to the media files? Eternal gratitude for a solution.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7239
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Livecode 7.0 rc 2 path name issue

Post by jacque » Thu Oct 30, 2014 5:25 pm

A newly created stack has no filename, so a relative file reference means nothing. Either give the stack a filename, or easier, use the complete path in "it". Since the user is selecting the file, "it" will always contain a computer specific reference.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Livecode 7.0 rc 2 path name issue

Post by [-hh] » Fri Oct 31, 2014 7:00 am

Did you forget to "save this stack" immediately after putting your relative path into fld "glossvideofld"?
shiftLock happens

thomthib
Posts: 17
Joined: Wed Mar 05, 2014 1:09 am

Re: Livecode 7.0 rc 2 path name issue

Post by thomthib » Mon Nov 03, 2014 3:29 pm

When I create the new stack, I give it a name and save it in the main folder at the top level, same place where the standalone application is. I can see the new stack file in the folder before I import the media files. It's as if the stack that's open and the file that I see in the folder aren't the same. However, when I quit the application and open up the stack again with the application, the media files work fine. This didn't happen with LC 6.

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Livecode 7.0 rc 2 path name issue

Post by Klaus » Mon Nov 03, 2014 4:58 pm

Hi Thom,

hint: "shortfilepath" will only work correctly as exspected on Windows systems!


Best

Klaus

thomthib
Posts: 17
Joined: Wed Mar 05, 2014 1:09 am

Re: Livecode 7.0 rc 2 path name issue

Post by thomthib » Sat Nov 08, 2014 7:47 pm

When I create the new stack with the standalone, it is save with a name and I can see the newly created stack file in the folder before I import the media. Since my last post I tried this on Windows 7 and the files open with no problem. I'm working mostly with OSX 10.9.5. Since the problem exists in OS X and not in Windows 7, I think this might be a bug.

Klaus, I did change the script by replacing shortfilepath to longfilepath and still had the same problem.

I've made a YouTube clip that demonstrates the problem. If someone can confirm that this is a bug, I can report it as such. Here's the URL to the YouTube clip:

http://youtu.be/jau_UzzOev4

Thank you!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7239
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Livecode 7.0 rc 2 path name issue

Post by jacque » Sun Nov 09, 2014 6:25 pm

Can we see the section of the script that sets the initial filename after the selection is made?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

thomthib
Posts: 17
Joined: Wed Mar 05, 2014 1:09 am

Re: Livecode 7.0 rc 2 path name issue

Post by thomthib » Wed Nov 12, 2014 4:07 am

Jacque, here's the code:
----------------------------------------------------
answer file "Select a file." --opens file browser to select file.

set the itemDel to slash

put "../"&item -3 of the longfilepath of it&"/"&item -2 of the longfilepath of it&"/"&last item of it into fld "textaudiofilename" of this cd - -SHORTENS THE PATH STARTING WITH THE MAIN FOLDER

put fld "textaudiofilename" into filenm

create player "jokeaudio"

set the filename of player "jokeaudio" to filenm

set showcontroller of player "jokeaudio" to true

show player "jokeaudio"

-----------------
The curious thing is that it works fine in Windows, just not OS X. Thanks!

Thom

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Livecode 7.0 rc 2 path name issue

Post by Klaus » Wed Nov 12, 2014 12:46 pm

Hi Thom,
thomthib wrote:Klaus, I did change the script by replacing shortfilepath to longfilepath and still had the same problem.
from the dictionary:
...
On Mac OS, OS X, or Unix systems, the longFilePath function simply returns the filePath without changing it.
...
just like "shortfilepath" would do 8)


Best

Klaus

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7239
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Livecode 7.0 rc 2 path name issue

Post by jacque » Wed Nov 12, 2014 5:30 pm

If the user is selecting a file, the path returned by the answer file dialog is the correct location. You can use it unaltered. The only time you might need to create a relative file path is if you are creating the path in a script without any user input.

Code: Select all

answer file "Select a file" 
put it into fld "textaudiofilename" of this cd
This will work on any OS.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

thomthib
Posts: 17
Joined: Wed Mar 05, 2014 1:09 am

Re: Livecode 7.0 rc 2 path name issue

Post by thomthib » Fri Nov 14, 2014 4:26 pm

I know selecting the file will generate the path automatically, but what happens when the unit (main folder, subfolders, external files) are moved to another computer. Now the initial step identifying the hard drive will be wrong. That's why I have to shorten the path to start with the Main folder.

Also, I still don't see why the code works as it should in Windows but not in OS X. Also, it worked with LiveCode 6x in OS X.

Is there another way of ensuring that if the unit is moved to a different computer, the links will still work?

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7239
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Livecode 7.0 rc 2 path name issue

Post by jacque » Fri Nov 14, 2014 8:10 pm

I'm confused. Are you asking how to set up the file dialog to open at the same folder where the app is? For that, get the defaultFolder (which will be where the app is if you haven't changed it specifically) and use that as the defaultPath parameter in the answer file dialog.

Code: Select all

answer file "Choose a file:" with the defaultFolder
If you want to point to a subdirectory:

Code: Select all

put the defaultFolder into tPath
put "/Subfolder" after tPath
answer file "Choose a file:" with tPath
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Livecode 7.0 rc 2 path name issue

Post by Simon » Fri Nov 14, 2014 10:13 pm

I'm not totally sure but wasn't this a bug that has been addressed in LC 7.0.1 rc 2?
http://downloads.livecode.com/livecode/ ... 1_rc_2.pdf

FIX "answer file" opening wrong folder (7.0.0 rc 3)

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7239
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Livecode 7.0 rc 2 path name issue

Post by jacque » Fri Nov 14, 2014 11:24 pm

Simon wrote:I'm not totally sure but wasn't this a bug that has been addressed in LC 7.0.1 rc 2?
http://downloads.livecode.com/livecode/ ... 1_rc_2.pdf

FIX "answer file" opening wrong folder (7.0.0 rc 3)
That one seems a little different, more about what happens if a specific path isn't passed in the parameter.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

thomthib
Posts: 17
Joined: Wed Mar 05, 2014 1:09 am

Re: Livecode 7.0 rc 2 path name issue

Post by thomthib » Wed Nov 26, 2014 4:07 pm

I think if I present the problem in the following way, it will be easier to suggest a solution:

I created a text processor that enables foreign language teachers to make hypermedia instructional materials for their students. The text processor, FLAn (fForeign Language Annotator) is downloaded from a web site and is contained within a folder called, FLAn_Mac or FLAn_PC.

1. The Main Folder, i.e., FLAn_Mac, has to be renamed with the title of the instructional unit.

2. The Main Folder contains the standalone app and a sub-folder.

3. The sub-folder contains an audio file.

4. The standalone app is used to create a new stack that is saved in the Main Folder on the same level as the standalone. The instructor modifies the stack with content for the students.

5. Part of that modification is to click a button that creates a player and links the audio file in the sub-stack to the player.

6. When this is done, a path name starting with the name of the hard drive and ending with the name of the file is generated.

7. Here's the clincher. The modified Main Folder with all its contents must be portable so that it can be copied onto other computers (both Mac & PC, I have FLAn for both platforms). This is where the problem lies. The link from player to audio file will be broken if the pathname changes when the folder is moved to another computer. In the script below, I reference the path name starting with the Main Folder. Since I don't know in advance what the folder name or audio file name will be, I have to use 2 variables in the pathname.

The problem is that when I create and save the new stack and make the link to an audio file from a new player, the player doesn't see the file. However, if I quit the stack and reopen it, then it sees it.

I would greatly appreciate it if anyone sees a problem in this script or could suggest a better script to accomplish what I've described above. Thank you so much!

P.S. I've been working on this program for several years and never had a problem with path names to external files until I switched to LiveCode 7. I'm now using Livecode 7 rc2 on a new iMac. I want to deploy on both Mac and PC.

-------------------------------------------------------------------------

on mouseUp

--------PICK AN AUDIO FILE, ISOLATE NAME OF DEFAULT FOLDER & NAME OF FILE--------------------

answer file "Pick a file, any file." --OPEN FILE BROWSER TO SELECT FILE

put it into fld "textaudiofilename" --FULL PATH NAME APPEARS IN HIDDEN FIELD

set the itemDelimiter to "/" --ALLOWS ME TO ISOLATE FOLDER NAME & AUDIO FILE NAME AS 'ITEMS' IN THE FULL PATH NAME

put last item of fld "textaudiofilename" into fld "textaudiofilename" --REPLACES FULL PATH NAME WITH AUDIO FILE NAME ONLY

put last item of defaultfolder into folderName --ISOLATES NAME OF MAIN FOLDER WHERE STANDALONE APP IS LOCATED

put fld "textaudiofilename" into theFileToPlay -- ASSIGN AUDIO FILE NAME IN FIELD TO A VARIABLE


------------CREATE THE PLAYER AND LINK IT TO THE AUDIO FILE------------------

create player "jokeaudio" -- CREATES THE PLAYER TO BE LINKED TO THE EXTERNAL AUDIO FILE

set the filename of player "jokeaudio" to "../"&foldername&"/FLAn_Audio/"&thefiletoPlay --THIS IS THE LINE IN QUESTION, IT PICKS UP THE PATHNAME STARTING WITH THE NAME OF THE MAIN FOLDER. MY UNDERSTANDING IS THAT THIS MAKES THE FOLDER PORTABLE SINCE THE NAME OF THE HARD DRIVE OR OTHER POSSIBLE FOLDER IS NOT INCLUDED IN THE PATH NAME.

end mouseUp

Post Reply

Return to “Multimedia”