Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 22nd, 2024, 10:17 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Variables in script file name
PostPosted: May 13th, 2011, 3:09 pm 
Offline

Joined: February 16th, 2005, 12:05 pm
Posts: 38
Location: Norfolk / UK
Here is a small script I have been struggling with:
-----------------------------
var fileDate = new Date()
var currDate = fileDate.getDate()
var currMonth = fileDate.getMonth()
var currYear = fileDate.getFullYear()
var filename= currDate + currMonth + currYear


if (FileExists( data + "\\review.mdb" ))

{
CopyFile( data + "\\review.mdb",data +"\\backup\\filename.mdb")
DeleteFile(data + "\\review.mdb")
}
---------------------------------
The syntax to pass the file name variable does not work . I can find no reference as to how the variable should be shown in a file address. I could do most of this without scripting but I needed to check for the existence a file before taking action.

Also passing date information into one variable ends up with it being added so i have got that wrong too! However, any advice on first part would be greatly appreciated.

Jeremy

_________________
Happiness is the knowledge of a suitable alternative.
Opus V 6.4 - XP Prof. - Mem 1024 Mb -
3 drives - 2 DVD burners and DVD drive -
Celeron CPU 2.8 MHZ


Top
 Profile Visit website  
 
 Post subject: Re: Variables in script file name
PostPosted: May 13th, 2011, 3:49 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Not sure I understand what's wrong.

The syntax for the FileExist command is fine and assuming the path in data is correctly formed, then it should work.

Code:
Debug.trace(data + "\\review.mdb")
will show the parameter as hard code.

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject: Re: Variables in script file name
PostPosted: May 13th, 2011, 6:01 pm 
Offline

Joined: February 16th, 2005, 12:05 pm
Posts: 38
Location: Norfolk / UK
Please don't bother with this one!After endless experimentation I have now made it work...

var fileDate = new Date()
var currDate = fileDate.getDate()
var currMonth = fileDate.getMonth()
var currYear = fileDate.getFullYear()
var filename= currDate +" "+ currMonth +" "+ currYear+" "+count

if (FileExists( data + "\\review.mdb" ))
{
CopyFile( data + "\\review.mdb",data +"\\backup\\"+filename+".mdb")

DeleteFile(data + "\\review.mdb")
}
It was obvious really and I will continue to move databases about in spite of severe warnings from DW support staff.

Jeremy

_________________
Happiness is the knowledge of a suitable alternative.
Opus V 6.4 - XP Prof. - Mem 1024 Mb -
3 drives - 2 DVD burners and DVD drive -
Celeron CPU 2.8 MHZ


Top
 Profile Visit website  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 27 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group