none
LitDev API Question RRS feed

  • Question

  • I would like to use LitDev's extentions to raise an event when a text file is changed.

    I see that in the LDEvents object, there is a FileChange event. However, I'm not  very experienced in programming I'm not sure how to implement the event.

    I see that the FilePath property should be set before using the FileChange event, can this be to a file in my program path?

    A small example would be helpful to get me pointed in the right procedure.

    Thanks,

    Thursday, September 6, 2012 3:16 PM

Answers

  • Try the following code:

    Note only a directory can be set to check, but you can then filter or check individual files in the event call.  Save the SmallBasic file somewhere first then create, edit or delete a txt file in this directory while running the program.

    TextWindow.Show()
    LDEvents.FilePath = Program.Directory 'This directory and all sub directories are checked
    LDEvents.FileFilter = "*.txt" 'txt files only
    LDEvents.FileChange = OnFileChange
    
    Sub OnFileChange
      path = LDEvents.LastFileChanged
      type = LDEvents.LastFileChangeType
      TextWindow.WriteLine(path+" ("+type+")")
    EndSub
    • Marked as answer by SFC-P33A Thursday, September 6, 2012 11:52 PM
    Thursday, September 6, 2012 5:31 PM
    Moderator

All replies

  • Try the following code:

    Note only a directory can be set to check, but you can then filter or check individual files in the event call.  Save the SmallBasic file somewhere first then create, edit or delete a txt file in this directory while running the program.

    TextWindow.Show()
    LDEvents.FilePath = Program.Directory 'This directory and all sub directories are checked
    LDEvents.FileFilter = "*.txt" 'txt files only
    LDEvents.FileChange = OnFileChange
    
    Sub OnFileChange
      path = LDEvents.LastFileChanged
      type = LDEvents.LastFileChangeType
      TextWindow.WriteLine(path+" ("+type+")")
    EndSub
    • Marked as answer by SFC-P33A Thursday, September 6, 2012 11:52 PM
    Thursday, September 6, 2012 5:31 PM
    Moderator
  • Thanks litdev that is what I needed.
    Thursday, September 6, 2012 11:52 PM