PDA

View Full Version : Reading CCF version/save date in NR



Barf
May 16th, 2010, 06:28 AM
I would like to access a "version" of the CCF version (either the date saved, a "build number" or something in the same vein) within NR. For example, a variable like NR.FILE.Version would fit. A reasonable solution would be to access the modification date of the ccf file, but I do not find anything to do this in e.g. the Lua IO library.

Any suggestion?

Rob H
May 16th, 2010, 01:20 PM
There's no version resource in a CCF file, so it would have to be the file timestamp. However, there is presently no way to do this as far as I can see - let me think about this.

kwaugh
May 17th, 2010, 02:15 PM
Here's the code I use for something similar, hope it helps!

--get information on this ccf
--for display on the sys admin screen
local curCCF = NetRemote.GetVariable("NR.FILE.Name")
local curPTH = NetRemote.GetVariable("NR.FILE.Path")
local curCCFs = string.gsub(curCCF,curPTH.."\\","")

fso = luacom.CreateObject ("Scripting.FileSystemObject")
f = fso:GetFile(curCCF)
NetRemote.SetVariable("NR.FILE.ShortName",curCCFs)
NetRemote.SetVariable("NR.FILE.CreateDate",f.DateCreated)
NetRemote.SetVariable("NR.FILE.ModDate",f.DateLastModified)
print(curCCF)
print(f.DateCreated)
print(f.DateLastModified)
fso = nil
collectgarbage ()

dsmes
May 17th, 2010, 10:07 PM
Here's the code I use to see if the NR version is newer than ver 1.1044 Note that the decimal is suppressed.

local version = NetRemote.GetVariable("NRVERSION")
version = string.gsub(version, "%.", "")
NetRemote.MessageBox ("NR Version is: "..version)
NewerVersion = false
if tonumber(version) > 11044 then NewerVersion = true end

Barf
May 19th, 2010, 01:20 PM
@Rob H: thanx for confirming that I did not just fail to RTFM. Such an NR Variable would be quite nice (although of course not really essential), don't you think...

@dsmes: thanx but I was looking for the version of the ccf file, not NR.

@kwaugh: This is sort of what I was looking for, thank you. (your example lacks the require('luacom') though). However, as far as I can tell, luacom in not present on the windows mobile version of NR, which is my main emphasis. (I want to quickly check whether I have remembered to update the win-mobile device.)

kwaugh
May 19th, 2010, 05:32 PM
Your right, the luacom require statement is in the 'setup' part of the code, and this is definitely XP vs. CE

Good luck!

Rob H
May 20th, 2010, 07:29 AM
Not sure about a variable, but some way of accessing such file info would be useful I agree.

Barf
October 20th, 2010, 05:35 AM
This is the solution that I am presently using:

I am maintaining my ccf- and lua-files with the subversion version management. Using keyword expansions a text file (like a lua file) can contain the (subversion) revision number, date or such. For example, writing

NetRemote.SetVariable("NRlua.svnrevision", "$Revision$")
in the lua file and then checking in converts it to

NetRemote.SetVariable("NRlua.svnrevision", "$Revision: 531 $")
(assuming that 531 is the revision number).

For this to work, the svn keywords property has to be set to "revision".

Trying the same with a binary file like ccf will almost surely lead to file corruption; I have not even bothered trying...
The drawback is that changes that does not involve a new version of the lua file are not visible.

Having your development artifacts under revision control is a very good idea anyhow, regardless of the issue of this thread.

References: http://svnbook.red-bean.com/ http://tortoisesvn.tigris.org/