Source language: Translate to:

FileList and Date check

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

FileList and Date check

Postby Dudus » Thu Oct 12, 2017 12:07 pm

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
Dudus
 
Posts: 114
Joined: Wed Sep 07, 2005 12:15 pm
Location: Hungary, Budapest

Re: FileList and Date check

Postby Gaev » Thu Oct 12, 2017 3:18 pm

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
Gaev
 
Posts: 3737
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: FileList and Date check

Postby Dudus » Fri Oct 13, 2017 6:28 am

Thank you Gave!

Works great! :) yesss
User avatar
Dudus
 
Posts: 114
Joined: Wed Sep 07, 2005 12:15 pm
Location: Hungary, Budapest


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 1 guest

cron