Re: [MI-L] Commit table with incrementing value or date

74 views
Skip to first unread message

CDR Group

unread,
May 15, 2013, 1:25:41 PM5/15/13
to mapi...@googlegroups.com
Try finalfilename = archivename + currdate so that your table name doesn't being with a numeric character.
 
Tony

CDR Group


www.cdrgroup.co.uk
www.browse-a-map.co.uk
Tel: 01433 621282
Fax: 01433 621292
Specialists in Geographic Information Systems

CDR Group is the trading name of Contract Data Research Ltd.
Registered address Eccles House, Eccles Lane, Hope, Hope Valley, S33 6RW.
Registration No. 1972326
VAT No. GB373 3117 67
----- Original Message -----
Sent: Wednesday, May 15, 2013 5:09 PM
Subject: [MI-L] Commit table with incrementing value or date

Hello everyone
 
I 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 date
 
I'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 finalfilename
 
The 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.
 
 

Russ Varley

unread,
May 15, 2013, 6:00:58 PM5/15/13
to mapi...@googlegroups.com, CDR Group
Hi Tony
 
Many thanks for the reply.  I tried what you suggested but sadly I get the same error.  It's late now so I will have another look in the morning and post any updates then.
 
Russ

MarkT

unread,
May 15, 2013, 6:33:54 PM5/15/13
to mapi...@googlegroups.com, CDR Group
Hi Russ,

The problem is that your finalfilename isn't a table - its only variable name.
Try using 

   commit table originalFileName as finalFileName

Mark T.

Russ Varley

unread,
May 16, 2013, 4:12:21 AM5/16/13
to mapi...@googlegroups.com, CDR Group
Hi Mark
 
Brilliant, worked like a charm.  Many many thanks
 
Russ

Thomas Bacon

unread,
May 17, 2013, 3:51:33 AM5/17/13
to mapi...@googlegroups.com

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 logo

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. 

Reply all
Reply to author
Forward
0 new messages