home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 448a.lha / Citation_Base_v1.1 / REXX / REFER-BibIX_EXPORT.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1990-09-15  |  3.2 KB  |  115 lines

  1. /* REFER-BibIX_EXPORT.rexx  version 1.1  */
  2. /* This macro can be run from the CLI, SHELL or WorkBench and  */
  3. /* acts on a text or word processor-based citation database from  */
  4. /* which you wish to export citations in REFER-BibIX format.  The  */
  5. /* macro generates a text file that can be imported into ENDNOTE on  */
  6. /* the MacIntosh or into REFER or BibIX on UNIX platforms.  */
  7.  
  8. /* open the citation text file (database) for import */
  9. /* NOTE: change the disk/drive designations below to suit your setup */
  10. in_text = getfile(,,'ram:',,'Select citation import file');
  11. if (in_text = '') then exit;
  12. if (open(importfile,in_text,'R') ~= 1) then;
  13.   do;
  14.     say 'I could not open the file ' || in_text || ' for importing.';
  15.     exit;
  16.   end;
  17.  
  18. /* open the text file for export */
  19. out_text = getfile(,,'ram:',,'Select REFER/BibIX export name');
  20. if (out_text = '') then exit;
  21. if (open(exportfile,out_text,'W') ~= 1) then;
  22.   do;
  23.     say 'I could not open the file ' || out_text || ' for exporting.';
  24.     exit;
  25.   end;
  26.  
  27.  
  28. /* get the first record */
  29. Tab = d2c(9);
  30. do j = 1 to 5;
  31.   rec.j.value = readln(importfile);
  32. end;
  33.  
  34.  
  35. /* Start output loop for citations */
  36. do while (~EOF(importfile));
  37.  
  38.  
  39. /* Extract author names & reconstruct author string */
  40.   authors = rec.1.value;
  41.   author_string.n = '';
  42.   n = 0;
  43.   if (length(authors) >= 2) then;
  44.     do forever;
  45.       n = n + 1;
  46.       parse var authors surname ',' authors;
  47.       surname = strip(surname,'B');
  48.       if surname == '' then leave;
  49.       parse var authors initials ',' authors;
  50.       initials = compress(initials);
  51.       new_initials = '';
  52.       do k = 1 to length(initials);
  53.          new_initials = (new_initials || (substr(initials,k,1) || ' '));
  54.          fix_pos = index(new_initials,'J r');
  55.          if fix_pos > 0 then;
  56.            new_initials = delstr(new_initials,(fix_pos + 1),1);
  57.       end;
  58.       new_initials = translate(new_initials, '.', ' ');
  59.       author_string.n = ('%A ' || new_initials || ' ' || surname);
  60.     end;
  61.  
  62.  
  63. /* Extract year and title */
  64.    year = ('%D ' || rec.2.value);
  65.   title = ('%T ' || rec.3.value);
  66.  
  67.  
  68. /* Extract volume, first and last page numbers, keywords */
  69.   parse var rec.4.value junk ',' volume ',' first ',' last ',' keywords;
  70.   volume = ('%V ' || (compress(volume)));
  71.    first = compress(first);
  72.     last = compress(last);
  73.    pages = ('%P ' || first || '-' || last);
  74. keywords = ('%K ' || (strip(keywords,'L',' ')));
  75.  
  76.  
  77. /* Extract full journal name, append abbreviated journal name */
  78.   journal = ('%J ' || (strip(rec.5.value,'L','*')));
  79.  abbrev_j = ('%B ' || junk);
  80.  
  81.  
  82. /* Export the citation in the REFER/BibIX format */
  83.   do out = 1 to n-1;
  84.     foo = writeln(exportfile,author_string.out)
  85.     say author_string.out;
  86.     author_string.out = '';
  87.   end;
  88.   foo = writeln(exportfile,year);
  89.   foo = writeln(exportfile,title);
  90.   foo = writeln(exportfile,abbrev_j);
  91.   foo = writeln(exportfile,journal);
  92.   foo = writeln(exportfile,volume);
  93.   foo = writeln(exportfile,pages);
  94.   foo = writeln(exportfile,keywords);
  95.   foo = writeln(exportfile,'');
  96.   say year;
  97.   say title;
  98.   say abbrev_j;
  99.   say journal;
  100.   say volume;
  101.   say pages;
  102.   say keywords;
  103.   say '';
  104.  
  105.  
  106. /* get the next record */
  107.   do loop = 1 to 5;
  108.     rec.loop.value = readln(importfile);
  109.   end;
  110. end;
  111.  
  112. /* exit macro */
  113. say 'Exported REFER/BibIX style citations in file ' || out_text;
  114. exit;
  115.