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

  1. /* PRO-CITE_IMPORT.rexx version 1.1 */
  2. /* This macro must be run from the WorkBench or a CLI (preferred). */
  3. /* The citations being imported by PRO-CITE_IMPORT.rexx may have been */
  4. /* generated by PRO-CITE or Current Contents and saved as a text file. */
  5. /* Since Currents Contents and PRO-CITE are not available on the Amiga, */
  6. /* the file will probably originate on an Apple MacIntosh or IBM PC (or */
  7. /* PC clone).  The file will have to be moved to an AmigaDOS disk */
  8. /* for this macro to have access to it.  A number of commercial or */
  9. /* public domain products are available to enable these transfers. */
  10. /* See the main Citation_Base documentation for more information. The */
  11. /* citations in the PRO-CITE file do not have abbreviated versions of */
  12. /* the journal names, so this macro simply copies the full journal name */
  13. /* into the abbreviated journal name field.  You will have to replace */
  14. /* the full name with the abbreviated name by hand.  Perhaps future */
  15. /* versions of this macro will employ a 'look-up' table to do the */
  16. /* substitution for you.  Typical Current Contents/PRO-CITE citations */
  17. /* contain major words in the citation title that are all capitalized, */
  18. /* including genus and species names.  The current version of this */
  19. /* macro CHANGES the capitals to lowercase, excluding the capital in the */
  20. /* first word.  Since the sheer number of scientific names precludes */
  21. /* building a look-up table, you will have to fix the capital letter */
  22. /* in the genus name.  Codes (the ampersand, &, and dollar sign, $) */
  23. /* for toggling formatting scientific names must also be inserted by */
  24. /* the user.  Don't be put off by the minor modifications described */
  25. /* above, the effort is minimal compared to entering the complete */
  26. /* citation. */
  27.  
  28.  
  29. /* Open the Current Contents/Pro-Cite citation text file for import */
  30. /* Note:  change the disk/drive designations below to suit your setup */
  31. screentofront();
  32. in_text = getfile(,,'ram:',,'Select PRO-CITE import file');
  33. if (in_text = '') then exit;
  34. if (open(importfile,in_text,'R') ~= 1) then;
  35.   do;
  36.     say 'I could not open the file ' || in_text || ' for importing.';
  37.     exit;
  38.   end;
  39.  
  40.  
  41. /* Open file to export citations in Citation_Base format. */
  42. out_cite = getfile(,,'ram:',,'Citation export filename');
  43. if (out_cite = '') then exit;
  44. if (open(exportcitefile,out_cite,'W') ~=1) then;
  45.   do;
  46.     say 'I could not open the file ' || out_cite || ' for output.';
  47.     exit;
  48.   end;
  49.  
  50.  
  51. /* Process citation and continue to end of file */
  52. Tab = d2c(9);
  53. do while (~EOF(importfile));
  54.  
  55.  
  56. /* Read the first Current Contents/Pro-Cite record */
  57. citation_input = readln(importfile);
  58. citation_input = translate(citation_input, '|', Tab);
  59.  
  60.  
  61. /* Break record into appropriate citation fields */
  62. parse var citation_input junk '|' citation_input;
  63. do j = 1 to 7;
  64.   parse var citation_input pc_string.j '|' citation_input;
  65. end;
  66.  
  67.  
  68. /* Extract author names & reconstruct author string */
  69.   author_string = '';
  70.   n = 1;
  71.   if (length(pc_string.1) >= 2) then;
  72.     do;
  73.       do forever;
  74.         parse var pc_string.1 surname.n ', ' pc_string.1;
  75.         if surname.n == '' then leave;
  76.         parse var pc_string.1 initials.n '//' pc_string.1;
  77.         initials.n = translate(initials.n, ' ', '.');
  78.         initials.n = strip(initials.n, 'T');
  79.         author_string = (author_string || surname.n || ', ' || initials.n || ", ");
  80.       end;
  81.       author_string = left(author_string,(length(author_string)-2));
  82.     end;
  83.   else author_string = '';
  84.  
  85.  
  86. /* Extract title and convert capitals to lowercase */
  87.     title_string = pc_string.2;
  88.     do i = 2 to length(title_string);
  89.       temp = substr(title_string,i,1);
  90.       if ((temp >= 'A') & (temp <= 'Z')) then; 
  91.         do;
  92.           temp = d2c((c2d(temp))+32);
  93.           title_string = insert(temp,title_string,i,1);
  94.           title_string = delstr(title_string,i,1);
  95.         end;
  96.       else NOP;
  97.     end;
  98.  
  99.  
  100. /* Extract journal name, year, volume */
  101.   journal = pc_string.3;
  102.   parse var pc_string.4 year ' ' junk;
  103.   volume = pc_string.5;
  104.  
  105.  
  106. /* Extract page numbers */
  107.   page_numbers = pc_string.7;
  108.   hyphen_pos = index(page_numbers,'-');
  109.   if hyphen_pos = 0 then;
  110.     do;
  111.       first_page = page_numbers;
  112.       last_page = '';
  113.     end;
  114.   else;
  115.     do;
  116.       parse var page_numbers first_page '-' last_page;
  117.     end;
  118.  
  119.  
  120. /* Assign string values to record (citation) values  and add record */
  121.   rec.1.value = author_string;
  122.   rec.2.value = year;
  123.   rec.3.value = title_string;
  124.   rec.4.value = (journal || ', ' || volume || ', ' || first_page || ', ' || last_page || ',');
  125.   rec.5.value = ('*' || journal);
  126.   do k = 1 to 5;
  127.     foo = writeln(exportcitefile,rec.k.value);
  128.     say rec.k.value;
  129.   end;
  130. end;
  131.  
  132.  
  133. /* Exit macro gracefully */
  134. say 'Citations imported from ' || in_text || ' now in database';
  135. exit;
  136.