
The path to liberation
Moderator: Klaus
Re: The path to liberation
Well, I have no mac to test on at the moment, but removing the path works on Lin and Win, doesn't it work on Mac too? I absolutely don't want poor lil Marlene to worry about moving it or to fiddle with paths, poor gal has enough to do already with that louse she married...



Re: The path to liberation
Not sure what the goal is but the preOpenStack code doesn't change anything for me. The path to the image was set to ./Test2.png already so LC knew where to find it. If you open a stack with that code and then choose an image, you still get the full path. If you manually chop it down to just the relative portion, then you can move the stack and image and it will still work. Now if you were opening and/or saving files in code, then having the default set could be useful. But for a built app, using the location like that is probably not the best idea since there is no guarantee that the app folder will be writable (and it is not on mobile).
I wouldn't expect a user to deal with path issues, that would be the type of thing the developer would address. Once the stack is packaged into an app, that type of information isn't something that can be changed by the user.
I just did some testing and as long as I checked the "Copy Referenced Files" box on the Copy Files tab of the Standalone Application Settings, then everything worked fine in the built app (files and/or folders were created and included along side the executable that was generated).
I just did these checks on plain images, so I would need to do additional checking for stacks and other types of assets.
I wouldn't expect a user to deal with path issues, that would be the type of thing the developer would address. Once the stack is packaged into an app, that type of information isn't something that can be changed by the user.
I just did some testing and as long as I checked the "Copy Referenced Files" box on the Copy Files tab of the Standalone Application Settings, then everything worked fine in the built app (files and/or folders were created and included along side the executable that was generated).
I just did these checks on plain images, so I would need to do additional checking for stacks and other types of assets.
-
- Livecode Opensource Backer
- Posts: 10080
- Joined: Fri Feb 19, 2010 10:17 am
Re: The path to liberation
Sorry for any confusion I added to this richmond, I missed the key word 'standalone' in the initial post, and thought you were talking about in the IDE 


Re: The path to liberation
Ok, now that I understand what you are really asking, I had another look...
The P2 example works on Windows, but doesn't work on Mac (don't have Linux handy to test). The reason that it doesn't work on Mac is due to the way the application is packaged for the OS.
You don't really need to set the defaultFolder (put an "answer the defaultFolder" in the preOpenStack). When the engine goes looking for images, it starts at the stack/executable location (if not an absolute path). In a Mac application package, that is 3 levels deeper (Application.app/Contents/MacOS/Application). I tested this theory in 2 ways. The first was to copy the image into the same location as the actual executable file. The second was to change the "set the path" button to use "../../../Test2.png" as the image target.
Part of the original issue is that when you choose files, the absolute path is stored. If you want to test out a way to have the PI use relative paths, you can edit com.livecode.pi.file.behavior (Tools/Toolset/palettes/inspector/editors/):
All of the changes are in the last if statement. I'm not sure if there are any other reasons not to do this, but if you make the edits inside of LiveCode, then they go away when you quit. (Of course, this is based on the new PI so I guess it would only apply to 8 or 9, I developed the code in 9DP10).
This does not address the issue of the relative path being different between Mac and Win/(Linux?) applications. On a Mac, all of the extra files can be included inside the package which makes moving it around easier for the user. On Win/Linux, the extra files are in folders next to the executable.
EDIT: See https://github.com/livecode/livecode-ide/pull/1817 for the latest version of the code above.
The P2 example works on Windows, but doesn't work on Mac (don't have Linux handy to test). The reason that it doesn't work on Mac is due to the way the application is packaged for the OS.
You don't really need to set the defaultFolder (put an "answer the defaultFolder" in the preOpenStack). When the engine goes looking for images, it starts at the stack/executable location (if not an absolute path). In a Mac application package, that is 3 levels deeper (Application.app/Contents/MacOS/Application). I tested this theory in 2 ways. The first was to copy the image into the same location as the actual executable file. The second was to change the "set the path" button to use "../../../Test2.png" as the image target.
Part of the original issue is that when you choose files, the absolute path is stored. If you want to test out a way to have the PI use relative paths, you can edit com.livecode.pi.file.behavior (Tools/Toolset/palettes/inspector/editors/):
Code: Select all
on mouseUp pButton
local tOptions
put the editorOptions of me into tOptions
if the name of the target contains "button" and pButton is 1 then
if tOptions is not empty then
replace return with comma in tOptions
end if
local tResult
revIDEAnswerFileWithTypes tOptions
put the result into tResult
if there is a file tResult then
local tStackPath, tFilePath
set the itemDelimiter to "/"
put item 1 to -2 of the filename of stack revtargetstack(line 1 of (the selObj)) into tStackPath
put revCalculateRelativePath(tStackPath, tResult) into tFilePath
if there is a file (tStackPath & slash & tFilePath) then put tFilePath into tResult
put tResult into field 1 of me
valueChanged
end if
end if
end mouseUp
This does not address the issue of the relative path being different between Mac and Win/(Linux?) applications. On a Mac, all of the extra files can be included inside the package which makes moving it around easier for the user. On Win/Linux, the extra files are in folders next to the executable.
EDIT: See https://github.com/livecode/livecode-ide/pull/1817 for the latest version of the code above.
Last edited by bwmilby on Sat Nov 04, 2017 9:32 pm, edited 1 time in total.
Re: The path to liberation
Found this bug:
http://quality.livecode.com/show_bug.cgi?id=17287
Addressing that would take care of the first part of your issue (the manual changing of image file paths to be relative). I've submitted a PR on that one.
The other issue (difference between where standalone apps look for images) is probably something that could be addressed in the standalone builder.
http://quality.livecode.com/show_bug.cgi?id=17287
Addressing that would take care of the first part of your issue (the manual changing of image file paths to be relative). I've submitted a PR on that one.
The other issue (difference between where standalone apps look for images) is probably something that could be addressed in the standalone builder.
Re: The path to liberation
I do get some sleep 
