FileList and Date check

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Locked
User avatar
Dudus
Posts: 120
Joined: Wed Sep 07, 2005 12:15 pm
Location: Hungary, Budapest

FileList and Date check

Post by Dudus »

SO... :)

i have a list of txt files now in a ListBox - its okay, but inside of these txt files the first row is a date for example 12.10.2017.
How can I check all of the files if I want to check that the date has expired. For example:

1.txt -> first row inside of text file is: 10.10.2017
2.txt -> first row inside of text file is: 19.10.2017

the result is: We would like to inform you, that the 1.txt is expired! Please check it.

Thank You again!
Dudus
User avatar
Gaev
Posts: 3782
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada
Contact:

Re: FileList and Date check

Post by Gaev »

Dudus:

Take a look at this code ...

Code: Select all

... get count of items in ListBox
ListBoxSize "ListBox3" "[LoopCount]"
... loop through each item
Loop "1" "[LoopCount]" "[LoopPosition]"
   ... get item
   ListBoxGetItem "ListBox3" "[LoopPosition]" "[thisListItem]"
   ... if file exists, read first line
   ... NOTE: You may have to prefix file name with file path
   FileExists "[thisListItem]" "[FileExistsResult]"
   If "[FileExistsResult]" "=" "True"
      FileRead "[thisListItem]" "1" "[thisLine1]"
      ... convert file date
      ... NOTE: Choose different file format if not default
      DateToNum "[thisLine1]" "Default" "[thisFileDate]"
      DateToNum "[DateShort]" "Default" "[DateToday]"
      If "[DateToday] ">" "[thisFiledate]"
         AlertBox "Attention" "File [thisLisItem] expired on [thisLine1]"
      Endif
   Else
      AlertBox "Attention" "File [thisListItem] does not exist"
   Endif
EndLoop
... make adjustments as necessary.
User avatar
Dudus
Posts: 120
Joined: Wed Sep 07, 2005 12:15 pm
Location: Hungary, Budapest

Re: FileList and Date check

Post by Dudus »

Thank you Gave!

Works great! :) yesss
Locked