Exporting a Datafile

LocoScript's data files are held in a highly compact and coded form and so cannot be used directly by other programs. To take a LocoScript PC or LOCOScript Professional datafile to use with other PC database programs, you need to change the file to a form that the other program can work with. This is done in two stages: first extracting the data into an ordinary LocoScript document, packaging each item of data in a way that the other database program will be able to work with; and second, converting the LocoScript document to a plain text file that contains no word processing codes (called an ASCII file).

Deciding on the format

Before you do this, you will need to understand how your new database program can read in data - ie how to package up the individual pieces of data. For example, if each record of your datafile has the items of information:

Name

A person's name

Address

Their address

Phone

Their phone number

you might be able to simply use a special \ character to separate the items, with # separating each record. So each "exported" record would look like:

Name\Address\Phone#

The details of this should be explained by the documentation for your new database. It might refer to this as Importing a datafile. If you are lucky, it may be able to import datafiles in "CSV" format. This stands for Comma Separated Values and the above example would need to be translated to lines of the form:

Name, Address, Phone

or to avoid problems if, say, Address itself contained commas or the newline character:

"Name", "Address", "Phone"

If you cannot find this information from the documentation for your new database, consult the supplier of the database - we cannot provide detailed help on other companies' products.

Exporting the database

The way you change the datafile to a document formatted as above is by a LocoScript Merge. You need to produce a Merge Master Document which can be merged with your Datafile to produce a document containing each of the items from each of your datafile's records, separated by the special characters needed. Note that this information sheet is specific to LocoScript PC, but the procedure on a PCW with LocoMail and LocoFile is generally similar.

To do this, create a new document in the normal way. Call this EXPORTDB.MGE and delete any initial text that may come from your template. Show word processing codes by pressing [f8] and setting Codes: to shown. Start by typing a Mail word processing code by pressing the [+] key on the numeric keypad and then the letter M. This will be displayed as (Mail)

The rest of what you are about to type are instructions to the merge part of LocoScript. You will first tell the merge what special separators to use between the items and records, then list how you want to lay out one record and finally give a special command to repeat this for each record in your datafile.

In the case: Name\Address\Phone#

the separators are \ between items - we'll call this sep

the record separator is # - we'll call this recsep

and there's nothing at the start (if there were we'd call it recstart).

We tell Merge this by typing instructions:

sep="\"
recsep="#"
recstart=""

where the " character is used to start and finish the actual text we want to use and "" means nothing.

In the CSV case: "Name", "Address", "Phone"[return]

sep is ", "
recsep is "[return]
recstart is "

(where [return] is the carriage return character)

The problem with the CSV case is that we actually want to use the " character inside the " " text. We can do this by putting in (-Mail) and (+Mail) codes (typed by [-] M and [+] M respectively).

This makes the instructions:

sep="(-Mail)", "(+Mail)"
recsep="(-Mail)"[return](+Mail)"
recstart="(-Mail)"(+Mail)"

The command to set up how a record will be processed is:

loop="
recstart : Name : sep : Address : sep : Phone : recsep
$+
"

where Name, Address etc. are the names you have used in your datafile; recstart, sep etc. are the separators set up by the above instructions and the other lines are instructions to Merge which you should type verbatim. If you have more or less items in your records add/remove pairs of item-name : sep as necessary.

And finally, you need an instruction to process all the records in the file. In LOCOScript Professional, this is:

%loop @ $#

(This actually means repeat the commands in loop until no more records are left, but simply type in the instruction verbatim and it should work!)

Thus the complete Merge "program" is:

using simple \ and # characters

to use a CSV file

sep="\"
recsep="#"
recstart=""
loop="
recstart : Name : sep : Address : sep : Phone : recsep
$+
"
%loop @ $#

sep="(-Mail)", "(+Mail)"
recsep="(-Mail)"[return](+Mail)"
recstart="(-Mail)"(+Mail)"
loop="
recstart : Name : sep : Address : sep : Phone : recsep
$+
"
%loop @ $#

 

Having typed in the above program (with the names changed to match the items in your datafile), select Finish edit from the [f10] menu in the normal way. Then Merge the master document with your datafile as follows:

  1. Highlight the merge master document
  2. Press M for merge
  3. when prompted, move the cursor to highlight your datafile
  4. press [Enter], check the files are correct and move down to the line "Automatic" and press [Enter]

At the end of the merge press [f10] and select Save result. Give this an appropriate name and press [Enter].

Changing to ASCII

The result of the above merge is still a LocoScript document, so will not be able to be read by your other database program. To make it readable, you need to convert the result of the Merge to ASCII. To do this:

  1. In the disc manager, highlight the file just created by the Merge
  2. Press [f9]
  3. Select Export document
  4. If ASCII is not shown against Type: move to that line and press the space bar until it is.
  5. Press [f10]
  6. In the menu that appears give a name to the text copy you are about to create.

And finally

You now need to run your new database program and import the text copy of the file you have just created. You may need to consult the suppliers of your new program on this - we cannot assist.

An alternative

If you do not want to carry out this procedure, then we do have a Windows program you can run to do it all for you. LocoLink for Windows (PC version) will take a LocoScript Datafile and convert it to a CSV text file. You do however have slightly less control over the order the information is produced in, which may affect importing it into your new database. Also, only a limited range of database formats is supported.

LocoLink for Windows (PC version) costs £39.95 incl VAT and delivery. It will run on Windows 3.1 or later or Windows 95 or 98.

PCW LocoFile datafiles

Much of the procedure outlined above will also work on an Amstrad PCW. The keys to press in a few cases will be slightly different because of the PCW's dedicated keyboard. Also, you will find the Save as ASCII option in the f1 menu, not f9. You will then have a final step - converting the PCW disk to a PC disk.