CDR Group
----- Original Message -----From: Russ VarleySent: Wednesday, May 15, 2013 5:09 PMSubject: [MI-L] Commit table with incrementing value or dateHello everyoneI have an mbx file that is run monthly that saves copies of my team's data into the various places on our corporate network so that other teams can have access to it. As an extra feature it would useful to have the same mbx file create an archive copy of the .tab files and add either an incrementing number or preferably the date that the .tab was saved to the filename.For example, the source file is filename.tab and is then committed to the archive as either 20130515filename.tab or filename1.tab.I've looked at the commit function docs and I don't see anything about adding a dateI've tried experimenting with setting the file name as a variable and using the curdate function to assign the current date to a second variable. I then create a third variable made up of the first two (sample code below)dim archivename As string
dim currdate As string
dim finalfilename As string
Open Table "F:\Tables\row_work"
Commit Table row_work As "C:\MBTest\currentrow_work.TAB" CoordSys Earth Projection 8, 79, 7, -2, 49, 0.9996012717, 400000, -100000
Close Table row_work
Open Table "C:\MBTest\currentrow_work.TAB"
archivename = "currentrow_work.tab"
currdate = Curdate()
finalfilename = currdate + archivename
Commit table finalfilenameThe mbx compiles fine but I get an error message on run. The error is "Expression does not evaluate to a column or table name." This error is pointing at the final commit line.Any help would be greatly appreciated and please accept my apologies if the answer is blindingly obvious.Russ--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en
---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Hi Russ,
The table is not saving because MapInfo can’t find a table with the name stored in your finalfilename variable.
Try something like this:
'====================================================
Dim dir as String
Open Table "C:\MBTest\currentrow_work.TAB"
archivename = TableInfo(0, TAB_INFO_NAME)
dir = PathToDirectory$(TableInfo(0, TAB_INFO_TABFILE))
currdate = Curdate()
finalfilename = dir & currdate & archivename & ".TAB"
Commit table archivename as finalfilename '// save currentname as newname
'====================================================
HTH,
Tom Bacon
GIS Engineer, Mouchel
T 01444 472380 │ E thomas...@mouchel.com │ W www.mouchel.com
Our values: innovation │ excellence │ integrity │ responsibility
Mouchel Limited (Mouchel) is registered in England and Wales with registered number 01686040 at Export House, Cawsey Way, Woking, Surrey, UK, GU21 6QX. The information in this e-mail is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. Any views or opinions expressed in this e-mail may be solely those of the author and are not necessarily those of Mouchel. No contracts may be concluded on behalf of Mouchel by means of email communications. Mouchel reserves the right to monitor and intercept emails sent and received on our network. |