home *** CD-ROM | disk | FTP | other *** search
- /* PRO-CITE_IMPORT.rexx version 1.1 */
- /* This macro must be run from the WorkBench or a CLI (preferred). */
- /* The citations being imported by PRO-CITE_IMPORT.rexx may have been */
- /* generated by PRO-CITE or Current Contents and saved as a text file. */
- /* Since Currents Contents and PRO-CITE are not available on the Amiga, */
- /* the file will probably originate on an Apple MacIntosh 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 PRO-CITE file do not have abbreviated versions of */
- /* the journal names, so this macro simply copies the full journal name */
- /* into the abbreviated journal name field. You will have to replace */
- /* the full name with the abbreviated name by hand. Perhaps future */
- /* versions of this macro will employ a 'look-up' table to do the */
- /* substitution for you. Typical Current Contents/PRO-CITE citations */
- /* contain major words in the citation title that are all capitalized, */
- /* including genus and species names. The current version of this */
- /* macro CHANGES the capitals to lowercase, excluding the capital in the */
- /* first word. Since the sheer number of scientific names precludes */
- /* building a look-up table, you will have to fix the capital letter */
- /* in the genus name. Codes (the ampersand, &, and dollar sign, $) */
- /* for toggling formatting 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 Current Contents/Pro-Cite citation text file for import */
- /* Note: change the disk/drive designations below to suit your setup */
- screentofront();
- in_text = getfile(,,'ram:',,'Select PRO-CITE 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 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;
-
-
- /* Process citation and continue to end of file */
- Tab = d2c(9);
- do while (~EOF(importfile));
-
-
- /* Read the first Current Contents/Pro-Cite record */
- citation_input = readln(importfile);
- citation_input = translate(citation_input, '|', Tab);
-
-
- /* Break record into appropriate citation fields */
- parse var citation_input junk '|' citation_input;
- do j = 1 to 7;
- parse var citation_input pc_string.j '|' citation_input;
- end;
-
-
- /* Extract author names & reconstruct author string */
- author_string = '';
- n = 1;
- if (length(pc_string.1) >= 2) then;
- do;
- do forever;
- parse var pc_string.1 surname.n ', ' pc_string.1;
- if surname.n == '' then leave;
- parse var pc_string.1 initials.n '//' pc_string.1;
- initials.n = translate(initials.n, ' ', '.');
- initials.n = strip(initials.n, 'T');
- author_string = (author_string || surname.n || ', ' || initials.n || ", ");
- end;
- author_string = left(author_string,(length(author_string)-2));
- end;
- else author_string = '';
-
-
- /* Extract title and convert capitals to lowercase */
- title_string = pc_string.2;
- do i = 2 to length(title_string);
- temp = substr(title_string,i,1);
- if ((temp >= 'A') & (temp <= 'Z')) then;
- do;
- temp = d2c((c2d(temp))+32);
- title_string = insert(temp,title_string,i,1);
- title_string = delstr(title_string,i,1);
- end;
- else NOP;
- end;
-
-
- /* Extract journal name, year, volume */
- journal = pc_string.3;
- parse var pc_string.4 year ' ' junk;
- volume = pc_string.5;
-
-
- /* Extract page numbers */
- page_numbers = pc_string.7;
- 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_string;
- rec.4.value = (journal || ', ' || volume || ', ' || first_page || ', ' || last_page || ',');
- rec.5.value = ('*' || journal);
- do k = 1 to 5;
- foo = writeln(exportcitefile,rec.k.value);
- say rec.k.value;
- end;
- end;
-
-
- /* Exit macro gracefully */
- say 'Citations imported from ' || in_text || ' now in database';
- exit;
-