From GridLAB-D Wiki
Import/Export - Module import/export functions
Synopsis
EXPORT int import_file(const char *file); EXPORT int export_file(const char *file);
Description
The import and export directives are used to allow module to load non-GLM data. When import is referenced in a GLM file, the appropriate module's import function is called. When export is references in a GLM file, the module's export function will be called when the simulation terminates.
Example
#include <string.h>
EXPORT int import_file(char *file)
{
char *ext = strrchr(file,'.');
if (ext!=NULL && stricmp(ext,".cdf")==0 )
return my_read_cdf(file) ? 1 : 0;
errno = ENOENT;
return 0;
}
EXPORT int export_file(char *file)
{
if (file==NULL) file="default.ext";
char *ext = strrchr(file,'.');
if (ext!=NULL && stricmp(ext,".cdf")==0)
return my_write_cdf(file) ? 1 : 0;
errno = ENOENT;
return 0;
}
See also
- Guide to Programming GridLAB-D
- Introduction
- Creating a module
- Creating a class
- Special Topics
- Source documentation
- Validation
- Debugging
- Code templates