Getting a file's creation date

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
cosnet1BUSk1Aq
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10
Joined: Wed Apr 18, 2012 9:58 pm

Getting a file's creation date

Post by cosnet1BUSk1Aq » Thu May 10, 2012 12:45 am

Hi,
I am parsing a text file and I have managed to figure out how to open the text file read its contents and dump to a text field. From that I will parse the contents to Grid field and one of the columns of the grid will be the files creation date. I have searched and found that you can read a directory of files and get the attributes from it but not on a single file that the user has selected.
Here is my code for the button to select the file and read it into a field "inkReport" but what I want to do is have the first line be the files creation date.

on preOpenStack
put empty into field "inkReport"
end preOpenStack
on mouseUp
answer file "Select Ink Coverage Report file:" with type Text
put it into tFile
processFile tFile
end mouseUp

on processFile pFile
open file pFile for read
read from file pFile until EOF
put it into field "inkReport"
close file pFile
end processFile

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3168
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Getting a file's creation date

Post by mwieder » Thu May 10, 2012 12:55 am

Check out "the detailed files".

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3443
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Getting a file's creation date

Post by bn » Thu May 10, 2012 11:54 am

Hi cosnet1BUSk1Aq,

as Mark says.

since some of the things are not quite obvious when retrieving the detailed files I made a little stack to get info on a file.
cosnet1BUSk1Aq.livecode.zip
(1.59 KiB) Downloaded 225 times
Kind regards

Bernd

cosnet1BUSk1Aq
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10
Joined: Wed Apr 18, 2012 9:58 pm

Re: Getting a file's creation date

Post by cosnet1BUSk1Aq » Thu May 10, 2012 11:56 am

I did see that function. The issue is that is for parsing an entire directory of files. I already have my file.. I guess I can build a kind of work around to get the detail of a specific file. Let me play with the function.
Suggestion: you should index every word in the dictionary. if you search for "the details" nothing comes up.. or even if you search for details.
I see just before I posted this that Bernd has something too.. Thanks to both of you.
Bruce
Last edited by cosnet1BUSk1Aq on Thu May 10, 2012 12:11 pm, edited 1 time in total.

cosnet1BUSk1Aq
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10
Joined: Wed Apr 18, 2012 9:58 pm

Re: Getting a file's creation date

Post by cosnet1BUSk1Aq » Thu May 10, 2012 12:10 pm

Hi Bernd,
Thanks for the code. It was something I had in mind as what I would do (not as elegant of course and much longer for a newbie to do).
I notice you have a series of saving current defaults for delimiter and folder and then replacing them with my files folder and path delimiters. Are you doing that so it does not spoil other parts of a program that might be using different defaults or are there inherent defaults that should not be changed by a program?

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3443
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Getting a file's creation date

Post by bn » Thu May 10, 2012 12:22 pm

Hi Bruce,

as for the itemDelimiter I have to change it to "/" to get at the file name and the folder name. Later I want to get "item x of tAllFiles" but the itemdelimiter is ",". Here it is important to change the itemDelimiter back.

As for the default folder it is not strictly necessary to set it back in your case, in other cases it might become a problem.

So it is a bit wordy but a reminder that one easily forgets in a long handler that the itemDelimiter was changed 50 lines above and now I want to use it for a comma delimited list and don't know why my code does not work. It makes life easier to restore things one has changed.

Kind regards

Bernd

atmosk
Posts: 32
Joined: Wed Feb 27, 2013 5:50 pm

Re: Getting a file's creation date

Post by atmosk » Tue Oct 08, 2019 8:12 am

As this is the first result from Google for "livecode file creation date" and no other thread actually answers it either (at least when going over them semi-superficially) here's how it's done in Richard's script mentioned above (with minor modification),

Code: Select all

on mouseUp
   put item 4 of line 1 of the detailed files into tDate
   convert tDate to long date and long time
   answer tDate
end mouseUp

bogs
Posts: 4791
Joined: Sat Feb 25, 2017 10:45 pm

Re: Getting a file's creation date

Post by bogs » Tue Oct 08, 2019 11:38 am

UMMmm...

Having resurrected a number of posts so old even I could smell the rigorous coming off them, I don't want to sound too critical here atmosk, so please don't take it that way, but I had some questions about your post.
atmosk wrote:
Tue Oct 08, 2019 8:12 am
here's how it's done in Richard's script mentioned above (with minor modification),
Richard who? I only see a sample posted in Bernd's post, and Mark's suggestion of using the detailed files items?
put item 4 of line 1 of the detailed files into tDate
The second is about the code itself. while it is plenty short, without a loop (to cover every file in a given directory) or some other means of determining which file we're working on (such as an if/then or case/select structure), all I see you getting here is the detail of the first file in the list of files of the default folder.

This may (or may not) even be where you want to be looking :|

The script is easy enough to turn into a function though, you may want to try it that way so it can be used over and over again.
Image

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”