Windows traits

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
keyless
Posts: 211
Joined: Wed Dec 12, 2007 11:21 pm

Windows traits

Post by keyless » Fri Feb 08, 2008 5:54 am

A couple of things have me worried as I work on my first program, aimed at Windows OS.

1. When I use Answer Folder and store results in afield the slashes are backwards from how they shold be in Windows

[C:/Documents and Settings/HP_Administrator/Desktop/Stuff] should be [C:\Documents and Settings\HP_Administrator\Desktop\Stuff]

Is there a property I'm missing or do I have to do something Like: Replace "/" with "\" in my code?

2. revCopyFile bybasses Windows warnings if a file with same name already exists in the folder. This could have unwanted results and data loss. Is there something that can be done about this or used instead or to prevent a copy over?

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Fri Feb 08, 2008 10:33 am

Hi keyless,

1) Why is this a problem for you?
2) Revolution can't know by itself whether you want to replace a file or not. You have to programme this yourself, e.g. "if there is a file <filename> then...."

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Post by malte » Fri Feb 08, 2008 11:48 am

Just to add to Marks post. Unless you need to work with shell commands, the backslash replacement will be just fine in rev. It replaces backslashes with slashes internally. This will make filepaths look the same across platforms and actually save you some headaches as soon as you go Cross platform. All the replacing will be handled internally. As soon as you need to shell out commands on Windows, you will need to do something like

replace "/" with "\" in mypath
-- do your shell stuff here

Hope that helps,

Malte

keyless
Posts: 211
Joined: Wed Dec 12, 2007 11:21 pm

Post by keyless » Fri Feb 08, 2008 6:38 pm

@ Mark

1) because I display the url in my program and allow the user to edit it manually. The wrong slash makes such editing confusing for the user and can lead to an error.

2) Perhaps you are not familiar with the Windows Copy shell command. It is designed so that files don't get copied over by other files with same name. What occures in Windows when you copy is if there is a file with same name dialog comes up :

This folder already contains a file named 'FILE NAME'. Would you like to replace the existing file (and then it shows info on both files like size and Modified date.

Also if there are multiple files you are copying, you can [Yes to all], so you don't have to go through dialog for all.

This dialog is crucial and protects files, I want this dialog. In windows you would need to use SET COPYCMD=/Y to bypass this dialog, maybe =/-Y will make it work for RevCopyFile.

UPDATE: I did find out that the dialog doesn't work for batch files. revCopyFile probably works as a batch file so overwrite dialog is bypassed. I guess I'll have to try and use Copy shell command. What would a shell command look like in Rev?

@ Malte

Thank you that is what I thought, I can probably use that to fix it in the field too. Thanks

keyless
Posts: 211
Joined: Wed Dec 12, 2007 11:21 pm

Post by keyless » Sat Feb 09, 2008 1:03 am

Ok I've learned a lot trying to troubleshoot this. Here is what revCopyFile passes to cmd prompt:

C:\WINDOWS\system32\cmd.exe /C copy "C:\Documents and Settings\Compaq_Owner\Desktop\001.jpg" "\Documents and Settings\Compaq_Owner\Desktop\HERE\001.jpg"

So it is in fact doing the same as I would do with a shell command. If I put the copy command into cmd.exe myself (in cmd window) it gives me the the replace (overwrite) dialog in the cmd box.

I suspect the /C Rev uses closes the box right away and prevents dialog from being a factor.

I had thought the dialog would be in a GUI like when you cut and paste copy. The dialog in cmd box is not what I wanted anyway.

So I am taking Marks advice and try and script an equivalent in Rev. So before my rev copy I will have to compare the files to be copied to the target directory. (Any Help Appreciated)

I'll have to admit a little more then I wanted to tackle on my first stab at Rev, but its been fun, and I actually do have a pretty good working program aside from this one thing I want to correct.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Sat Feb 09, 2008 1:36 am

Hi Keyless,

This might help:

http://thread.gmane.org/gmane.comp.ide. ... cus=104611

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

keyless
Posts: 211
Joined: Wed Dec 12, 2007 11:21 pm

Post by keyless » Sat Feb 09, 2008 5:48 am

Mark wrote:Hi Keyless,

This might help:

http://thread.gmane.org/gmane.comp.ide. ... cus=104611

Best,

Mark
I'm actually quite happy with the way revcopyfile works, I just don't want to overwrite existing files. Seems to me I'd have the same issue using a different copy method like the one described in your link, or the Put URL one.

In that thread though, Chip mentions the Windows API has CopyFile, I wish I could somehow access that, as if it is same as I have used in ACCESS, I know it could prevent overwrite.

as it is now I think I will try and stick with revcopyfile and try something like:

Code: Select all

set itemdelimiter to "/"
        if item -1 of FilePath is among the lines of targetFolder then 
though I will have to figure out how to nest this within the IFs and Elses I already have. Ugggg

I really am put off by not finding any decent info on moving and copying files other than insanly long threads on possible ways and theories.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Sat Feb 09, 2008 10:20 am

Keyless,

Earlier I wrote: "if there is a file <filename> then". You can also use "if not (there is a file <filename>) then". Obviously, instead of filename, you can also use the complete filepath.

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

keyless
Posts: 211
Joined: Wed Dec 12, 2007 11:21 pm

Post by keyless » Sat Feb 09, 2008 10:08 pm

Mark wrote:Keyless,

Earlier I wrote: "if there is a file <filename> then". You can also use "if not (there is a file <filename>) then". Obviously, instead of filename, you can also use the complete filepath.

Mark
Yeah I went back to that. This is what I ended up using:

Code: Select all

repeat for each line NPath in FilePathList
    set the itemDel to "/"
    if the last item of NPath is among the lines of Dupefld then
      answer error "already exists" with "Stop" or "Continue"
      end if
Dupefld of course being the listing of files in the Destination folder.

This works very well and I will add the file name to the answer dialiog also

I was even thinking if I use detailed file info, I could probably recreate the windows dialog exactly (with file size, yes to all, and everything)

I have to say I'm pretty proud of what I cam up with, and how easy it was to do with Rev, and it works great.

Thanks Mark and Malte for you suggestions, they helped point me in the right directions.

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”