allegro Data Import 

1.  `External Data` 
2.  `Details of external data structure` 
3.  `How to load external data in a99` 
4.  `Copying from a parallel database`	
5.  `Fast coupling` 
	(Opening a resource database for copying)
6.  `Conventional Import` 
      (Ready-made for MARC, MAB2, Pica, VLB)

Background
A frequent situation: one has obtained material from other environments and wants to insert it into a database. allegro possesses powerful methods, esp. for cases where the external data have a very different or even exotic structure. Chapters 5 (Concept and application)  and 11 (Import Language) of the System Handbook describe it all. 
Briefly: An "import" proceeds in two phases: 
1. Conversion
In the most general case, an  Import Parameter File has to be written (Chap. 11), containing a precise description, field by field, of the external data and what IMPORT.EXE is supposed to do with it. This program can then read and process the material and export it into a file of type .ADT using  e-1.apr  (see below) or of type .ALG using i-1.apr. 
There are prefabricated import parameters for the bibliographic formats `MAB2`, `MARC` and `Pica3`. 
2. Merging
A file of type .ALG (as produced by IMPORT) can be merged into a database by `upd.exe`  (import.exe itself can only do the conversion, its name may thus be found misleading!).  a99 can directly read external files of type .ALG or .ADT (The FLEX command `read file` can be used automate this). 
The two phases can be combined in a batchfile: 
The general pattern of a batch looks like this: 

import -dfile -f5 -iform -e i-1/new.clg -v1 -m0 -s0 -h0 -kconf
upd -fm01 -dDbDir\DbName -unew.clg -n2 -m1 -kconf

Example:
Say there's a database using $u.cfg as its configuration and the name of  marc, located on  k:\database\catalog,  and we have an external file xyz.dat and a suitable parameter file usmarc.uim, then our batch would be: (the configuration letter being u, the file has to be of type ulg ) 

import -dxyz.dat -f5 -iusmarc -e i-1/new.ulg -v1 -m0 -s0 -h0 -ku
upd -fm01 -dk:\database\catalog\marc -u new.ulg -n2 -m1 -ku

The  function mode of the merging is indicated by the option  -fmxy . x and y are digits. The possible values are documented in the  `Handbook Chap.9` . 
The mos difficult job is therefore the writing of an import specification file. Once this has been done, the rest is simple, following the indicated method. For the standard schema, several import specs are part of the package along with appropriate `Batch files` to make the import process a very simple procedure. 

1. External data
In the least complicated situation one would have data in a predefined format, called the `external format` . 
Here are two records int his format, using the tags of the "consolidated bibliographic format" (the second is a "hierarchic record" with two subrecords): 

#00 123456 
#20 Einsicht ins Ich : Fantasien und Reflexionen über Selbst und Seele 
#22 ¬The¬ mind's I <dt.> 
#30 CS PH 
#31 Künstliche Intelligenz; Selbstreferenz; Individualität 
#39 Ausgewählt und in Szene gesetzt von Douglas R. Hofstadter und Daniel 
 Dennett. [Aus d. Amerik. übers. von Ulrich Enderwitz] 
#40 Hofstadter, Douglas R. 
#402Dennett, Daniel C. 
#74 Stuttgart 
#75 Klett-Cotta 
#76 1986 
#77 485 S. 
#81 Orig. Ausg. bei Basic Books, 1982 
#87 3-608-93038-8 

#00 654321 
#20 Was können wir wissen? 
#31 Evolutionäre Erkenntnistheorie 
#40 Vollmer, Gerhard 
#74 Stuttgart 
#75 Hirzel 
#76 1985 
#77 Bd.1.2. 
#01 1=Bd. 1 
#20 ¬Die¬ Natur der Erkenntnis : Beiträge zur Evolutionären 
 Erkenntnistheorie 
#25 Mit einem Geleitw. v. Konrad Lorenz 
#77 337 S. 
#87 3-7776-0403-8 
#90 2647-3611 
#01 2=Bd. 2 
#20 ¬Die¬ Erkenntnis der Natur : Beiträge zur modernen Naturphilosophie 
#77 350 S. 
#87 3-7776-0404-6 
#90 2650-9705 

If one has records like these in a file EXTERN.DAT on the working directory of a99, the program can read these directly! On the "File" menu, use the command "External result set", and you see the records displayed at once. More about this under 3.. 

2. Details of the external structure
Every record has to start on a new line beginning with the  # character followed by a tag number. The tag numbers are defined in a  `configuration file` named $A.CFG . 
Multiple fields must be distinguished by a digit or letter following the tag, like  #402 for the 2nd author. 
A blank line is the demarcation between two records. 
If a field, because of its length, is broken into several lines, this should be done only between words, and subsequent lines have to begin with a space. 
Codes have to be ASCII. (In case of ANSI, being the Windows standard, activate the two lines "dx=1" and "to" in the file d-w.apr, ANSI will then be changed into ASCII via the table o.apt ) 
The second example is a hierarchic record consisting of a main and two subordinate records (each beginning with a #01 field). If linked records are wanted rather than hierarchic ones, the second example has to look like this: (being three records, each with its own ID number #00, the link being effected by the number in field #00 of the main record) 

#00 654321
#20 Was können wir wissen? 
#31 Evolutionäre Erkenntnistheorie 
#40 Vollmer, Gerhard 
#74 Stuttgart 
#75 Hirzel 
#76 1985 
#77 Bd.1.2. 

#00 324987 
#09 654321+1=Bd. 1 
#20 ¬Die¬ Natur der Erkenntnis : Beiträge zur Evolutionären 
 Erkenntnistheorie 
#25 Mit einem Geleitw. v. Konrad Lorenz 
#77 337 S. 
#87 3-7776-0403-8 
#90 2647-3611 

#00 837613 
#09 654321+2=Bd. 2 
#20 ¬Die¬ Erkenntnis der Natur : Beiträge zur modernen Naturphilosophie 
#77 350 S. 
#87 3-7776-0404-6 
#90 2650-9705 

3. How to load external data in a99 
1. Go to the menu "File | External result set". The contents of file EXTERN.DAT will appear in the result window. These records will not, however, be merged into the database right away, they are just loaded into the `Offline Store`. Don't worry, therefore - you are safe from making horrible mistakes! 

2. The offline records can be looked at in the display window, you can edit them, and use the [Next] and [Previous] buttons (lower right) to browse forward and backward. In the status display, you see  "NEW" to indicate that the record is not (yet) part of the database. 

3. Every record may be saved individually using the [Save Rec] button. 

4. Or  save all offline records at once using the menu "File | Offline file -> Database".  If unsaved records are left when exiting the program, you will be asked to decide whether or not to save the remaining offline records - just reply "no" to prevent it! 

The FLEX command `update` automates the merging of offline data. 

If you have data in formats different from this or if you cannot easily produce this format using tools available to you, read Chap. 5. It explains how to proceed. Chap. 11 describes existing conversion parameters and how to create individual parameters. 

4. Copying from a parallel database  
[Handbook Chap.2.4]
It is one of the most popular features of the DOS program PRESTO that it can switch to another database by Alt+a , whereupon the same index section of the other database will pop up. In  a99/alcarta this is a trifle more difficult to achieve, but with a few very brief FLEXes life can become even more comfortable. 
But you don't have to write any FLEXes yourself; there's a  FLEX named `FREMDDB` that establishes a  fast coupling between your database and another one - if you have one in your system (i.e., on one of the accessible disks).  For future sessions, the settings for this coupling will be saved in a  fremddb.ini - coupling will then be even faster. 
For experts interested in the details, here's a step-by-step description of the procedure: 

The task: Switch from database A to a resource database B. Display the same index section there. If a usable record is found in  B , copy it from B to A on the push of a button. 

Solution:  Alt+a like in PRESTO cannot be used  (because it is used for "Add bookmark"). Instead, the swithing  AàB is done by Alt+1, the reverse  BàA with Alt+9 . 
Start both databases with separate calles to a99, for B alcarta can be used as well. We  assume both calls are issued from the same work directory. 
In  B.INI  we need to have: 
ExportParameter=E-W 
OutputFile=E.ADT 

NEW and better than in PRESTO: If the resource database is in a different format, one has to provide appropriate export parameters E-W for it. Then, one can even import directly from databases in completely different formats. 

Switching  A à B 
A FLEX called SWITCH.FLX is provided for this. It contains comment. 
When activated in A, this FLEX writes a file alta.flx and then sends a message to B to execute this FLEX. The ALTA.FLX contains just this : 
activate 
index |i xyz
with xyz  being the last access point in the current index i . 
The activate command will bring B into the foreground. 
Then, index i is displayed at position xyz . 
It works both ways! Alt+TAB may also be used to switch between both databases, with no effect on the indexes however. 
The simplest way to install the function in A: Enter this into the input field: 
   #uX1X switch.flx 
After this, Alt+1 will do the switch, and will be preserved for future sessions. The "fast coupling" function will, instead, produce a new menu item in the main menu. 

Backswitch B à A 
The simple FLEX    x download\flex copy 
(to be started in B) will at first download the current record to the file E.ADT , then send a message to  A to inform it that it should execute the  COPY.FLX . This file, too, comes with the package and is commented. 
The simplest way to install the function in B: Enter this into the input field: 
   #uX9x download\flex copy 
After this, Alt+9 will do the switch, and will also be preserved for future sessions. 

A FLEX command delete in copy.flx deletes the file E.ADT to make sure the next copy action can follow immediately. 

switch.flx  und  copy.flx  are contained in the package. They may be adapted for individual purposes. 

6.  Conventional Import
The DOS `Import Parameter Files` remain valid. More about these in the handbook Chapters 5 and  11. 
For the standard format, $A.CFG, several import parameters come with the package. 
In the DOS `CockPit`, there is a menu item "Import-Aktionen" under "Macros". The options are these: Deutsche Bibliothek (MAB2), Pica, MARC and VLB. For each of these there is a parameter file written for that particular format: MAB2.AIM, PICA.AIM and so on. 

?configuration file=h acb-1 
?External Data=h =1. External Data 
?Details of external data structure=h =2. Details 
?How to load external data in a99=h =3. How to load 
?Copying from a parallel database=h =4. Copying from 
?Offline Store=h off 
?update=h xupdate 
?FREMDDB=X fremddb 
?Fast coupling=X fremddb 
?upd.exe=h ac9 
?MAB2=h mab2.aim 
?MARC=h oclc.aim 
?Pica3=h pica.aim 
?Handbook Chap.9=h ac9=Option -fm 
?Conventional Import=h =6.  Conventional Import 
?read file=h xread 
?Import Parameter Files=h param=API 
?MAB2-Daten=x var "MAB2"\ins #uvI\exec fremd 
?Pica-Daten=x var "PICA"\ins #uvI\exec fremd 
?MARC-Daten=x var "OCLC"\ins #uvI\exec fremd 
?VLB-Daten=x var "VLB"\ins #uvI\exec fremd 
?CockPit=X cockpit