home *** CD-ROM | disk | FTP | other *** search
- /* This arexx programm is intended to help you getting your database data
- from DATAMAT to Twist. The programm will convert a .DIF file produced
- by DATAMAT to a standard komma file importable in Twist. This conversion
- is needed if any field contains kommas, quotation marks or linefeeds.
-
- The first step is to create the .DIF file in DATAMAT or DATAMAT
- Profesional:
- - Select the menu:
- Optionen -> Arbeitsumgebungen ändern... -> Ein-Ausgabe
- - In the opening requester change the "Feldtrenner" value to: A4 and
- change the "Satztrenner" value to: A5
- - Close the requester by clicking on "OK"
- To ensure that all fields are exported and that they are exported in the
- right sequence make a new field selection.
- - Select the menu option: Optionen -> Feldauswahl treffen (Amiga T).
- - Enter an ascending number (ie 1 in the first field, 2 in the next
- field, and so on..) in all the fields you wish to export.
- - When all fields have been numbered select the menu item again (now
- labeled "Feldauswahl beenden")
- - confirm that you wish to save the new field selection.
-
- - Open your DATAMAT database file window and select the menu:
- Ein-Ausgabe -> Textdatei -> Ausgeben
- - In the opening file name requester enter a filename. DATAMAT will by
- it self add the extension .DIF
-
- - Open a shell window and start this arexx program with the filename
- as its argument. E.g.
-
- RX twist:arexx/datamatdif_to_txt.rexx myaddressbook
-
- The argument should include a fully qualifying path but not the .DIF
- extension. The arexx program will create a new file with the same name
- and path but with the extension .TXT
-
- IF SUCH A FILE ALREADY EXISTS TWIST WILL OVERWRITE IT.
-
- The conversion is rather slow. On an A3000 about 10 KB per minute. The
- converted file has each field enclosed in quotiation marks and separated
- by kommas. Every record ends with a line feed. If the fields contain
- doublequotation marks these will be converted to singe quotes ( " -> ' )
-
- - Start Twist and create a new file with the same fields as the
- DATAMAT file. Make sure that text fields have a length large enough
- to the maximum size of the DATAMAT form layout. Fields larger than
- 50 characters should problably be set to file type "Compressed".
-
- - Use a text field for time fields with length 8 and a calc formular
-
- "TimeStr(TimeVal(<fieldname>))"
-
- (You need to first define the field before you can enter the calculation
- string. Of course <fieldname> should be replaced by the actual field
- name)
-
- When all the fields have been added close the "Edit fields" window and
- from the opening database window select the menu: "Datensatz -> Impor-
- tiere..."
-
- In the import window make sure that "Durch Komma getrennt" and "Mehr-
- zeilige Felder" is selected. Select the File requester symbol at the
- "Name" gadget and pick the file just created by the arexx programm.
-
- After that the "Start" gadget can be be activated and Twist will start
- to import the data. When finished look at the records imported in "list
- modus" (table mode) make sure that the records have been imported with
- the right sequence of fields (ie that the "strasse" field does in fact
- contain values for that field and not for "Vorname").
-
- If the sequence of fields was wrong delete all imported records (Daten-
- satz -> Alle markieren + "Lösche") and change the sequence of the fields
- in the import window before you retry.
-
- Mermaid Group 24/10/94
- */
-
- PARSE ARG dif_filename
- Say "This program converts an exported .DEF file from DATAMAT (Profesional)"
- say "to a .TXT file that can be imported into Twist2"
- say "For full instructions load this file into an editor an read the comments"
- say ""
- if dif_filename = "" then
- do
- say "Enter name of .DIF file to convert (don't enter .DIF extension)"
- pull dif_filename
- if dif_filename = "" then exit
- end
-
- difopenok = open('input',dif_filename || ".DIF" ,'R')
- if ~difopenok then
- do
- say "Unable to open " || dif_filename || ".DIF"
- exit
- end
- txtopenok = open('output', dif_filename || ".TXT", 'W')
- if ~txtopenok then
- do
- say "Unable to create " || dif_filename || "TXT"
- exit
- end
-
- field_delimchr = x2c(a4)
- record_delimchr = x2c(a5)
-
- fsiz = seek('input',0,'E')
- seek('input',0,'B')
-
- rlen = 0
- rpos = 1
- outstr = '"'
- do FOREVER
- if (rpos > rlen) then /* Read the next block from the file */
- do
- rlen = min(fsiz,1024)
- if rlen <= 0 then leave
- fsiz = fsiz - rlen
- readbuf = readch('input', rlen)
- rpos = 1
- end
-
- chr = substr(readbuf, rpos, 1) /* Get next chr from read buffer */
- rpos = rpos + 1
-
- select /* examine chr for field and record delimiters perform conversion */
- when chr = field_delimchr then outstr = outstr || '","'
- when chr = record_delimchr then
- do
- writech('output', outstr || '"' || x2c(a)) /* Write the whole converted record string to the output file */
- outstr = '"'
- end
- when chr = '"' then outstr = outstr || "'"
- otherwise outstr = outstr || chr
- end
- end
- close('output')
- close('input')
-
-