Save as

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

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Save as

Post by bidgeeman » Mon May 18, 2009 3:22 am

I found the "Save" script in Runrev, but is there a similar window with the option to"Save As" that will let you rename the file before saving to the destination folder?
on mouseUp

if the label of me is "Save" then
answer folder "Please select a location to save to."
if it is empty then exit mouseUp -- the user has cancelled out
put it into tDestinationFolder
revCopyFile "C:\test.mp3",tDestinationFolder
else
pass mouseUp
end if

end mouseUp
Cheers
Bidge

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10050
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Post by FourthWorld » Mon May 18, 2009 4:56 am

See the "ask file" command in the Dictionary.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Post by bidgeeman » Mon May 18, 2009 5:43 am

Hi FourthWorld that was a grat help. It is sometimes very hard to guess what the commands might be in Runrev. I do have a problem though trying to implement the ask file command in the previous script.
It's bringing up 2 windows...one with file path and another to name the file. I'm doing something wrong.

On mouseUp
if the label of me is "save" then
answer folder "Please select a location to save to."
if it is empty then exit mouseUp -- the user has cancelled out
put it into tDestinationFolder
ask file "Please name the file:"
revCopyFile "it",tDestinationFolder
else
pass mouseUp
end if
go to card "Main"
end mouseUp
Any pointers would be much appreciated.
Cheers
Bidge

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Post by bidgeeman » Mon May 18, 2009 9:34 am

Hello.
After hours I'm still stuck....I got the script to copy my source mp3 file ok.... but just can't figure out how to have the file appear at the other end renamed by a user with an input field???

Please help!!!
ON mouseUp pMouseBtnNo

if the label of me is "Button" then
answer folder "Please select a location to save to."
if it is empty then exit mouseUp

put "C:\merge.mp3" into SourceFile
put it into DestinationFile

revCopyFile SourceFile,destinationFile

END IF
END mouseUp
Thanks
Bidge

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Mon May 18, 2009 11:02 am

Bidge,

I made a script that you might find useful.
It has the original file hardwired into the script, for that you have to change the script
First put run this:

Code: Select all

on mouseUp pMouseBtnNo
    answer file "file to copy"
    put it
end mouseUp
now you copy what appears in the message box into the script below

Code: Select all

on mouseUp 
    answer folder "Please select a location to save to." 
    if it is empty then exit mouseUp
    
    -- append a slash since we want to use the path later on as folder path
    put it & "/" into DestinationFolder
     
    -- set your hardcoded file name and path
    -- replace with your hardcoded version of the sourcefile
    put "/Users/berndnig/Desktop/egg.png" into SourceFile
    
    -- extract the filename from the folder/file name
    -- since in Rev folders are separated by slashes we set the itemdelimiter to slash
    set the itemdelimiter to "/"
    put last item of SourceFile into tNameOfFile
    
    -- ask for an new name of the file to copy
    ask "please name the file" with tNameOfFile
    if it is empty then exit mouseUp
    
    -- make shure the file extension is ok, if user left it out or changed it
    -- append the file extension of the original file
    put it into tNewNameOfFile
    if char -4 to -1 of tNewNameOfFile is not char -4 to - 1 of tNameOfFile then
        put char -4 to -1 of tNameOfFile after tNewNameOfFile
    end if
    
    -- now copy the file to the new destination
    revCopyFile SourceFile,DestinationFolder
     
     -- now rename the copied file at his new destination to the new name
    rename file DestinationFolder & tNameOfFile to DestinationFolder & tNewNameOfFile
    
end mouseUp
see the comments in the script.
I saw in one of your scripts that you put it into quotes. That will not work since you turn it from a variable to a literal and Rev treats it as such.
Also note, in Revs path conventions there are no backslashes as far as I know. (I use a Mac, so dont know much about Rev and Windows)
But to make shure you get the hardcoded path to the original file use the first script to be shure.
regards
bernd

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Post by bidgeeman » Mon May 18, 2009 11:09 am

Wow....thanks Berd. I would love to use your script and will if i can solve this one mate... I have run into a HUGE problem!

I changed from using wav files to mp3 files as it is quite easy to stitch mp3 files together. But when I play them in my stack all I get is noise???
I'm researching the problem and it appears you have to use a playe object for in your stack. I have no idea how to do this. I downloaded the Revolution Player.exe but I have no idea how to implement this at all....
all this work for nothing :(

Please help!

Bidge

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Mon May 18, 2009 11:32 am

actually it is easy to use a player object to play sounds.
It is easiest if you have Quicktime installed on your computer. Recently there was the option to use Windows Media player, but I dont know anything about it.
If you have Quicktime then:
Drag a player object from the tool palette to your stack. In the property inspector there is little folder icon, click on it and choose your audio file.
Then click on the player to play the sound.
Look up player in the dictionary and related commands to control the player object from a script.
In Rev preferences you might have to turn on load Quicktime on start up.

regards
Bernd

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Post by bidgeeman » Mon May 18, 2009 11:39 am

OMG...you just made my day....IT WORKED!!!.....I was ready to give up. Not being a coder it's very difficult even doing such a simple project. Is there a way to hide the player and control it with customized buttons?

I am going to try out your script now Berd.
Thanks a heap once again ;)

David

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Post by bidgeeman » Mon May 18, 2009 11:58 am

WOW...Thank you Bernd. That script is a little ripper ;) :shock:
I would not have been able to do this without your help mate.

Cheers
Bidge

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Mon May 18, 2009 12:14 pm

David,
s there a way to hide the player and control it with customized buttons?
name you player "P1" for this.
make buttons lets say 4 and set the script to

a Start/Stop button

Code: Select all

on mouseUp pMouseBtnNo
    if the label of me is "Start Player" then
        start player "P1"
        set the label of me to "Stop Player"
    else
        stop player "P1"
        set the label of me to "Start Player"
    end if
end mouseUp
just a Start button

Code: Select all

on mouseUp pMouseBtnNo
    start player "p1"
end mouseUp
a Stop button

Code: Select all

on mouseUp pMouseBtnNo
    stop player "p1"
end mouseUp
a Rewind button

Code: Select all

on mouseUp pMouseBtnNo
    set the currenttime of player "p1" to 0
end mouseUp
you can hide the player and it will play nonetheless.

Lets make a fifth button:
choose an audio file

Code: Select all

on mouseUp pMouseBtnNo
    answer file "choose audio file to play"
    if it is empty then exit mouseUp
    put it into theFileAndPath
    set the filename of player "P1" to theFileAndPath
end mouseUp
you get the idea.
Bernd

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Post by bidgeeman » Mon May 18, 2009 2:06 pm

Hi Berd.

AArgh! Having a final glitch!!!
This code was working ok last night but now it won't rename the .bat file:
It's writing to the txt file ok but won't rewrite the .bat for some reason?
Oh...and it's not launching the bat file either???

open file "C:\data.txt"
write field "Test" to file "C:\data.txt"
close file "C:\data.txt"
rename file "C:\data.txt" to "C:\merge.bat"
set the hideConsoleWindows to true
launch "C:\merge.bat"

--go to card"Save as"
end mouseUp

Bidge

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Mon May 18, 2009 2:20 pm

sorry,
since I dont even know the path conventions on Windows I am of no help here, may be someone else is chiming in?

regards
Bernd

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Post by bidgeeman » Mon May 18, 2009 2:45 pm

Hi Bernd.
I think I know what the problem is.....the .bat file is still running while the rename command is tryinh to write to it....is there a command that will wait for it to finish before attempting to rename the file?

Bidge

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Mon May 18, 2009 3:17 pm

not that I know of as a native command. May be a shell comannd???
bernd

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Mon May 18, 2009 9:28 pm

David,
I suppose you are doing some sort of batch processing with the bat file. Is it possible that when the processing is done as a last action the bat file is instructed to generate a file e.g. processingDone.txt
If so you could check for the presence of that file to indicate that no batch processing is going on. And before you start a new round of .bat file processing you delete the file by script.
If that is possible you would know the status of batch processing.
To query for the existence of a file is easy:

if there is a file "my/long/path/processingDone.txt" then
do what you want
else
inform user to come back later

Bernd

Post Reply