.
.   
NEdit.org
   .

Home
 - News - Download - Documentation - Search - FTP     
.
.
  

Load macro files on demand

[Back]

Ever wished your NEdit would start as fast as it did before you added all those macros? Did you want to be able to give users a particular search path for them to pick up their (perhaps preset) macro files? You've got a macro which depends on another, but you can't remember whether you've already loaded it?

Help is on its way!

The macros supplied here (in a file I've called NEDIT_LOADED.nm) try to answer these problems, rather in the manner of the #import directive in Objective-C, or the require keyword in Perl. What you do is load the NEDIT_LOADED.nm file using the one-line .neditmacro file:

  load_macro_file("<path-to-files>/NEDIT_LOADED.nm")
After that, wherever you have a macro which depends on another defined in a file, call
  NEDIT_require_macro_file("<your-macro-file-name>")
to load it. NEDIT_require_macro_file() will search a path defined by the ":" or " " separated environment variable called $NEDIT_MACRO_SEARCH_PATH if the name supplied to it does not give an absolute path to the file. You can call it inside another macro file (for example, in my macro files, I add
  NEDIT_require_macro_file("element.nm")
for the array handling routines), or at the start of a macro defined in NEdit's macro dialogs (I do this for my .shtml definitions, for example:
  NEDIT_require_macro_file("html.nm")
  html_add_markup_brackets("TT")
where html_add_markup_brackets() is defined in the file html.nm somewhere on the $NEDIT_MACRO_SEARCH_PATH).

Since NEDIT_require_macro_file() does a quick check (a search in a global string) before loading a file, it will only load that file once.

Another useful function is the NEDIT_find_file_in_pathlist() which looks for a file of a given name in the given (newline-separated) path list. Based on Rusty Ballinger's include file search and open functions, this can be used in other contexts.

A word of warning: if NEDIT_LOADED.nm cannot be found on the $NEDIT_MACRO_SEARCH_PATH, you'll get a warning dialog.

... And if you use VMS, I'm afraid you'll have to rewrite these calls... sorry.

[Back]


. Released on  Wed, 21 Nov 2001  by C. Denat  

  
Visit our sponsor
Check Metrolink

© NEdit.org
1999-2001
All rights reserved


.