Map Basic Rename tab file with date/time

384 views
Skip to first unread message

BenM

unread,
Oct 23, 2007, 3:52:35 AM10/23/07
to MapInfo-L
I am looking for some help with constructing a Mapbasic tool which has
the ability to automate a few naming conventions

One of my naming conventions for MI files is linked to dates and
ocassionaly even specific times

Essentially I name the Files by:

SpatialDescriptor_Job/contentDescriptor_datecreated_timecreated.TAB
eg

After altering a base file and depending on if I am satisfied with my
attribute changes I want to be able to either:

(a) Overwrite (eg Rename) the original file to display the current
date / time.

or

(b) Save a copy of the original file to the original directory so that
there will be two files present, with the latest copy displaying the
current date/time, therefore showing it to be more up to date.

Idealy I would like the date / file name to be automatically updated
from the windows own time.

Further more I would like the ability to select the file that I would
like to save, when changes are made

Any ideas?

Trey Pattillo

unread,
Oct 23, 2007, 6:43:21 PM10/23/07
to mapi...@googlegroups.com
I would some of the below methods:

1) build a *new* SAVE button
2) using the help I have on my website [www.wap3.com] in the API section
you can get the real date and time
3) activate the tool button when a change is made to the map
4) in the handler do a SAVE AS using the new date / time
5) do a revert table to the original
6) close original and open the new table
7) may consider a time frame from the last date/time that the code
aborts and does not create a new file

Simpson Jan

unread,
Oct 23, 2007, 7:47:39 PM10/23/07
to mapi...@googlegroups.com

Here is an example of a similar option that creates an XLS document using some 'unique' date/time stamping

Note: this is V8.5, before the inclusion of the time field…

 

Hope this helps…

 

Create a custom button to perform your save, or in this case export…

 

This code takes a selection and creates an EXCEL document with the name of QVAS_Export_All_ValuerName_Date_Time.csv

 

Where:      ValuerName is the name of the user (fetched from an INI)

            ExportPath is also defined in the same INI file

            ExcelString is path of the EXCEL executable

(this may vary in versions of excel and operating systems)

            Date is the current date – the date right now extracted from the MapBasic command CurDate()

            Time is HH and SS extracted from the time stamp – extracted from the MapBasic command Time(24)

 

 

‘-----

Dim ValuerName as string

Dim ExportPath as string

Dim ExcelString as string

Dim Now as string

 

Now = mid$(time(24),1,2) + mid$(time(24), 4,2)

 

Export "QVAS_Export" Into ExportPath +"QVAS_Export_All"+"_"+ValuerName+"_"+Curdate() + "_"+ Now +".csv" Type "ASCII" Delimiter "," CharSet "WindowsLatin1" Titles

 

run menu command M_QUERY_UNSELECT 

           

ExcelString = "C:\Program Files\Microsoft Office\OFFICE11\excel.exe " + ExportPath +"QVAS_Export_All" + "_"+ ValuerName + "_" + Curdate() + "_" + now +".csv"

 

run program ExcelString

 

‘-----

 

 

 

Mr Jan S Simpson

 

Systems Officer | State Valuation Services

Telephone: 07 5451-2402 Facsimile: 07 5451-2260

Email: jan.s...@nrw.qld.gov.au

 www.nrw.qld.gov.au

 

Department of Natural Resources and Water

52-64 Currie Street Nambour Qld 4560

************************************************************************
The information in this email together with any attachments is
intended only for the person or entity to which it is addressed
and may contain confidential and/or privileged material.
Any form of review, disclosure, modification, distribution
and/or publication of this email message is prohibited, unless
as a necessary part of Departmental business.
If you have received this message in error, you are asked to
inform the sender as quickly as possible and delete this message
and any copies of this message from your computer and/or your
computer system network.
************************************************************************

Reply all
Reply to author
Forward
0 new messages