Faking stack file extensions

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jmk_phd
Posts: 213
Joined: Sat Apr 15, 2017 8:29 pm

Faking stack file extensions

Post by jmk_phd » Sat Jun 10, 2017 10:01 pm

When asked to create a cross-platform version of a 30-year old Windows-only psychological testing app, I insisted upon using LC (which worked flawlessly when I rewrote by own 1990s-era Mac-only Prograph-based testing app as cross-platform).

The client insists upon maintaining the original folder/file organization: a folder that includes both the app/.exe and a template for saving the data, with a subfolder (dubbed “ClientData”) into which a copy of the template can be saved for storing an individual client’s test responses. For simplicity, I prefer to use a LC stack file as the template into which test responses are entered.

The revCopyFile works fine to create a copy of the template in the subfolder, but the rename command just doesn’t seem to work.

Klaus (and others) provided a very helpful lead in suggesting instead using

put url("binfile:" & tSourcePath) into url("binfile:" & tDestinationPath)

The thing is that this creates an empty file in the subfolder, rather than a copy of the data stack file.

Apparently, the problem is that my template and copy employed a fake extension (.hrm) in place of the original .livecode.

When the files and paths employ the original extension .livecode, everything seems to work fine: I can open and save the newly created data stack file from the path saved in a custom property in the main stack.

Bottom line: Although it’s not the worst disaster to employ the .livecode extension for the template file and its copies, it would be more elegant to identify these files with a fake custom extension.

Any advice regarding whether, how, or when to change the .livecode extension during these file path manipulations would be much appreciated.

Thanks much for any insights.

jeff k

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: Faking stack file extensions

Post by SparkOut » Sun Jun 11, 2017 7:55 am

If I can get a chance, I will look and test a bit, but I don't know what is different on your system. I use stack files with custom extensions all the time and they are able to be opened and saved without issue. You can also leave out a file extension and it should work, so it is strange to me that you are only having this problem when using other extensions than .livecode
One first guess is if the file extensions are hidden on the Windows explorer pane and you are getting some doubled up file extensions that look normal in the explorer. So for your original file copying the template might not find the source file if it has a dodgy extension, hence the empty destination.
In any event try answer the detailed files in the source folder before copying and also if there is a file tSourcePath then... do the copy

jmk_phd
Posts: 213
Joined: Sat Apr 15, 2017 8:29 pm

Re: Faking stack file extensions

Post by jmk_phd » Mon Jun 12, 2017 1:10 am

Thank you for confirming that stack files with custom extensions can be opened/saved without issue, which encouraged me not to scrap that strategy.

Your first guess turned out to be spot on:
One first guess is if the file extensions are hidden on the Windows explorer pane and you are getting some doubled up file extensions that look normal in the explorer.
Although I'm working on a Mac, extensions can be hidden in Mac Finder windows as in the Windows explorer pane. Once I unhid extensions, it became apparent that the template stack file employed .livecode as the extension, with my appended "extension" actually being treated as part of the filename (i.e., ClientTemplate.hrm.livecode). So of course the pathname constructed in the script went awry. I did employ answer to check each step in constructing the paths, but I overlooked the most important one. Things work fine now that this has been corrected.

Sorry to have bothered everyone over such a dumb mistake, but I really appreciate your help in alerting me to the solution.

jeff k

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”