home *** CD-ROM | disk | FTP | other *** search
- /* AGRICOLA_IMPORT.rexx version 1.1 */
- /* This macro must be run from the WorkBench or a CLI (preferred). */
- /* The citations being imported by AGRICOLA_IMP.rexx must have been */
- /* generated by the AGRICOLA CD ROM and saved as a text file. Since */
- /* the AGRICOLA CD ROM is not yet available for the Amiga, you will */
- /* have had to create the file on an AGRICOLA station or IBM PC (or */
- /* PC clone). The file will have to be moved to an AmigaDOS disk */
- /* for this macro to have access to it. A number of commercial or */
- /* public domain products are available to enable these transfers. */
- /* See the main Citation_Base documentation for more information. */
- /* The citations in the AGRICOLA file have only abbreviated journal */
- /* names, so this macro simply copies the abbreviated journal name */
- /* into the full journal name field. You will have to replace */
- /* the abbreviated name with the full name by hand. Perhaps future */
- /* versions of this macro will employ a 'look-up' table to do the */
- /* substitution for you. Another characteristic of AGRICOLA citations */
- /* is that journal names contain a trailing period, which is OK when */
- /* the last word in the abbreviated name is truly abbreviated, but */
- /* some journal names are spelled out fully and should not have the */
- /* trailing period. You will need to remove these periods by hand. */
- /* Codes (the ampersand, &, and dollar sign, $) for toggling the */
- /* formatting around scientific names must also be inserted by the */
- /* user. Don't be put off by the minor modifications described */
- /* above, the effort is minimal compared to entering the complete */
- /* citation. */
-
-
- /* Open the Agricola citation text file for import */
- /* Note: change the disk/drive designations below to suit your setup */
- screentofront();
- in_text = getfile(,,'ram:',,'Select Agricola 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 file to export non-standard (bad) Agricola citations */
- out_text = getfile(,,'ram:',,'Filename for bad citations');
- if (out_text = '') then exit;
- if (open(exportfile,out_text,'W') ~= 1) then;
- do;
- say 'I could not open the file ' || out_text || ' for output.';
- exit;
- end;
-
-
- /* Open file to export citations in Citation_Base format. */
- out_cite = getfile(,,'ram:',,'Citation export filename');
- if (out_cite = '') then exit;
- if (open(exportcitefile,out_cite,'W') ~=1) then;
- do;
- say 'I could not open the file ' || out_cite || ' for output.';
- exit;
- end;
-
-
- /* Initialize variables */
- cite_num = 0;
- b = 1;
-
-
- /* Process citation and continue to end of file */
- do while (~EOF(importfile));
-
-
- /* Read Agricola CITN style citation */
- cite_num = cite_num + 1;
- skip_cite = 'no';
- j = 1;
- agr_string.j = readln(importfile);
- do forever;
- j = j + 1;
- agr_string.j = readln(importfile);
- agr_string.j = strip(agr_string.j,'T',d2c(13));
- say agr_string.j;
- if substr(agr_string.j,3,1) ~= ':' then leave;
- end;
- if j > 7 then;
- do;
- skip_cite = 'yes';
- bad_cite_num.b = cite_num;
- b = b + 1;
- end;
- else;
- do;
- temp = agr_string.4;
- parse var temp junk ': ' junk ' ' test_year ' v. ' temp;
- if right(test_year,1) = '.' then test_year = left(test_year,length(test_year)-1);
- prefix_year = substr(test_year,length(test_year)-3,2);
- if ((prefix year ~= '18') & (prefix_year ~= '19') & (prefix_year ~= '20')) then;
- do;
- skip_cite = 'yes';
- bad_cite_num.b = cite_num;
- b = b + 1;
- end;
- else NOP;
- end;
-
- /* Skip citation if in non-standard format */
- if skip_cite = 'no' then;
- do;
-
- /* Extract author names and reconstruct author string */
- author_string = '';
- parse var agr_string.2 junk ': ' agr_string.2;
- if (length(agr_string.2) >= 2) then;
- do;
- do forever;
- parse var agr_string.2 surname ',-' agr_string.2;
- if surname == '' then leave;
- parse var agr_string.2 initials '.; ' agr_string.2;
- initials = compress(translate(initials,' ','.'));
- author_string = (author_string || surname || ', ' || initials || ', ');
- end;
- author_string = left(author_string,(length(author_string)-2));
- end;
- else author_string = '';
-
-
- /* Extract title */
- parse var agr_string.3 junk ': ' title;
- title = left(title,(length(title)-1));
-
-
- /* Extract journal name */
- parse var agr_string.4 junk ': ' journal ' ' agr_string.4;
- do forever;
- hyphen_pos = index(journal,'-');
- if hyphen_pos = 0 then leave;
- journal = insert('. ',journal,hyphen_pos);
- journal = delstr(journal,hyphen_pos,1);
- end;
-
-
- /* Extract year and volume number */
- parse var agr_string.4 long_year ' v. ' volume ' ' junk 'p. ' page_numbers '.' junk;
- if right(long_year,1) = '.' then long_year = left(long_year,length(long_year)-1);
- year = right(long_year,4);
-
-
- /* Extract page numbers */
- hyphen_pos = index(page_numbers,'-');
- if hyphen_pos = 0 then;
- do;
- first_page = page_numbers;
- last_page = '';
- end;
- else;
- do;
- parse var page_numbers first_page "-" last_page;
- end;
-
- /* Assign string values to record (citation) values and add record */
- rec.1.value = author_string;
- rec.2.value = year;
- rec.3.value = title;
- rec.4.value = (journal || ', ' || volume || ', ' || first_page || ', ' || last_page || ', ');
- rec.5.value = ('*' || journal);
- do k = 1 to 5;
- foo = writeln(exportcitefile,rec.k.value);
- end;
- end;
-
-
- /* Write non-standard (bad) citations to export file */
- else;
- do i = 2 to j;
- foo = writeln(exportfile,agr_string.i);
- end;
-
- /* End Agricola citation import loop */
- end;
-
-
- /* Report bad citations */
- do i = 1 to b-1;
- say 'Bad citation: ' || bad_cite_num.i;
- foo = writeln(exportfile,('Bad citation: ' || bad_cite_num.i));
- end;
-
-
- /* Exit macro gracefully */
- screentoback();
- say 'Citations imported from ' || in_text || ' now in database';
- exit;
-
-
-