539 lines
16 KiB
Plaintext
Executable File
539 lines
16 KiB
Plaintext
Executable File
program DC4
|
|
*******************************************************************************
|
|
*
|
|
*
|
|
* Convert dictionary item(s) from Pick to Uni*Verse format:
|
|
* entry point and main control loop
|
|
*
|
|
* Module %M% Version %I% Date %H%
|
|
*
|
|
* (c) Copyright 1998 Ardent Software Inc. - All Rights Reserved
|
|
* This is unpublished proprietary source code of Ardent Software Inc.
|
|
* The copyright notice above does not evidence any actual or intended
|
|
* publication of such source code.
|
|
*
|
|
* The basis for this Pick-to-Uni*Verse dictionary converter was a
|
|
* Microdata-to-Prime converter written by J. Michael Cannady and
|
|
* Thomas J. Rauschenbach of Fulcrum Computer Group, Inc. Ardent
|
|
* was granted permission to use that code by Infocel, Inc., a successor
|
|
* of Fulcrum.
|
|
*
|
|
*******************************************************************************
|
|
*
|
|
*
|
|
* Maintenence log - insert most recent change descriptions at top
|
|
*
|
|
* Date.... GTAR# WHO Description.........................................
|
|
* 10/22/98 23801 SAP Change company name to Ardent
|
|
* 10/14/98 23801 SAP Change copyrights.
|
|
* 06/12/96 18438 JC Port to NT
|
|
* 08/01/89 - MR # 6152, put release four DC in release 5
|
|
* 09/23/86 - MR #3241, reworked handling of @-phrase HBB
|
|
* 08/18/86 - MR #3102, changed DC.COMMON.DECL to DC.COMM.DECL HBB
|
|
* 07/23/86 - MR #2945, permit description after A or S in field 1 HBB
|
|
* 07/03/86 - MR #2694, when converting item named after the file, replace
|
|
* modulo with item name in UV dict. HBB
|
|
* 05/15/86 - MR #2663, replaced "execute SSELECT" with "sselect" HBB
|
|
* 03/15/86 - MR history purged at 3.4.1, see previous release for changes
|
|
*
|
|
*******************************************************************************
|
|
*
|
|
$options DEFAULT
|
|
$include UNIVERSE.INCLUDE DC.COMM.DECL
|
|
DC.ITEM4 = "*DC.ITEM4"
|
|
*
|
|
dummy = @( 0, 0 )
|
|
equ true to 1; equ false to 0
|
|
equ CR to char( 13 ) : char( 10 )
|
|
*
|
|
* << A "clear common" would be meaningless here, since we're using >>
|
|
* << named COMMON. So we must do it by hand. >>
|
|
*
|
|
VTYPE = ""
|
|
SOURCE.MACHINE = ""
|
|
EFV = ""
|
|
UFV = ""
|
|
PFV = ""
|
|
VOC = ""
|
|
LOGGING = 99
|
|
FILE = ""
|
|
ITEM.NAME = ""
|
|
A.AMC = ""
|
|
PARSE.ONLY = ""
|
|
CRT.COL = ""
|
|
LPTR.COL = ""
|
|
MAINTAIN.WHICH = ""
|
|
A.REC.LEVEL = ""
|
|
NO.ERR = ""
|
|
ERR.REC = ""
|
|
UCODE.FV = ""
|
|
NO.UCODES = ""
|
|
PICK.LINE = ""
|
|
*
|
|
items.to.convert = ""
|
|
nogo.msg = "*** Not converted. ***"
|
|
using.select = false
|
|
*
|
|
* << Get rid of "DC " in the invoking sentence. >>
|
|
*
|
|
sentence = trim( @sentence )
|
|
sentence = field( sentence, " ", 2, 9999 )
|
|
if sentence[ 1, 1 ] = "-" then
|
|
*
|
|
* << User is allowed to answer the "send to printer", "name the source
|
|
* << machine", and "which style will you maintain" prompts with a single
|
|
* << option. E.g., "DC -NOU" means no printed output, other
|
|
* << (non-Microdata) source, and maintain UniVerse dictionaries.
|
|
*
|
|
options = upcase( field( sentence, " ", 1, 1 ))
|
|
good.options = true
|
|
for opt.pos = 1 to len( options )
|
|
begin case
|
|
case options[ opt.pos, 1 ] = "Y"
|
|
LOGGING = true
|
|
case options[ opt.pos, 1 ] = "L"
|
|
LOGGING = true
|
|
case options[ opt.pos, 1 ] = "N"
|
|
LOGGING = false
|
|
case options[ opt.pos, 1 ] = "M"
|
|
SOURCE.MACHINE = "M"
|
|
case options[ opt.pos, 1 ] = "O"
|
|
SOURCE.MACHINE = "O"
|
|
case options[ opt.pos, 1 ] = "P"
|
|
MAINTAIN.WHICH = "P"
|
|
case options[ opt.pos, 1 ] = "U"
|
|
MAINTAIN.WHICH = "U"
|
|
case options[ opt.pos, 1 ] = "-"
|
|
null
|
|
case 1
|
|
good.options = false
|
|
end case
|
|
next opt.pos
|
|
if good.options then
|
|
sentence = field( sentence, " ", 2, 9999 )
|
|
end
|
|
end
|
|
*
|
|
*
|
|
* << Go get name of file to convert. >>
|
|
if len( sentence ) then
|
|
gosub 500
|
|
FILE = stuff
|
|
loop
|
|
while ( len( sentence )) do
|
|
gosub 500
|
|
ins stuff before items.to.convert< 1, -1, 0 >
|
|
repeat
|
|
end
|
|
*
|
|
open "" , "VOC" to VOC else
|
|
call @DC.MESSAGE( "Unable to open VOC.", "Dictionary converter halting." )
|
|
stop
|
|
end
|
|
*
|
|
if items.to.convert then
|
|
gosub 75
|
|
end else
|
|
gosub 50
|
|
end
|
|
*
|
|
* Write out the error record, if required.
|
|
*
|
|
if not( NO.ERR ) and ERR.REC <> "" then
|
|
err.id = "DC.ERRORS_" : iconv( time(), "MD0" ) : "_" : date()
|
|
print
|
|
print 'Error list written to file "&SAVEDLISTS&" item "' : err.id : '".'
|
|
write ERR.REC on EFV, err.id
|
|
end
|
|
print
|
|
stop
|
|
*
|
|
*
|
|
*
|
|
******************************************************************************
|
|
* S U B R O U T I N E S
|
|
******************************************************************************
|
|
*
|
|
*
|
|
*
|
|
******************************************************
|
|
50
|
|
* Convert entire dictionary or multiple dictionaries
|
|
*
|
|
******************************************************
|
|
*
|
|
*
|
|
list.of.files = ""
|
|
*
|
|
print @( -1 )
|
|
print @( 0, 0 ) : str( "=", 79 )
|
|
print @( 15, 2 ) : "Convert dictionaries from Pick to Uni*Verse format."
|
|
print @( 0, 4 ) : str( "=", 79 )
|
|
print
|
|
*
|
|
if LOGGING = 99 then
|
|
print "Send listing to the printer (Y/N) " :
|
|
input ans
|
|
if ans[ 1, 1 ] = "N" then
|
|
LOGGING = false
|
|
end else
|
|
LOGGING = true
|
|
end
|
|
print
|
|
end
|
|
*
|
|
* << Either the user has a SELECT list of files to convert, or he has >>
|
|
* << given us a single file name, or we must prompt him. >>
|
|
*
|
|
if FILE = "" then
|
|
*
|
|
* << The user didn't provide us a single file name. See if there's >>
|
|
* << a SELECT list. >>
|
|
*
|
|
eosl = false
|
|
using.select = true
|
|
readnext FILE from 0 else
|
|
using.select = false
|
|
eosl = true
|
|
FILE = ""
|
|
end
|
|
if eosl then
|
|
*
|
|
* << No SELECT list. Must prompt for file name. >>
|
|
*
|
|
print "Enter name of dictionary to convert, "
|
|
print " or '*' for all local dictionaries " :
|
|
input ans
|
|
begin case
|
|
case ans = "*"
|
|
using.select = true
|
|
execute "SELECTFL TO 1"
|
|
eov = false
|
|
loop
|
|
readnext vocitem.name from 1 else eov = true
|
|
until eov do
|
|
read vocitem from VOC, vocitem.name then
|
|
if count( convert('\','/',vocitem< 3 >), "/" ) = 0 and vocitem.name[ len( vocitem.name ) - 1, 2 ] <> ".O" and vocitem.name[ 1, 3 ] <> "VOC" and vocitem.name[ 1, 1 ] <> "&" then
|
|
FILE = vocitem.name
|
|
print "Convert DICT " : FILE : " (y/n) " :
|
|
input ans
|
|
if ans[ 1, 1 ] = "Y" or ans[ 1, 1 ] = "y" then
|
|
list.of.files = insert( list.of.files, -1; FILE )
|
|
end
|
|
end
|
|
end else
|
|
print "A SELECTed item -- " : vocitem.name :
|
|
print " -- cannot be read from your VOC."
|
|
end
|
|
repeat
|
|
case ans = ""
|
|
stop
|
|
case 1
|
|
list.of.files = ans
|
|
end case
|
|
end else
|
|
*
|
|
* << There was a SELECT list. Use it. >>
|
|
*
|
|
loop
|
|
list.of.files = insert( list.of.files, -1; FILE )
|
|
readnext FILE from 0 else eosl = true
|
|
until eosl do
|
|
repeat
|
|
end
|
|
end else
|
|
*
|
|
* << We were given an explicit file name. >>
|
|
*
|
|
list.of.files = FILE
|
|
end
|
|
*
|
|
* << Now convert the files in the list. >>
|
|
*
|
|
loop
|
|
while list.of.files <> "" do
|
|
FILE = list.of.files< 1 >
|
|
list.of.files = delete( list.of.files, 1 )
|
|
gosub 100
|
|
repeat
|
|
return
|
|
*
|
|
*
|
|
*
|
|
*********************************************
|
|
75
|
|
* Convert only specified dictionary item(s)
|
|
*
|
|
*********************************************
|
|
*
|
|
*
|
|
LOGGING = false
|
|
call @DC.OPENS( true, proceed ); * Open files.
|
|
if not( proceed ) then stop; * Abort conversion.
|
|
readv SOURCE.MACHINE from PFV, "&PICK.SOURCE.MACHINE&", 1 else
|
|
SOURCE.MACHINE = "O"
|
|
end
|
|
nbr.items = count( items.to.convert, @VM ) + 1
|
|
for di = 1 to nbr.items
|
|
ITEM.NAME = items.to.convert< 1, di >
|
|
*
|
|
read dict.item from PFV, ITEM.NAME then
|
|
call @DC.MESSAGE( fmt( "Converting " : ITEM.NAME, "L#25" ), "" )
|
|
if ITEM.NAME <> "@ID" and ITEM.NAME[ 1, 6 ] <> "&PICK." then
|
|
gosub 300; * Check D/TYPE and A/AMC
|
|
if not( skip.item ) then
|
|
gosub 400; * Convert the dictionary item
|
|
end; * if not( skip.item )
|
|
end; * if not @ID and not &PICK.
|
|
end else; * read then
|
|
*
|
|
* << It was deleted. Delete Uni*Verse version as well. >>
|
|
*
|
|
print "Deleting DICT " : FILE : " " : ITEM.NAME : "."
|
|
sleep 1
|
|
delete UFV, ITEM.NAME
|
|
*
|
|
end; * read
|
|
*
|
|
if num( ITEM.NAME ) and ITEM.NAME then
|
|
*
|
|
* << Numeric item-ID. Be sure that it's in the @-phrase. >>
|
|
*
|
|
gosub 200
|
|
end; * if num( ITEM.NAME )
|
|
*
|
|
next di
|
|
return
|
|
*
|
|
*
|
|
*
|
|
************************************
|
|
100
|
|
* Main conversion control routine.
|
|
*
|
|
************************************
|
|
*
|
|
*
|
|
call @DC.OPENS( using.select, proceed ); * Open files.
|
|
if not( proceed ) then return; * Abort conversion of current dict.
|
|
|
|
if LOGGING then
|
|
left.half = iconv((( 110 - len( FILE )) / 2), "MD0" )
|
|
right.half = 110 - len( FILE ) - left.half
|
|
print on 1 str( "#", 130 )
|
|
print on 1 str( "#", left.half ) : space( 20 + len( FILE )) : str( "#", right.half )
|
|
print on 1 str( "#", left.half ) : " Converting DICT " : FILE : " ":
|
|
print on 1 str( "#", right.half )
|
|
print on 1 str( "#", left.half ) : space( 20 + len( FILE )) : str( "#", right.half )
|
|
print on 1 str( "#", 130 )
|
|
print on 1
|
|
end
|
|
print
|
|
print "Converting DICT " : FILE
|
|
*
|
|
sselect PFV to 2; * Use SELECT list 2 for item list
|
|
*
|
|
* << Copy all items from P_FILE to D_FILE, converting if valid. >>
|
|
*
|
|
eop = false
|
|
loop
|
|
readnext ITEM.NAME from 2 else eop = true
|
|
until eop do
|
|
120 read dict.item from PFV, ITEM.NAME else
|
|
print "SELECTed item '": ITEM.NAME :
|
|
print "' cannot be read from PDICT " : FILE : "."
|
|
print "Enter <CR> to try again, anything else to quit "
|
|
input ans:
|
|
if ans = "" then
|
|
GOTO 120
|
|
end else
|
|
proceed = false
|
|
return
|
|
end
|
|
end
|
|
if ITEM.NAME[ 1, 6 ] <> "&PICK." and ITEM.NAME <> "@ID" then
|
|
call @DC.MESSAGE( fmt( ITEM.NAME, "L#25" ), "" )
|
|
gosub 300; * Check D/TYPE, A/AMC
|
|
if not( skip.item ) then
|
|
gosub 400; * Convert the item.
|
|
end
|
|
end
|
|
repeat
|
|
*
|
|
*
|
|
* << Create the "@" dictionary entry to control listings. >>
|
|
*
|
|
gosub 200
|
|
*
|
|
read dict.item from UFV, "@ID" else
|
|
dict.item = ""
|
|
dict.item< 1 > = "D"
|
|
dict.item< 2 > = 0
|
|
dict.item< 4 > = FILE
|
|
dict.item< 5 > = "10R"
|
|
dict.item< 6 > = "S"
|
|
write dict.item on UFV, "@ID"
|
|
end
|
|
*
|
|
* Compile the I-descriptors.
|
|
*
|
|
print
|
|
print "Compiling I-descriptors."
|
|
execute "CD " : FILE
|
|
print
|
|
print
|
|
if LOGGING then
|
|
print on 1 char( 12 )
|
|
end
|
|
return
|
|
*
|
|
*
|
|
*
|
|
************************************
|
|
300
|
|
* Check D/TYPE and A/AMC of Pick
|
|
* item.
|
|
*
|
|
************************************
|
|
*
|
|
*
|
|
* << Convert items with A or S D/TYPES. Copy any others as they are. >>
|
|
*
|
|
skip.item = false; * Convert or not?
|
|
dict.item< 1 > = trim( dict.item< 1 >)
|
|
begin case
|
|
case ITEM.NAME = FILE or ITEM.NAME = "DL/ID"
|
|
delete UFV, ITEM.NAME; * Will change to "@ID"
|
|
dict.item< 1 > = "A"; * In Pick, is "D"
|
|
dict.item< 2 > = 0; * In Pick, is the base frame
|
|
dict.item< 3 > = ITEM.NAME; * In Pick, is the modulo
|
|
ITEM.NAME = "@ID"
|
|
*
|
|
case dict.item< 1 >[ 1, 1 ] = "A" or dict.item< 1 >[ 1, 1 ] = "S"
|
|
if num( dict.item< 2 > ) and count( dict.item< 2 >, @VM ) = 0 then
|
|
null
|
|
end else
|
|
call @DC.MESSAGE( "Non-numeric A/AMC: " : dict.item< 2 > : ".", "Copied verbatim." )
|
|
call @DC.MESSAGE( nogo.msg, CR )
|
|
if not( NO.ERR ) then
|
|
ins FILE : " " : ITEM.NAME before ERR.REC< -1 >
|
|
end
|
|
skip.item = true
|
|
end
|
|
*
|
|
case 1
|
|
call @DC.MESSAGE( "Unconvertible D/TYPE: " : dict.item< 1 > : ".", "Copied verbatim." )
|
|
call @DC.MESSAGE( nogo.msg, CR )
|
|
if not( NO.ERR ) then
|
|
ins FILE : " " : ITEM.NAME before ERR.REC< -1 >
|
|
end
|
|
skip.item = true
|
|
*
|
|
end case
|
|
if skip.item then
|
|
write dict.item on UFV, ITEM.NAME
|
|
end
|
|
return
|
|
*
|
|
*
|
|
*
|
|
************************************
|
|
400
|
|
* Read the item. Call @DC.ITEM to
|
|
* convert it, then write it.
|
|
*
|
|
************************************
|
|
*
|
|
*
|
|
assoc.item = ""
|
|
assoc.name = ""
|
|
result = ""
|
|
*
|
|
*410 read dict.item from UFV, ITEM.NAME else
|
|
* print "SELECTed item '": ITEM.NAME :
|
|
* print "' cannot be read from DICT '" : FILE : "'."
|
|
* print "Enter <CR> to try again, 'Q' to quit"
|
|
* input pause :
|
|
* if pause = "" then
|
|
* goto 410
|
|
* end else
|
|
* call @DC.MESSAGE( "Dictionary converter halting.", "" )
|
|
* stop
|
|
* end
|
|
* end
|
|
*
|
|
call @DC.ITEM4( dict.item, assoc.name, assoc.item, result )
|
|
*
|
|
if result then
|
|
call @DC.MESSAGE( "Converted.", CR )
|
|
end else
|
|
call @DC.MESSAGE( nogo.msg, CR )
|
|
end
|
|
*
|
|
write dict.item on UFV, ITEM.NAME
|
|
*
|
|
return
|
|
*
|
|
*
|
|
*
|
|
**************************************************************************
|
|
500
|
|
* Parse the command-line sentence for the next name. It may be quoted,
|
|
* and, if it is, it may contain blanks.
|
|
*
|
|
**************************************************************************
|
|
*
|
|
*
|
|
loop
|
|
while sentence[ 1, 1 ] = " " do
|
|
sentence = sentence[ 2, len( sentence )]
|
|
repeat
|
|
*
|
|
stuff = ""
|
|
if sentence[ 1, 1 ] = '"' or sentence[ 1, 1 ] = "'" or sentence[ 1, 1 ] = "\" then
|
|
quote = sentence[ 1, 1 ]
|
|
sentence = sentence[ 2, len( sentence )]
|
|
loop
|
|
while sentence[ 1, 1 ] <> quote and len( sentence ) do
|
|
stuff := sentence[ 1, 1 ]
|
|
sentence = sentence[ 2, len( sentence )]
|
|
repeat
|
|
if sentence[ 1, 1 ] <> quote then
|
|
call @DC.MESSAGE( "Unable to parse command-line sentence: ", sentence )
|
|
stop
|
|
end
|
|
sentence = sentence[ 2, len( sentence )]
|
|
end else
|
|
stuff = field( sentence, " ", 1 )
|
|
sentence = sentence[ COL2() + 1, LEN( sentence )]
|
|
end
|
|
return
|
|
*
|
|
*
|
|
********************************
|
|
200
|
|
* Create/amend the @-phrase
|
|
********************************
|
|
*
|
|
at.phrase = ""
|
|
quit.loop = false
|
|
for i = 1 to 100 until quit.loop
|
|
readv xx from UFV, i, 0 then
|
|
at.phrase := " " : i
|
|
end else
|
|
quit.loop = true
|
|
end
|
|
next i
|
|
at.phrase = trim( at.phrase )
|
|
if at.phrase then
|
|
at.rec = ""
|
|
at.rec< 1 > = "PH"
|
|
at.rec< 2 > = at.phrase
|
|
write at.rec on UFV, "@"
|
|
end else
|
|
delete UFV, "@"
|
|
end
|
|
return
|
|
end
|
|
|