Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8614339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:05:57+00:00 2026-06-12T05:05:57+00:00

What is an efficient method to check if a file has changed and only

  • 0

What is an efficient method to check if a file has changed and only print the new data?

Originally, I leaned towards a readline approach comparing line counts but that seemed very inefficient.

My initial query was if there was a way to check file size or time stamp from Netlogo. The answer was ‘no’. However, Charles Staelin was kind enough to add the get-date-ms method to the pathdir extension. So, now the file changes (as per time stamp) can be checked for with set currenttimestamp pathdir:get-date-ms "somefile.nlist"
if currenttimestamp != filetimestamp

Using the added method:

to checkfile
  ifelse checktick mod 19 = 0
    [set currenttimestamp pathdir:get-date-ms "somefile.nlist" 
     if currenttimestamp != filetimestamp
     [file-open "somefile.nlist"
      let thiscount 0
      while [not file-at-end?][
        set in1 file-read-line
        set global-in1 in1
        set thiscount thiscount + 1
        if thiscount > global-filelength AND (not file-at-end?)[ ;it seems that this not-at-file-end is redundant - why not?
          print in1
          set global-filelength thiscount
          set hasfilechanged true

       ]

        ]
     file-close
      set filetimestamp currenttimestamp
      set checktick checktick + 1
      ]

     ]

    [ set checktick checktick + 1]

end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:05:58+00:00Added an answer on June 12, 2026 at 5:05 am

    Charles Staelin has recently added this to his pathdir extension, which adds an assortment of file and path oriented primitives to NetLogo. see http://groups.yahoo.com/group/netlogo-users/message/15301 . The extension is listed at https://github.com/NetLogo/NetLogo/wiki/Extensions

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having a little trouble designing an efficient data storage method of storing
Is there an efficient way to check the existence of a file on a
Is there an efficient method in VB to check if a string can be
Possible Duplicate: Most efficient way to check if a file is empty in Java
What's an efficient method (preferably simple as well) for communicating with a remote server
I'm wondering if there is a more efficient method for replacing colors in a
I am doing a project at the moment and I need an efficient method
I'm looking for the most efficient Java method that would allow me to 'delete
I'm looking to try to make an efficient delete method to work on a
I read that using recursion with Divide and Conquer method is efficient. Could anyone

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.