home *** CD-ROM | disk | FTP | other *** search
- /* REFER-BibIX_EXPORT.rexx version 1.1 */
- /* This macro can be run from the CLI, SHELL or WorkBench and */
- /* acts on a text or word processor-based citation database from */
- /* which you wish to export citations in REFER-BibIX format. The */
- /* macro generates a text file that can be imported into ENDNOTE on */
- /* the MacIntosh or into REFER or BibIX on UNIX platforms. */
-
- /* open the citation text file (database) for import */
- /* NOTE: change the disk/drive designations below to suit your setup */
- in_text = getfile(,,'ram:',,'Select citation import file');
- if (in_text = '') then exit;
- if (open(importfile,in_text,'R') ~= 1) then;
- do;
- say 'I could not open the file ' || in_text || ' for importing.';
- exit;
- end;
-
- /* open the text file for export */
- out_text = getfile(,,'ram:',,'Select REFER/BibIX export name');
- if (out_text = '') then exit;
- if (open(exportfile,out_text,'W') ~= 1) then;
- do;
- say 'I could not open the file ' || out_text || ' for exporting.';
- exit;
- end;
-
-
- /* get the first record */
- Tab = d2c(9);
- do j = 1 to 5;
- rec.j.value = readln(importfile);
- end;
-
-
- /* Start output loop for citations */
- do while (~EOF(importfile));
-
-
- /* Extract author names & reconstruct author string */
- authors = rec.1.value;
- author_string.n = '';
- n = 0;
- if (length(authors) >= 2) then;
- do forever;
- n = n + 1;
- parse var authors surname ',' authors;
- surname = strip(surname,'B');
- if surname == '' then leave;
- parse var authors initials ',' authors;
- initials = compress(initials);
- new_initials = '';
- do k = 1 to length(initials);
- new_initials = (new_initials || (substr(initials,k,1) || ' '));
- fix_pos = index(new_initials,'J r');
- if fix_pos > 0 then;
- new_initials = delstr(new_initials,(fix_pos + 1),1);
- end;
- new_initials = translate(new_initials, '.', ' ');
- author_string.n = ('%A ' || new_initials || ' ' || surname);
- end;
-
-
- /* Extract year and title */
- year = ('%D ' || rec.2.value);
- title = ('%T ' || rec.3.value);
-
-
- /* Extract volume, first and last page numbers, keywords */
- parse var rec.4.value junk ',' volume ',' first ',' last ',' keywords;
- volume = ('%V ' || (compress(volume)));
- first = compress(first);
- last = compress(last);
- pages = ('%P ' || first || '-' || last);
- keywords = ('%K ' || (strip(keywords,'L',' ')));
-
-
- /* Extract full journal name, append abbreviated journal name */
- journal = ('%J ' || (strip(rec.5.value,'L','*')));
- abbrev_j = ('%B ' || junk);
-
-
- /* Export the citation in the REFER/BibIX format */
- do out = 1 to n-1;
- foo = writeln(exportfile,author_string.out)
- say author_string.out;
- author_string.out = '';
- end;
- foo = writeln(exportfile,year);
- foo = writeln(exportfile,title);
- foo = writeln(exportfile,abbrev_j);
- foo = writeln(exportfile,journal);
- foo = writeln(exportfile,volume);
- foo = writeln(exportfile,pages);
- foo = writeln(exportfile,keywords);
- foo = writeln(exportfile,'');
- say year;
- say title;
- say abbrev_j;
- say journal;
- say volume;
- say pages;
- say keywords;
- say '';
-
-
- /* get the next record */
- do loop = 1 to 5;
- rec.loop.value = readln(importfile);
- end;
- end;
-
- /* exit macro */
- say 'Exported REFER/BibIX style citations in file ' || out_text;
- exit;
-